• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2## Test that -r keeps local symbols which are used in relocations even when
3## --discard-{locals,all} is given.
4
5# RUN: llvm-mc -filetype=obj -triple=x86_64 -save-temp-labels %s -o %t.o
6
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
10
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
14
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 {{.*}} unused
19# DISCARD-LOCALS-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} unused_gc
20# DISCARD-LOCALS-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} used
21# DISCARD-LOCALS-NEXT:           SECTION LOCAL  DEFAULT {{.*}} .text
22# DISCARD-LOCALS-NEXT:           SECTION LOCAL  DEFAULT {{.*}} text
23# DISCARD-LOCALS-NEXT:           SECTION LOCAL  DEFAULT {{.*}} gc
24# DISCARD-LOCALS-NEXT:           NOTYPE  GLOBAL DEFAULT {{.*}} _start
25
26## --discard-all removes all unused regular local symbols.
27# DISCARD-ALL:    0: {{0+}} 0 NOTYPE  LOCAL  DEFAULT UND
28# DISCARD-ALL-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} .Lused
29# DISCARD-ALL-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} used
30# DISCARD-ALL-NEXT:           SECTION LOCAL  DEFAULT {{.*}} .text
31# DISCARD-ALL-NEXT:           SECTION LOCAL  DEFAULT {{.*}} text
32# DISCARD-ALL-NEXT:           SECTION LOCAL  DEFAULT {{.*}} gc
33# DISCARD-ALL-NEXT:           NOTYPE  GLOBAL DEFAULT {{.*}} _start
34
35# REL:      .rela.text {
36# REL-NEXT:   R_X86_64_PLT32 text 0xFFFFFFFFFFFFFFFC
37# REL-NEXT:   R_X86_64_PLT32 .Lused 0xFFFFFFFFFFFFFFFC
38# REL-NEXT:   R_X86_64_PLT32 used 0xFFFFFFFFFFFFFFFC
39# REL-NEXT: }
40
41.globl _start
42_start:
43  call text@plt
44  jmp .Lused@plt
45  call used@plt
46
47.section text,"ax"
48.Lunused:
49.Lused:
50unused:
51used:
52
53.section gc,"ax"
54.Lunused_gc:
55unused_gc:
56  ret
57