2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3 # RUN: echo "SECTIONS { .text : { *(.text.1) } }" > %t.script
5 ## Check we do not report orphans by default even with -verbose.
6 # RUN: ld.lld -shared -o %t.out --script %t.script %t.o 2>&1 -verbose \
7 # RUN: | FileCheck %s --check-prefix=DEFAULT
10 ## Check --orphan-handling=place has the same behavior as default.
11 # RUN: ld.lld -shared --orphan-handling=place -o %t.out --script %t.script \
12 # RUN: %t.o 2>&1 -verbose -error-limit=0 | FileCheck %s --check-prefix=DEFAULT
14 ## Check --orphan-handling=error or =warn do not report errors if no linker
16 # RUN: ld.lld -shared -orphan-handling=error -o /dev/null %t.o 2>&1 | count 0
17 # RUN: ld.lld -shared -orphan-handling=warn -o /dev/null %t.o 2>&1 | count 0
18 # RUN: ld.lld -r -orphan-handling=error -o /dev/null %t.o 2>&1 | count 0
19 # RUN: ld.lld -r -orphan-handling=warn -o /dev/null %t.o 2>&1 | count 0
21 ## Check --orphan-handling=error reports errors about orphans.
22 # RUN: not ld.lld --orphan-handling=error -o /dev/null -T %t.script \
23 # RUN: %t.o 2>&1 | FileCheck %s --check-prefixes=COMMON,SYMTAB
25 ## --strip-all discards .strtab and .symtab sections. Don't error about them.
26 # RUN: not ld.lld --orphan-handling=error --strip-all -o /dev/null -T %t.script \
27 # RUN: %t.o 2>&1 | FileCheck %s --check-prefix=COMMON
29 ## -shared enables some .dynsym related sections.
30 # RUN: not ld.lld -shared --orphan-handling=error -o /dev/null -T %t.script \
31 # RUN: %t.o 2>&1 | FileCheck %s --check-prefixes=COMMON,DYNSYM,SYMTAB
33 # COMMON: {{.*}}.o:(.text) is being placed in '.text'
34 # COMMON-NEXT: {{.*}}.o:(.text.2) is being placed in '.text.2'
35 # COMMON-NEXT: <internal>:(.comment) is being placed in '.comment'
36 # DYNSYM-NEXT: <internal>:(.dynsym) is being placed in '.dynsym'
37 # DYNSYM-NEXT: <internal>:(.gnu.hash) is being placed in '.gnu.hash'
38 # DYNSYM-NEXT: <internal>:(.hash) is being placed in '.hash'
39 # DYNSYM-NEXT: <internal>:(.dynamic) is being placed in '.dynamic'
40 # DYNSYM-NEXT: <internal>:(.dynstr) is being placed in '.dynstr'
41 # SYMTAB-NEXT: <internal>:(.symtab) is being placed in '.symtab'
42 # COMMON-NEXT: <internal>:(.shstrtab) is being placed in '.shstrtab'
43 # SYMTAB-NEXT: <internal>:(.strtab) is being placed in '.strtab'
44 # COMMON-NOT: <internal>
46 ## Check --orphan-handling=warn reports warnings about orphans.
47 # RUN: ld.lld --orphan-handling=warn -o /dev/null -T %t.script \
48 # RUN: %t.o 2>&1 | FileCheck %s --check-prefixes=COMMON,SYMTAB
50 # RUN: not ld.lld --orphan-handling=foo -o /dev/null --script %t.script %t.o 2>&1 \
51 # RUN: | FileCheck %s --check-prefix=UNKNOWN
52 # UNKNOWN: unknown --orphan-handling mode: foo