[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / basic-ppc64.s
blob4032ceca614fb5e35b8e3cb0a82f3d8f01429162
1 # REQUIRES: ppc
2 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t.o
3 # RUN: ld.lld --hash-style=sysv -discard-all -shared %t.o -o %t.so
4 # RUN: llvm-readobj --file-headers --sections --section-data -l %t.so | FileCheck --check-prefixes=CHECK,LE %s
6 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t.o
7 # RUN: ld.lld --hash-style=sysv -discard-all -shared %t.o -o %t.so
8 # RUN: llvm-readobj --file-headers --sections --section-data -l %t.so | FileCheck --check-prefixes=CHECK,BE %s
10 .abiversion 2
11 # Exits with return code 55 on linux.
12 .text
13 li 0,1
14 li 3,55
17 // CHECK: Format: elf64-powerpc
18 // LE-NEXT: Arch: powerpc64le
19 // BE-NEXT: Arch: powerpc64{{$}}
20 // CHECK-NEXT: AddressSize: 64bit
21 // CHECK-NEXT: LoadName:
22 // CHECK-NEXT: ElfHeader {
23 // CHECK-NEXT: Ident {
24 // CHECK-NEXT: Magic: (7F 45 4C 46)
25 // CHECK-NEXT: Class: 64-bit (0x2)
26 // LE-NEXT: DataEncoding: LittleEndian (0x1)
27 // BE-NEXT: DataEncoding: BigEndian (0x2)
28 // CHECK-NEXT: FileVersion: 1
29 // CHECK-NEXT: OS/ABI: SystemV (0x0)
30 // CHECK-NEXT: ABIVersion: 0
31 // CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
32 // CHECK-NEXT: }
33 // CHECK-NEXT: Type: SharedObject (0x3)
34 // CHECK-NEXT: Machine: EM_PPC64 (0x15)
35 // CHECK-NEXT: Version: 1
36 // CHECK-NEXT: Entry: 0x0
37 // CHECK-NEXT: ProgramHeaderOffset: 0x40
38 // CHECK-NEXT: SectionHeaderOffset: 0x330
39 // CHECK-NEXT: Flags [ (0x2)
40 // CHECK-NEXT: 0x2
41 // CHECK-NEXT: ]
42 // CHECK-NEXT: HeaderSize: 64
43 // CHECK-NEXT: ProgramHeaderEntrySize: 56
44 // CHECK-NEXT: ProgramHeaderCount: 7
45 // CHECK-NEXT: SectionHeaderEntrySize: 64
46 // CHECK-NEXT: SectionHeaderCount: 11
47 // CHECK-NEXT: StringTableSectionIndex: 9
48 // CHECK-NEXT:}
49 // CHECK-NEXT:Sections [
50 // CHECK-NEXT: Section {
51 // CHECK-NEXT: Index: 0
52 // CHECK-NEXT: Name: (0)
53 // CHECK-NEXT: Type: SHT_NULL (0x0)
54 // CHECK-NEXT: Flags [ (0x0)
55 // CHECK-NEXT: ]
56 // CHECK-NEXT: Address: 0x0
57 // CHECK-NEXT: Offset: 0x0
58 // CHECK-NEXT: Size: 0
59 // CHECK-NEXT: Link: 0
60 // CHECK-NEXT: Info: 0
61 // CHECK-NEXT: AddressAlignment: 0
62 // CHECK-NEXT: EntrySize: 0
63 // CHECK-NEXT: SectionData (
64 // CHECK-NEXT: )
65 // CHECK-NEXT: }
66 // CHECK-NEXT: Section {
67 // CHECK-NEXT: Index: 1
68 // CHECK-NEXT: Name: .dynsym (1)
69 // CHECK-NEXT: Type: SHT_DYNSYM (0xB)
70 // CHECK-NEXT: Flags [ (0x2)
71 // CHECK-NEXT: SHF_ALLOC (0x2)
72 // CHECK-NEXT: ]
73 // CHECK-NEXT: Address: 0x200
74 // CHECK-NEXT: Offset: 0x200
75 // CHECK-NEXT: Size: 24
76 // CHECK-NEXT: Link: 3
77 // CHECK-NEXT: Info: 1
78 // CHECK-NEXT: AddressAlignment: 8
79 // CHECK-NEXT: EntrySize: 24
80 // CHECK-NEXT: SectionData (
81 // CHECK-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
82 // CHECK-NEXT: 0010: 00000000 00000000 |........|
83 // CHECK-NEXT: )
84 // CHECK-NEXT: }
85 // CHECK-NEXT: Section {
86 // CHECK-NEXT: Index: 2
87 // CHECK-NEXT: Name: .hash (9)
88 // CHECK-NEXT: Type: SHT_HASH (0x5)
89 // CHECK-NEXT: Flags [ (0x2)
90 // CHECK-NEXT: SHF_ALLOC (0x2)
91 // CHECK-NEXT: ]
92 // CHECK-NEXT: Address: 0x218
93 // CHECK-NEXT: Offset: 0x218
94 // CHECK-NEXT: Size: 16
95 // CHECK-NEXT: Link: 1
96 // CHECK-NEXT: Info: 0
97 // CHECK-NEXT: AddressAlignment: 4
98 // CHECK-NEXT: EntrySize: 4
99 // CHECK-NEXT: SectionData (
100 // LE-NEXT: 0000: 01000000 01000000 00000000 00000000
101 // BE-NEXT: 0000: 00000001 00000001 00000000 00000000
102 // CHECK-NEXT: )
103 // CHECK-NEXT: }
104 // CHECK-NEXT: Section {
105 // CHECK-NEXT: Index: 3
106 // CHECK-NEXT: Name: .dynstr (15)
107 // CHECK-NEXT: Type: SHT_STRTAB (0x3)
108 // CHECK-NEXT: Flags [ (0x2)
109 // CHECK-NEXT: SHF_ALLOC (0x2)
110 // CHECK-NEXT: ]
111 // CHECK-NEXT: Address: 0x228
112 // CHECK-NEXT: Offset: 0x228
113 // CHECK-NEXT: Size: 1
114 // CHECK-NEXT: Link: 0
115 // CHECK-NEXT: Info: 0
116 // CHECK-NEXT: AddressAlignment: 1
117 // CHECK-NEXT: EntrySize: 0
118 // CHECK-NEXT: SectionData (
119 // CHECK-NEXT: 0000: 00 |.|
120 // CHECK-NEXT: )
121 // CHECK-NEXT: }
122 // CHECK-NEXT: Section {
123 // CHECK-NEXT: Index: 4
124 // CHECK-NEXT: Name: .text (23)
125 // CHECK-NEXT: Type: SHT_PROGBITS (0x1)
126 // CHECK-NEXT: Flags [ (0x6)
127 // CHECK-NEXT: SHF_ALLOC (0x2)
128 // CHECK-NEXT: SHF_EXECINSTR (0x4)
129 // CHECK-NEXT: ]
130 // CHECK-NEXT: Address: 0x1022C
131 // CHECK-NEXT: Offset: 0x22C
132 // CHECK-NEXT: Size: 12
133 // CHECK-NEXT: Link: 0
134 // CHECK-NEXT: Info: 0
135 // CHECK-NEXT: AddressAlignment: 4
136 // CHECK-NEXT: EntrySize: 0
137 // CHECK-NEXT: SectionData (
138 // LE-NEXT: 0000: 01000038 37006038 02000044
139 // BE-NEXT: 0000: 38000001 38600037 44000002
140 // CHECK-NEXT: )
141 // CHECK-NEXT: }
142 // CHECK-NEXT: Section {
143 // CHECK-NEXT: Index: 5
144 // CHECK-NEXT: Name: .dynamic (29)
145 // CHECK-NEXT: Type: SHT_DYNAMIC (0x6)
146 // CHECK-NEXT: Flags [ (0x3)
147 // CHECK-NEXT: SHF_ALLOC (0x2)
148 // CHECK-NEXT: SHF_WRITE (0x1)
149 // CHECK-NEXT: ]
150 // CHECK-NEXT: Address: 0x20238
151 // CHECK-NEXT: Offset: 0x238
152 // CHECK-NEXT: Size: 96
153 // CHECK-NEXT: Link: 3
154 // CHECK-NEXT: Info: 0
155 // CHECK-NEXT: AddressAlignment: 8
156 // CHECK-NEXT: EntrySize: 16
157 // CHECK-NEXT: SectionData (
158 // LE-NEXT: 0000: 06000000 00000000 00020000 00000000 |
159 // LE-NEXT: 0010: 0B000000 00000000 18000000 00000000 |
160 // LE-NEXT: 0020: 05000000 00000000 28020000 00000000 |
161 // LE-NEXT: 0030: 0A000000 00000000 01000000 00000000 |
162 // LE-NEXT: 0040: 04000000 00000000 18020000 00000000 |
163 // LE-NEXT: 0050: 00000000 00000000 00000000 00000000 |
164 // BE-NEXT: 0000: 00000000 00000006 00000000 00000200 |
165 // BE-NEXT: 0010: 00000000 0000000B 00000000 00000018 |
166 // BE-NEXT: 0020: 00000000 00000005 00000000 00000228 |
167 // BE-NEXT: 0030: 00000000 0000000A 00000000 00000001 |
168 // BE-NEXT: 0040: 00000000 00000004 00000000 00000218 |
169 // BE-NEXT: 0050: 00000000 00000000 00000000 00000000 |
170 // CHECK-NEXT: )
171 // CHECK-NEXT: }
172 // CHECK-NEXT: Section {
173 // CHECK-NEXT: Index: 6
174 // CHECK-NEXT: Name: .branch_lt (38)
175 // CHECK-NEXT: Type: SHT_NOBITS (0x8)
176 // CHECK-NEXT: Flags [ (0x3)
177 // CHECK-NEXT: SHF_ALLOC (0x2)
178 // CHECK-NEXT: SHF_WRITE (0x1)
179 // CHECK-NEXT: ]
180 // CHECK-NEXT: Address: 0x30298
181 // CHECK-NEXT: Offset: 0x298
182 // CHECK-NEXT: Size: 0
183 // CHECK-NEXT: Link: 0
184 // CHECK-NEXT: Info: 0
185 // CHECK-NEXT: AddressAlignment: 8
186 // CHECK-NEXT: EntrySize: 0
187 // CHECK-NEXT: }
188 // CHECK-NEXT: Section {
189 // CHECK-NEXT: Index: 7
190 // CHECK-NEXT: Name: .comment (49)
191 // CHECK-NEXT: Type: SHT_PROGBITS (0x1)
192 // CHECK-NEXT: Flags [ (0x30)
193 // CHECK-NEXT: SHF_MERGE (0x10)
194 // CHECK-NEXT: SHF_STRINGS (0x20)
195 // CHECK-NEXT: ]
196 // CHECK-NEXT: Address: 0x0
197 // CHECK-NEXT: Offset: 0x298
198 // CHECK-NEXT: Size: 8
199 // CHECK-NEXT: Link: 0
200 // CHECK-NEXT: Info: 0
201 // CHECK-NEXT: AddressAlignment: 1
202 // CHECK-NEXT: EntrySize: 1
203 // CHECK-NEXT: SectionData (
204 // CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.|
205 // CHECK-NEXT: )
206 // CHECK-NEXT: }
207 // CHECK-NEXT: Section {
208 // CHECK-NEXT: Index: 8
209 // CHECK-NEXT: Name: .symtab (58)
210 // CHECK-NEXT: Type: SHT_SYMTAB (0x2)
211 // CHECK-NEXT: Flags [ (0x0)
212 // CHECK-NEXT: ]
213 // CHECK-NEXT: Address: 0x0
214 // CHECK-NEXT: Offset: 0x2A0
215 // CHECK-NEXT: Size: 48
216 // CHECK-NEXT: Link: 10
217 // CHECK-NEXT: Info: 2
218 // CHECK-NEXT: AddressAlignment: 8
219 // CHECK-NEXT: EntrySize: 24
220 // CHECK-NEXT: SectionData (
221 // LE-NEXT: 0000: 00000000 00000000 00000000 00000000
222 // LE-NEXT: 0010: 00000000 00000000 01000000 00020500
223 // LE-NEXT: 0020: 38020200 00000000 00000000 00000000
224 // BE-NEXT: 0000: 00000000 00000000 00000000 00000000
225 // BE-NEXT: 0010: 00000000 00000000 00000001 00020005
226 // BE-NEXT: 0020: 00000000 00020238 00000000 00000000
227 // CHECK-NEXT: )
228 // CHECK-NEXT: }
229 // CHECK-NEXT: Section {
230 // CHECK-NEXT: Index: 9
231 // CHECK-NEXT: Name: .shstrtab (66)
232 // CHECK-NEXT: Type: SHT_STRTAB (0x3)
233 // CHECK-NEXT: Flags [ (0x0)
234 // CHECK-NEXT: ]
235 // CHECK-NEXT: Address: 0x0
236 // CHECK-NEXT: Offset: 0x2D0
237 // CHECK-NEXT: Size: 84
238 // CHECK-NEXT: Link: 0
239 // CHECK-NEXT: Info: 0
240 // CHECK-NEXT: AddressAlignment: 1
241 // CHECK-NEXT: EntrySize: 0
242 // CHECK-NEXT: SectionData (
243 // CHECK-NEXT: 0000: 002E6479 6E73796D 002E6861 7368002E |..dynsym..hash..|
244 // CHECK-NEXT: 0010: 64796E73 7472002E 74657874 002E6479 |dynstr..text..dy|
245 // CHECK-NEXT: 0020: 6E616D69 63002E62 72616E63 685F6C74 |namic..branch_lt|
246 // CHECK-NEXT: 0030: 002E636F 6D6D656E 74002E73 796D7461 |..comment..symta|
247 // CHECK-NEXT: 0040: 62002E73 68737472 74616200 2E737472 |b..shstrtab..str|
248 // CHECK-NEXT: 0050: 74616200 |tab.|
249 // CHECK-NEXT: )
250 // CHECK-NEXT: }
251 // CHECK-NEXT: Section {
252 // CHECK-NEXT: Index: 10
253 // CHECK-NEXT: Name: .strtab (76)
254 // CHECK-NEXT: Type: SHT_STRTAB (0x3)
255 // CHECK-NEXT: Flags [ (0x0)
256 // CHECK-NEXT: ]
257 // CHECK-NEXT: Address: 0x0
258 // CHECK-NEXT: Offset: 0x324
259 // CHECK-NEXT: Size: 10
260 // CHECK-NEXT: Link: 0
261 // CHECK-NEXT: Info: 0
262 // CHECK-NEXT: AddressAlignment: 1
263 // CHECK-NEXT: EntrySize: 0
264 // CHECK-NEXT: SectionData (
265 // CHECK-NEXT: 0000: 005F4459 4E414D49 4300 |._DYNAMIC.|
266 // CHECK-NEXT: )
267 // CHECK-NEXT: }
268 // CHECK-NEXT:]
269 // CHECK-NEXT:ProgramHeaders [
270 // CHECK-NEXT: ProgramHeader {
271 // CHECK-NEXT: Type: PT_PHDR (0x6)
272 // CHECK-NEXT: Offset: 0x40
273 // CHECK-NEXT: VirtualAddress: 0x40
274 // CHECK-NEXT: PhysicalAddress: 0x40
275 // CHECK-NEXT: FileSize: 448
276 // CHECK-NEXT: MemSize: 448
277 // CHECK-NEXT: Flags [ (0x4)
278 // CHECK-NEXT: PF_R (0x4)
279 // CHECK-NEXT: ]
280 // CHECK-NEXT: Alignment: 8
281 // CHECK-NEXT: }
282 // CHECK-NEXT: ProgramHeader {
283 // CHECK-NEXT: Type: PT_LOAD (0x1)
284 // CHECK-NEXT: Offset: 0x0
285 // CHECK-NEXT: VirtualAddress: 0x0
286 // CHECK-NEXT: PhysicalAddress: 0x0
287 // CHECK-NEXT: FileSize: 553
288 // CHECK-NEXT: MemSize: 553
289 // CHECK-NEXT: Flags [ (0x4)
290 // CHECK-NEXT: PF_R (0x4)
291 // CHECK-NEXT: ]
292 // CHECK-NEXT: Alignment: 65536
293 // CHECK-NEXT: }
294 // CHECK-NEXT: ProgramHeader {
295 // CHECK-NEXT: Type: PT_LOAD (0x1)
296 // CHECK-NEXT: Offset: 0x22C
297 // CHECK-NEXT: VirtualAddress: 0x1022C
298 // CHECK-NEXT: PhysicalAddress: 0x1022C
299 // CHECK-NEXT: FileSize: 12
300 // CHECK-NEXT: MemSize: 12
301 // CHECK-NEXT: Flags [ (0x5)
302 // CHECK-NEXT: PF_R (0x4)
303 // CHECK-NEXT: PF_X (0x1)
304 // CHECK-NEXT: ]
305 // CHECK-NEXT: Alignment: 65536
306 // CHECK-NEXT: }
307 // CHECK-NEXT: ProgramHeader {
308 // CHECK-NEXT: Type: PT_LOAD (0x1)
309 // CHECK-NEXT: Offset: 0x238
310 // CHECK-NEXT: VirtualAddress: 0x20238
311 // CHECK-NEXT: PhysicalAddress: 0x20238
312 // CHECK-NEXT: FileSize: 96
313 // CHECK-NEXT: MemSize: 96
314 // CHECK-NEXT: Flags [ (0x6)
315 // CHECK-NEXT: PF_R (0x4)
316 // CHECK-NEXT: PF_W (0x2)
317 // CHECK-NEXT: ]
318 // CHECK-NEXT: Alignment: 65536
319 // CHECK-NEXT: }
320 // CHECK-NEXT: ProgramHeader {
321 // CHECK-NEXT: Type: PT_DYNAMIC (0x2)
322 // CHECK-NEXT: Offset: 0x238
323 // CHECK-NEXT: VirtualAddress: 0x20238
324 // CHECK-NEXT: PhysicalAddress: 0x20238
325 // CHECK-NEXT: FileSize: 96
326 // CHECK-NEXT: MemSize: 96
327 // CHECK-NEXT: Flags [ (0x6)
328 // CHECK-NEXT: PF_R (0x4)
329 // CHECK-NEXT: PF_W (0x2)
330 // CHECK-NEXT: ]
331 // CHECK-NEXT: Alignment: 8
332 // CHECK-NEXT: }
333 // CHECK-NEXT: ProgramHeader {
334 // CHECK-NEXT: Type: PT_GNU_RELRO (0x6474E552)
335 // CHECK-NEXT: Offset: 0x238
336 // CHECK-NEXT: VirtualAddress: 0x20238
337 // CHECK-NEXT: PhysicalAddress: 0x20238
338 // CHECK-NEXT: FileSize: 96
339 // CHECK-NEXT: MemSize: 3528
340 // CHECK-NEXT: Flags [ (0x4)
341 // CHECK-NEXT: PF_R (0x4)
342 // CHECK-NEXT: ]
343 // CHECK-NEXT: Alignment: 1
344 // CHECK-NEXT: }
345 // CHECK-NEXT: ProgramHeader {
346 // CHECK-NEXT: Type: PT_GNU_STACK (0x6474E551)
347 // CHECK-NEXT: Offset: 0x0
348 // CHECK-NEXT: VirtualAddress: 0x0
349 // CHECK-NEXT: PhysicalAddress: 0x0
350 // CHECK-NEXT: FileSize: 0
351 // CHECK-NEXT: MemSize: 0
352 // CHECK-NEXT: Flags [ (0x6)
353 // CHECK-NEXT: PF_R (0x4)
354 // CHECK-NEXT: PF_W (0x2)
355 // CHECK-NEXT: ]
356 // CHECK-NEXT: Alignment: 0
357 // CHECK-NEXT: }
358 // CHECK-NEXT:]