[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / relocatable-discard-locals.s
blob8941e8de7abc8970da1e7609fe3719e73f9322b3
1 # REQUIRES: x86
2 ## Test that -r keeps local symbols which are used in relocations even when
3 ## --discard-{locals,all} is given.
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 -save-temp-labels %s -o %t.o
7 # RUN: ld.lld -r --discard-locals %t.o -o %tlocal.ro
8 # RUN: llvm-readelf -s %tlocal.ro | FileCheck --check-prefix=DISCARD-LOCALS %s
9 # RUN: llvm-readobj -r %tlocal.ro | FileCheck --check-prefix=REL %s
11 # RUN: ld.lld -r --discard-all %t.o -o %tall.ro
12 # RUN: llvm-readelf -s %tall.ro | FileCheck --check-prefix=DISCARD-ALL %s
13 # RUN: llvm-readobj -r %tall.ro | FileCheck --check-prefix=REL %s
15 ## --discard-locals removes unused local symbols which start with ".L"
16 # DISCARD-LOCALS: 0: {{0+}} 0 NOTYPE LOCAL DEFAULT UND
17 # DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} .Lused
18 # DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} used
19 # DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} .L.str
20 # DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} unused
21 # DISCARD-LOCALS-NEXT: NOTYPE LOCAL DEFAULT {{.*}} unused_gc
22 # DISCARD-LOCALS-NEXT: SECTION LOCAL DEFAULT {{.*}} .text
23 # DISCARD-LOCALS-NEXT: SECTION LOCAL DEFAULT {{.*}} text
24 # DISCARD-LOCALS-NEXT: SECTION LOCAL DEFAULT {{.*}} gc
25 # DISCARD-LOCALS-NEXT: SECTION LOCAL DEFAULT {{.*}} .rodata.str1.1
26 # DISCARD-LOCALS-NEXT: NOTYPE GLOBAL DEFAULT {{.*}} _start
28 ## --discard-all removes all unused regular local symbols.
29 # DISCARD-ALL: 0: {{0+}} 0 NOTYPE LOCAL DEFAULT UND
30 # DISCARD-ALL-NEXT: NOTYPE LOCAL DEFAULT {{.*}} .Lused
31 # DISCARD-ALL-NEXT: NOTYPE LOCAL DEFAULT {{.*}} used
32 # DISCARD-ALL-NEXT: NOTYPE LOCAL DEFAULT {{.*}} .L.str
33 # DISCARD-ALL-NEXT: SECTION LOCAL DEFAULT {{.*}} .text
34 # DISCARD-ALL-NEXT: SECTION LOCAL DEFAULT {{.*}} text
35 # DISCARD-ALL-NEXT: SECTION LOCAL DEFAULT {{.*}} gc
36 # DISCARD-ALL-NEXT: SECTION LOCAL DEFAULT {{.*}} .rodata.str1.1
37 # DISCARD-ALL-NEXT: NOTYPE GLOBAL DEFAULT {{.*}} _start
39 # REL: .rela.text {
40 # REL-NEXT: R_X86_64_PLT32 text 0xFFFFFFFFFFFFFFFC
41 # REL-NEXT: R_X86_64_PLT32 .Lused 0xFFFFFFFFFFFFFFFC
42 # REL-NEXT: R_X86_64_PLT32 used 0xFFFFFFFFFFFFFFFC
43 # REL-NEXT: R_X86_64_PC32 .L.str 0xFFFFFFFFFFFFFFFC
44 # REL-NEXT: }
46 .globl _start
47 _start:
48 call text@plt
49 jmp .Lused@plt
50 call used@plt
51 leaq .L.str(%rip), %rdi
53 .section text,"ax"
54 .Lunused:
55 .Lused:
56 unused:
57 used:
59 .section gc,"ax"
60 .Lunused_gc:
61 unused_gc:
62 ret
64 .section .rodata.str1.1,"aMS",@progbits,1
65 .L.str: .asciz "a"