3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4 # RUN: ld.lld %t -o %t2
5 # RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=NOGC %s
6 # RUN: ld.lld --gc-sections --print-gc-sections %t -o %t2 | FileCheck --check-prefix=GC1-DISCARD %s
7 # RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC1 %s
8 # RUN: ld.lld -pie --export-dynamic --gc-sections %t -o %t2
9 # RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC2 %s
11 ## In non-pie static linking, --export-dynamic currently retains the global 'd' even if it is not exported.
12 # RUN: ld.lld --export-dynamic --gc-sections --print-gc-sections %t -o %t1
13 # RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC2 %s
15 # RUN: llvm-mc -filetype=obj -triple=x86_64 --crel %s -o %t.o
16 # RUN: ld.lld -pie --gc-sections --print-gc-sections %t.o -o %t2 | FileCheck --check-prefix=GC1-DISCARD %s
17 # RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC1 %s
19 # NOGC: Name: .eh_frame
28 # NOGC: Name: .fini_array
29 # NOGC: Name: .init_array
30 # NOGC: Name: .preinit_array
33 # NOGC: Name: .debug_pubtypes
34 # NOGC: Name: .comment
46 # GC1-DISCARD: removing unused section {{.*}}:(.text.d)
47 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.text.x)
48 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.text.y)
49 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.tbss.f)
50 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.tdata.h)
51 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.init_x)
52 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.jcr_x)
55 # GC1: Name: .eh_frame
63 # GC1: Name: .fini_array
64 # GC1: Name: .init_array
65 # GC1: Name: .preinit_array
67 # GC1: Name: .debug_pubtypes
80 # GC2: Name: .eh_frame
88 # GC2: Name: .fini_array
89 # GC2: Name: .init_array
90 # GC2: Name: .preinit_array
92 # GC2: Name: .debug_pubtypes
106 .protected a, b, c, e, f, g, h, x, y
110 .section .text.a,"ax",@progbits
115 .section .text.b,"ax",@progbits
117 leaq e@tpoff
(%rax
),%rdx
120 .section .text.c,"ax",@progbits
122 leaq g@tpoff
(%rax
),%rdx
124 .section .text.d,"ax",@progbits
128 .section .text.x,"ax",@progbits
132 .section .text.y,"ax",@progbits
136 .section .tbss.e,"awT",@nobits
140 .section .tbss.f,"awT",@nobits
144 .section .tdata.g,"awT",@progbits
148 .section .tdata.h,"awT",@progbits
152 .section .ctors,"aw",@progbits
155 .section .dtors,"aw",@progbits
161 .section .init_x,"ax"
167 .section .fini_array,"aw",@fini_array
170 # https://golang.org/cl/373734
171 .section .init_array,"aw",@progbits
174 # Work around https://github.com/rust-lang/rust/issues/92181
175 .section .init_array.00001,"aw",@progbits
178 .section .preinit_array,"aw",@preinit_array
187 .section .eh_frame,"a",@unwind
190 .section .debug_pubtypes,"",@progbits
193 .section .comment,"MS",@progbits,8