aboutsummaryrefslogtreecommitdiff
path: root/lld/test
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin@accesssoftek.com>2024-05-29 14:53:29 -0700
committerGitHub <noreply@github.com>2024-05-29 14:53:29 -0700
commit34b14cc4f88b5e3d757f2ab20c19387178056567 (patch)
tree646d510615769195d97ec3f3f0ad5fdc16ae3e0f /lld/test
parent058d4295939998923c78df80d0ea3b82ed899aa1 (diff)
downloadllvm-34b14cc4f88b5e3d757f2ab20c19387178056567.zip
llvm-34b14cc4f88b5e3d757f2ab20c19387178056567.tar.gz
llvm-34b14cc4f88b5e3d757f2ab20c19387178056567.tar.bz2
[lld][ELF] Suppress `--orphan-handling=error/warn` without `SECTIONS` (#93630)
Without a linker script, `--orphan-handling=error` or `=warn` reports all input sections, including even well-known sections like `.text`, `.bss`, `.dynamic`, or `.symtab`. However, in this case, no sections should be considered orphans because they all are placed with the same default rules. This patch suppresses errors/warnings for placing orphan sections if no linker script with the `SECTIONS` command is provided. The proposed behavior matches GNU gold. GNU ld in the same scenario only reports sections that are not in its default linker script, thus, it avoids complaining about `.text` and similar.
Diffstat (limited to 'lld/test')
-rw-r--r--lld/test/ELF/linkerscript/orphan-report.s7
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/test/ELF/linkerscript/orphan-report.s b/lld/test/ELF/linkerscript/orphan-report.s
index 3dca232..eedcc4e 100644
--- a/lld/test/ELF/linkerscript/orphan-report.s
+++ b/lld/test/ELF/linkerscript/orphan-report.s
@@ -11,6 +11,13 @@
# RUN: ld.lld -shared --orphan-handling=place -o %t.out --script %t.script \
# RUN: %t.o 2>&1 -verbose -error-limit=0 | FileCheck %s --check-prefix=DEFAULT
+## Check --orphan-handling=error or =warn do not report errors if no linker
+## script is used.
+# RUN: ld.lld -shared -orphan-handling=error -o /dev/null %t.o 2>&1 | count 0
+# RUN: ld.lld -shared -orphan-handling=warn -o /dev/null %t.o 2>&1 | count 0
+# RUN: ld.lld -r -orphan-handling=error -o /dev/null %t.o 2>&1 | count 0
+# RUN: ld.lld -r -orphan-handling=warn -o /dev/null %t.o 2>&1 | count 0
+
## Check --orphan-handling=error reports errors about orphans.
# RUN: not ld.lld --orphan-handling=error -o /dev/null -T %t.script \
# RUN: %t.o 2>&1 | FileCheck %s --check-prefixes=COMMON,SYMTAB