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
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
51 leaq
.L.str(%rip), %rdi
64 .section .rodata.str1.1,"aMS",@progbits,1