1 # Test reading ARM64X dynamic relocations.
3 # RUN: yaml2obj %s -o %t.dll
4 # RUN: llvm-readobj --coff-load-config %t.dll | FileCheck --check-prefixes=CHECK,V1 %s
6 # CHECK: CHPEMetadataPointer: 0x180005000
7 # CHECK: CHPEMetadata [
8 # CHECK-NEXT: Version: 0x1
9 # CHECK-NEXT: CodeMap [
10 # CHECK-NEXT: 0x1000 - 0x1030 ARM64EC
11 # CHECK-NEXT: 0x2000 - 0x2040 ARM64
12 # CHECK-NEXT: 0x3000 - 0x3050 X64
14 # CHECK-NEXT: CodeRangesToEntryPoints [
15 # CHECK-NEXT: 0x1000 - 0x1020 -> 0x1000
16 # CHECK-NEXT: 0x1020 - 0x1040 -> 0x2000
18 # CHECK-NEXT: RedirectionMetadata [
19 # CHECK-NEXT: 0x1000 -> 0x2000
20 # CHECK-NEXT: 0x1020 -> 0x2030
23 # CHECK: DynamicRelocations [
28 # CHECK-NEXT: RVA: 0x84
29 # CHECK-NEXT: Type: VALUE
30 # CHECK-NEXT: Size: 0x2
31 # CHECK-NEXT: Value: 0x8664
34 # CHECK-NEXT: RVA: 0x6020
35 # CHECK-NEXT: Type: VALUE
36 # CHECK-NEXT: Size: 0x2
37 # CHECK-NEXT: Value: 0x3412
40 # CHECK-NEXT: RVA: 0x6024
41 # CHECK-NEXT: Type: VALUE
42 # CHECK-NEXT: Size: 0x4
43 # CHECK-NEXT: Value: 0x89674523
46 # CHECK-NEXT: RVA: 0x6028
47 # CHECK-NEXT: Type: VALUE
48 # CHECK-NEXT: Size: 0x8
49 # CHECK-NEXT: Value: 0x8877665544332211
52 # CHECK-NEXT: RVA: 0x6000
53 # CHECK-NEXT: Type: ZERO
54 # CHECK-NEXT: Size: 0x2
57 # CHECK-NEXT: RVA: 0x6004
58 # CHECK-NEXT: Type: ZERO
59 # CHECK-NEXT: Size: 0x4
62 # CHECK-NEXT: RVA: 0x6010
63 # CHECK-NEXT: Type: ZERO
64 # CHECK-NEXT: Size: 0x8
67 # CHECK-NEXT: RVA: 0x6040
68 # CHECK-NEXT: Type: DELTA
69 # CHECK-NEXT: Value: 68740
72 # CHECK-NEXT: RVA: 0x6044
73 # CHECK-NEXT: Type: DELTA
74 # CHECK-NEXT: Value: 137480
77 # CHECK-NEXT: RVA: 0x6048
78 # CHECK-NEXT: Type: DELTA
79 # CHECK-NEXT: Value: -16
82 # CHECK-NEXT: RVA: 0x604C
83 # CHECK-NEXT: Type: DELTA
84 # CHECK-NEXT: Value: -32
89 # RUN: llvm-readobj --hex-dump=.test %t.dll | FileCheck --match-full-lines --strict-whitespace --check-prefix=HEX %s
90 # HEX:Format: COFF-ARM64X
91 # HEX-NEXT:Arch: aarch64
92 # HEX-NEXT:AddressSize: 64bit
94 # HEX-NEXT:Hex dump of section '.test':
95 # HEX-NEXT:0x180006000 11112222 33334444 55556666 77778888 ..""33DDUUffww..
96 # HEX-NEXT:0x180006010 9999aaaa bbbbcccc ddddeeee ffff0000 ................
97 # HEX-NEXT:0x180006020 00000000 00000000 00000000 00000000 ................
98 # HEX-NEXT:0x180006030 00000000 00000000 00000000 00000000 ................
99 # HEX-NEXT:0x180006040 10101010 20202020 30303030 40404040 .... 0000@@@@
100 # HEX-NEXT:0x180006050 50505050 60606060 70707070 80808080 PPPP````pppp....
101 # HEX-NEXT:HybridObject {
102 # HEX-NEXT: Format: COFF-ARM64EC
103 # HEX-NEXT: Arch: aarch64
104 # HEX-NEXT: AddressSize: 64bit
106 # HEX-NEXT: Hex dump of section '.test':
107 # HEX-NEXT: 0x180006000 00002222 00000000 55556666 77778888 ..""....UUffww..
108 # HEX-NEXT: 0x180006010 00000000 00000000 ddddeeee ffff0000 ................
109 # HEX-NEXT: 0x180006020 12340000 23456789 11223344 55667788 .4..#Eg.."3DUfw.
110 # HEX-NEXT: 0x180006030 00000000 00000000 00000000 00000000 ................
111 # HEX-NEXT: 0x180006040 941c1110 28392220 20303030 20404040 ....(9" 000 @@@
112 # HEX-NEXT: 0x180006050 50505050 60606060 70707070 80808080 PPPP````pppp....
118 ImageBase: 0x180000000
119 SectionAlignment: 4096
121 DLLCharacteristics: [ ]
123 RelativeVirtualAddress: 0x4000
126 Machine: IMAGE_FILE_MACHINE_ARM64
127 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]
130 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
131 VirtualAddress: 0x1000
134 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
135 VirtualAddress: 0x4000
139 CHPEMetadataPointer: 0x180005000
140 DynamicValueRelocTableOffset: 4
141 DynamicValueRelocTableSection: 5
143 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
144 VirtualAddress: 0x5000
147 - UInt32: 1 # Version
148 - UInt32: 0x5050 # CodeMap
149 - UInt32: 3 # CodeMapCount
150 - UInt32: 0x5068 # CodeRangesToEntryPoints
151 - UInt32: 0x5080 # RedirectionMetadata
159 - UInt32: 2 # CodeRangesToEntryPointsCount
160 - UInt32: 2 # RedirectionMetadataCount
167 - UInt32: 0x1001 # CodeMap[0]
169 - UInt32: 0x2000 # CodeMap[1]
171 - UInt32: 0x3002 # CodeMap[2]
173 - UInt32: 0x1000 # CodeRangesToEntryPoints[0]
176 - UInt32: 0x1020 # CodeRangesToEntryPoints[1]
179 - UInt32: 0x1000 # RedirectionMetadata[0]
181 - UInt32: 0x1020 # RedirectionMetadata[1]
184 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
185 VirtualAddress: 0x6000
188 - Binary: 111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000
189 - Binary: 0000000000000000000000000000000000000000000000000000000000000000
190 - Binary: 1010101020202020303030304040404050505050606060607070707080808080
192 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_DISCARDABLE ]
193 VirtualAddress: 0x7000
197 - UInt32: 1 # coff_dynamic_reloc_table.Version
198 - UInt32: 76 # coff_dynamic_reloc_table.Size
199 - UInt32: 6 # coff_dynamic_relocation64.Symbol(low) = IMAGE_DYNAMIC_RELOCATION_ARM64X
200 - UInt32: 0 # coff_dynamic_relocation64.Symbol(high)
201 - UInt32: 64 # coff_dynamic_relocation64.BaseRelocSize
202 - UInt32: 0 # coff_base_reloc_block_header[0].PageRVA
203 - UInt32: 12 # coff_base_reloc_block_header[0].BlockSize
204 - Binary: 8450 # VALUE offset 0x84 (PE header Machine), size 2
205 - Binary: 6486 # IMAGE_FILE_MACHINE_AMD64
206 - UInt32: 0x6000 # coff_base_reloc_block_header[1].PageRVA
207 - UInt32: 52 # coff_base_reloc_block_header[1].BlockSize
208 - Binary: 2050 # VALUE offset 0x20, size 2
209 - Binary: 1234 # test value
210 - Binary: 2490 # VALUE offset 0x24, size 4
211 - Binary: 23456789 # test value
212 - Binary: 28d0 # VALUE offset 0x28, size 4
213 - Binary: 11223344 # test value
214 - Binary: 55667788 # test value
215 - Binary: 0040 # ZERO offset 0, size 2
216 - Binary: 0480 # ZERO offset 4, size 4
217 - Binary: 10c0 # ZERO offset 16, size 8
218 - Binary: 4020 # DELTA offset 0x40, mul 4
220 - Binary: 44a0 # DELTA offset 0x44, mul 8
222 - Binary: 4860 # DELTA offset 0x48, mul 4
224 - Binary: 4ce0 # DELTA offset 0x4c, mul 8
226 - Binary: 0000 # terminator
230 # RUN: yaml2obj %s --docnum=2 -o %t2.dll
231 # RUN: llvm-readobj --coff-load-config %t2.dll | FileCheck --check-prefixes=CHECK,V2 %s
232 # RUN: llvm-readobj --hex-dump=.test %t2.dll | FileCheck --match-full-lines --strict-whitespace --check-prefix=HEX %s
236 ImageBase: 0x180000000
237 SectionAlignment: 4096
239 DLLCharacteristics: [ ]
241 RelativeVirtualAddress: 0x4000
244 Machine: IMAGE_FILE_MACHINE_ARM64
245 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]
248 Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
249 VirtualAddress: 0x1000
252 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
253 VirtualAddress: 0x4000
257 CHPEMetadataPointer: 0x180005000
258 DynamicValueRelocTableOffset: 4
259 DynamicValueRelocTableSection: 5
261 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
262 VirtualAddress: 0x5000
265 - UInt32: 1 # Version
266 - UInt32: 0x5050 # CodeMap
267 - UInt32: 3 # CodeMapCount
268 - UInt32: 0x5068 # CodeRangesToEntryPoints
269 - UInt32: 0x5080 # RedirectionMetadata
277 - UInt32: 2 # CodeRangesToEntryPointsCount
278 - UInt32: 2 # RedirectionMetadataCount
285 - UInt32: 0x1001 # CodeMap[0]
287 - UInt32: 0x2000 # CodeMap[1]
289 - UInt32: 0x3002 # CodeMap[2]
291 - UInt32: 0x1000 # CodeRangesToEntryPoints[0]
294 - UInt32: 0x1020 # CodeRangesToEntryPoints[1]
297 - UInt32: 0x1000 # RedirectionMetadata[0]
299 - UInt32: 0x1020 # RedirectionMetadata[1]
302 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
303 VirtualAddress: 0x6000
306 - Binary: 111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000
307 - Binary: 0000000000000000000000000000000000000000000000000000000000000000
308 - Binary: 1010101020202020303030304040404050505050606060607070707080808080
310 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_DISCARDABLE ]
311 VirtualAddress: 0x7000
315 - UInt32: 2 # coff_dynamic_reloc_table.Version
316 - UInt32: 88 # coff_dynamic_reloc_table.Size
317 - UInt32: 24 # coff_dynamic_relocation64_v2.HeaderSize
318 - UInt32: 64 # coff_dynamic_relocation64_v2.FixupInfoSize
319 - UInt32: 6 # coff_dynamic_relocation64_v2.Symbol(low) = IMAGE_DYNAMIC_RELOCATION_ARM64X
320 - UInt32: 0 # coff_dynamic_relocation64_v2.Symbol(high)
321 - UInt32: 0 # coff_dynamic_relocation64_v2.SymbolGroup
322 - UInt32: 0 # coff_dynamic_relocation64_v2.Flags
323 - UInt32: 0 # coff_base_reloc_block_header[0].PageRVA
324 - UInt32: 12 # coff_base_reloc_block_header[0].BlockSize
325 - Binary: 8450 # VALUE offset 0x84 (PE header Machine), size 2
326 - Binary: 6486 # IMAGE_FILE_MACHINE_AMD64
327 - UInt32: 0x6000 # coff_base_reloc_block_header[1].PageRVA
328 - UInt32: 52 # coff_base_reloc_block_header[1].BlockSize
329 - Binary: 2050 # VALUE offset 0x20, size 2
330 - Binary: 1234 # test value
331 - Binary: 2490 # VALUE offset 0x24, size 4
332 - Binary: 23456789 # test value
333 - Binary: 28d0 # VALUE offset 0x28, size 4
334 - Binary: 11223344 # test value
335 - Binary: 55667788 # test value
336 - Binary: 0040 # ZERO offset 0, size 2
337 - Binary: 0480 # ZERO offset 4, size 4
338 - Binary: 10c0 # ZERO offset 16, size 8
339 - Binary: 4020 # DELTA offset 0x40, mul 4
341 - Binary: 44a0 # DELTA offset 0x44, mul 8
343 - Binary: 4860 # DELTA offset 0x48, mul 4
345 - Binary: 4ce0 # DELTA offset 0x4c, mul 8
347 - Binary: 0000 # terminator
351 # RUN: yaml2obj %s --docnum=3 -o %t3.dll
352 # RUN: llvm-readobj --coff-exports %t3.dll | FileCheck --match-full-lines --strict-whitespace --check-prefix=EXP %s
354 # EXP:Format: COFF-ARM64X
355 # EXP-NEXT:Arch: aarch64
356 # EXP-NEXT:AddressSize: 64bit
358 # EXP-NEXT: Ordinal: 1
359 # EXP-NEXT: Name: test
360 # EXP-NEXT: RVA: 0x2000
362 # EXP-NEXT:HybridObject {
363 # EXP-NEXT: Format: COFF-ARM64EC
364 # EXP-NEXT: Arch: aarch64
365 # EXP-NEXT: AddressSize: 64bit
367 # EXP-NEXT: Ordinal: 1
368 # EXP-NEXT: Name: test
369 # EXP-NEXT: RVA: 0x2004
375 ImageBase: 0x180000000
376 SectionAlignment: 4096
378 DLLCharacteristics: [ ]
379 AddressOfEntryPoint: 0
381 RelativeVirtualAddress: 0x1000
384 RelativeVirtualAddress: 0x3000
387 Machine: IMAGE_FILE_MACHINE_ARM64
388 Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_LARGE_ADDRESS_AWARE, IMAGE_FILE_DLL ]
391 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
392 VirtualAddress: 0x1000
395 - UInt32: 0 # ExportFlags
396 - UInt32: 0 # TimeDateStamp
397 - UInt32: 0 # Version
398 - UInt32: 0x1028 # NameRVA
399 - UInt32: 1 # OrdinalBase
400 - UInt32: 1 # AddressTableEntries
401 - UInt32: 1 # NumberOfNamePointers
402 - UInt32: 0x1030 # ExportAddressTableRVA
403 - UInt32: 0x1034 # NamePointerRVA
404 - UInt32: 0x1038 # OrdinalTableRVA
405 - Binary: 7473742E646C6C00 # "tst.dll"
406 - UInt32: 0x2000 # export RVA
407 - UInt32: 0x103A # name RVA
408 - Binary: 0000 # ordinal
409 - Binary: 7465737400 # "test"
411 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
412 VirtualAddress: 0x2000
415 - UInt32: 1 # Version
416 - UInt32: 0 # CodeMap
417 - UInt32: 0 # CodeMapCount
418 - UInt32: 0 # CodeRangesToEntryPoints
419 - UInt32: 0 # RedirectionMetadata
427 - UInt32: 0 # CodeRangesToEntryPointsCount
428 - UInt32: 0 # RedirectionMetadataCount
436 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
437 VirtualAddress: 0x3000
441 CHPEMetadataPointer: 0x180002000
442 DynamicValueRelocTableOffset: 0
443 DynamicValueRelocTableSection: 4
445 Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_DISCARDABLE ]
446 VirtualAddress: 0x4000
449 - UInt32: 2 # coff_dynamic_reloc_table.Version
450 - UInt32: 48 # coff_dynamic_reloc_table.Size
451 - UInt32: 24 # coff_dynamic_relocation64_v2.HeaderSize
452 - UInt32: 24 # coff_dynamic_relocation64_v2.FixupInfoSize
453 - UInt32: 6 # coff_dynamic_relocation64_v2.Symbol(low) = IMAGE_DYNAMIC_RELOCATION_ARM64X
454 - UInt32: 0 # coff_dynamic_relocation64_v2.Symbol(high)
455 - UInt32: 0 # coff_dynamic_relocation64_v2.SymbolGroup
456 - UInt32: 0 # coff_dynamic_relocation64_v2.Flags
457 - UInt32: 0 # coff_base_reloc_block_header[0].PageRVA
458 - UInt32: 12 # coff_base_reloc_block_header[0].BlockSize
459 - Binary: 8450 # VALUE offset 0x84 (PE header Machine), size 2
460 - Binary: 6486 # IMAGE_FILE_MACHINE_AMD64
461 - UInt32: 0x1000 # coff_base_reloc_block_header[1].PageRVA
462 - UInt32: 12 # coff_base_reloc_block_header[1].BlockSize
463 - Binary: 3020 # DELTA offset 0x30, mul 4