Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / gc-sections.s
blob94adc8210b4bc67790976e69743d2d1e7396fa92
1 # REQUIRES: x86
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 --export-dynamic --gc-sections %t -o %t2
9 # RUN: llvm-readobj --sections --symbols %t2 | FileCheck -check-prefix=GC2 %s
11 # NOGC: Name: .eh_frame
12 # NOGC: Name: .text
13 # NOGC: Name: .init
14 # NOGC: Name: .init_x
15 # NOGC: Name: .fini
16 # NOGC: Name: .tdata
17 # NOGC: Name: .tbss
18 # NOGC: Name: .ctors
19 # NOGC: Name: .dtors
20 # NOGC: Name: .fini_array
21 # NOGC: Name: .init_array
22 # NOGC: Name: .preinit_array
23 # NOGC: Name: .jcr
24 # NOGC: Name: .jcr_x
25 # NOGC: Name: .debug_pubtypes
26 # NOGC: Name: .comment
27 # NOGC: Name: a
28 # NOGC: Name: b
29 # NOGC: Name: c
30 # NOGC: Name: e
31 # NOGC: Name: f
32 # NOGC: Name: g
33 # NOGC: Name: h
34 # NOGC: Name: x
35 # NOGC: Name: y
36 # NOGC: Name: d
38 # GC1-DISCARD: removing unused section {{.*}}:(.text.d)
39 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.text.x)
40 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.text.y)
41 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.tbss.f)
42 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.tdata.h)
43 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.init_x)
44 # GC1-DISCARD-NEXT: removing unused section {{.*}}:(.jcr_x)
45 # GC1-DISCARD-EMPTY:
47 # GC1: Name: .eh_frame
48 # GC1: Name: .text
49 # GC1: Name: .init
50 # GC1: Name: .fini
51 # GC1: Name: .tdata
52 # GC1: Name: .tbss
53 # GC1: Name: .ctors
54 # GC1: Name: .dtors
55 # GC1: Name: .fini_array
56 # GC1: Name: .init_array
57 # GC1: Name: .preinit_array
58 # GC1: Name: .jcr
59 # GC1: Name: .debug_pubtypes
60 # GC1: Name: .comment
61 # GC1: Name: a
62 # GC1: Name: b
63 # GC1: Name: c
64 # GC1: Name: e
65 # GC1-NOT: Name: f
66 # GC1: Name: g
67 # GC1-NOT: Name: h
68 # GC1-NOT: Name: x
69 # GC1-NOT: Name: y
70 # GC1-NOT: Name: d
72 # GC2: Name: .eh_frame
73 # GC2: Name: .text
74 # GC2: Name: .init
75 # GC2: Name: .fini
76 # GC2: Name: .tdata
77 # GC2: Name: .tbss
78 # GC2: Name: .ctors
79 # GC2: Name: .dtors
80 # GC2: Name: .fini_array
81 # GC2: Name: .init_array
82 # GC2: Name: .preinit_array
83 # GC2: Name: .jcr
84 # GC2: Name: .debug_pubtypes
85 # GC2: Name: .comment
86 # GC2: Name: a
87 # GC2: Name: b
88 # GC2: Name: c
89 # GC2: Name: e
90 # GC2-NOT: Name: f
91 # GC2: Name: g
92 # GC2-NOT: Name: h
93 # GC2-NOT: Name: x
94 # GC2-NOT: Name: y
95 # GC2: Name: d
97 .globl _start, d
98 .protected a, b, c, e, f, g, h, x, y
99 _start:
100 call a
102 .section .text.a,"ax",@progbits
104 call _start
105 call b
107 .section .text.b,"ax",@progbits
109 leaq e@tpoff(%rax),%rdx
110 call c
112 .section .text.c,"ax",@progbits
114 leaq g@tpoff(%rax),%rdx
116 .section .text.d,"ax",@progbits
120 .section .text.x,"ax",@progbits
122 call y
124 .section .text.y,"ax",@progbits
126 call x
128 .section .tbss.e,"awT",@nobits
130 .quad 0
132 .section .tbss.f,"awT",@nobits
134 .quad 0
136 .section .tdata.g,"awT",@progbits
138 .quad 0
140 .section .tdata.h,"awT",@progbits
142 .quad 0
144 .section .ctors,"aw",@progbits
145 .quad 0
147 .section .dtors,"aw",@progbits
148 .quad 0
150 .section .init,"ax"
151 .quad 0
153 .section .init_x,"ax"
154 .quad 0
156 .section .fini,"ax"
157 .quad 0
159 .section .fini_array,"aw",@fini_array
160 .quad 0
162 # https://golang.org/cl/373734
163 .section .init_array,"aw",@progbits
164 .quad 0
166 # Work around https://github.com/rust-lang/rust/issues/92181
167 .section .init_array.00001,"aw",@progbits
168 .quad 0
170 .section .preinit_array,"aw",@preinit_array
171 .quad 0
173 .section .jcr,"aw"
174 .quad 0
176 .section .jcr_x,"aw"
177 .quad 0
179 .section .eh_frame,"a",@unwind
180 .quad 0
182 .section .debug_pubtypes,"",@progbits
183 .quad 0
185 .section .comment,"MS",@progbits,8
186 .quad 0