[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / comdat-discarded-lazy.s
blob23b922abb8d6a8bb9216335f21835df5db95f2bc
1 # REQUIRES: x86
2 ## Test that lazy symbols in a section group can be demoted to Undefined,
3 ## so that we can report a "discarded section" error.
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
6 # RUN: echo '.globl f1, foo; f1: call foo; \
7 # RUN: .section .text.foo,"axG",@progbits,foo,comdat; foo:' | \
8 # RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
10 ## Test the case when the symbol causing a "discarded section" is ordered
11 ## *before* the symbol fetching the lazy object.
12 ## The test relies on the symbol table order of llvm-mc (lexical), which will
13 ## need adjustment if llvm-mc changes its behavior.
14 # RUN: echo '.globl aa, f2; f2: .weak foo; foo: call aa; \
15 # RUN: .section .text.foo,"axG",@progbits,foo,comdat; aa:' | \
16 # RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %taa.o
17 # RUN: llvm-nm -p %taa.o | FileCheck --check-prefix=AA-NM %s
18 # RUN: not ld.lld %t.o --start-lib %t1.o %taa.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s
19 # RUN: rm -f %taa.a && llvm-ar rc %taa.a %taa.o
20 # RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %taa.a -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s
22 # AA-NM: aa
23 # AA-NM: f2
25 # AA: error: relocation refers to a symbol in a discarded section: aa
26 # AA-NEXT: >>> defined in {{.*}}aa.o
27 # AA-NEXT: >>> section group signature: foo
28 # AA-NEXT: >>> prevailing definition is in {{.*}}1.o
29 # AA-NEXT: >>> or the symbol in the prevailing group {{.*}}
30 # AA-NEXT: >>> referenced by {{.*}}aa.o:(.text+0x1)
32 ## Test the case when the symbol causing a "discarded section" is ordered
33 ## *after* the symbol fetching the lazy object.
34 # RUN: echo '.globl f2, zz; .weak foo; foo: f2: call zz; \
35 # RUN: .section .text.foo,"axG",@progbits,foo,comdat; zz:' | \
36 # RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %tzz.o
37 # RUN: llvm-nm -p %tzz.o | FileCheck --check-prefix=ZZ-NM %s
38 # RUN: not ld.lld %t.o --start-lib %t1.o %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
39 # RUN: rm -f %tzz.a && llvm-ar rc %tzz.a %tzz.o
40 # RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %tzz.a -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
42 # ZZ-NM: f2
43 # ZZ-NM: zz
45 # ZZ: error: relocation refers to a symbol in a discarded section: zz
46 # ZZ-NEXT: >>> defined in {{.*}}zz.o
47 # ZZ-NEXT: >>> section group signature: foo
48 # ZZ-NEXT: >>> prevailing definition is in {{.*}}1.o
49 # ZZ-NEXT: >>> or the symbol in the prevailing group {{.*}}
50 # ZZ-NEXT: >>> referenced by {{.*}}zz.o:(.text+0x1)
52 ## The definition in %tdef.o is outside a group. Currently we give an error
53 ## because %tdef.o is not extracted.
54 # RUN: echo '.globl zz; zz:' | llvm-mc -filetype=obj -triple=x86_64 - -o %tdef.o
55 # RUN: not ld.lld %t.o --start-lib %t1.o %tdef.o %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
56 # RUN: rm -f %tdef.a && llvm-ar rc %tdef.a %tdef.o
57 # RUN: not ld.lld %t.o --start-lib %t1.o %tdef.a %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
59 .globl _start
60 _start:
61 call f1
62 call f2