Recommit "rL366894: [yaml2obj] - Allow custom fields for the SHT_UNDEF sections."
[llvm-complete.git] / test / tools / llvm-readobj / coff-file-headers.test
blob77efe0146beddd4168731a3194c678eeecab56af
1 # RUN: yaml2obj %s --docnum=1 -o %t.arm
2 # RUN: llvm-readobj -h %t.arm \
3 # RUN:  | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.arm --check-prefix ARM
5 #      ARM:File: [[FILE]]
6 # ARM-NEXT:Format: COFF-ARM
7 # ARM-NEXT:Arch: thumb
8 # ARM-NEXT:AddressSize: 32bit
9 # ARM-NEXT:ImageFileHeader {
10 # ARM-NEXT:  Machine: IMAGE_FILE_MACHINE_ARMNT (0x1C4)
11 # ARM-NEXT:  SectionCount: 0
12 # ARM-NEXT:  TimeDateStamp: 1970-01-01 00:00:00 (0x0)
13 # ARM-NEXT:  PointerToSymbolTable: 0x0
14 # ARM-NEXT:  SymbolCount: 0
15 # ARM-NEXT:  OptionalHeaderSize: 0
16 # ARM-NEXT:  Characteristics [ (0x0)
17 # ARM-NEXT:  ]
18 # ARM-NEXT:}
19 # ARM-NOT:{{.}}
21 --- !COFF
22 header:
23   Machine:         IMAGE_FILE_MACHINE_ARMNT
24   Characteristics: [  ]
25 sections:
26 symbols:
28 # RUN: yaml2obj %s --docnum=2 -o %t.arm64
29 # RUN: llvm-readobj -h %t.arm64 \
30 # RUN:  | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.arm64 --check-prefix ARM64
32 #      ARM64:File: [[FILE]]
33 # ARM64-NEXT:Format: COFF-ARM64
34 # ARM64-NEXT:Arch: aarch64
35 # ARM64-NEXT:AddressSize: 64bit
36 # ARM64-NEXT:ImageFileHeader {
37 # ARM64-NEXT:  Machine: IMAGE_FILE_MACHINE_ARM64 (0xAA64)
38 # ARM64-NEXT:  SectionCount: 0
39 # ARM64-NEXT:  TimeDateStamp: 1970-01-01 00:00:00 (0x0)
40 # ARM64-NEXT:  PointerToSymbolTable: 0x0
41 # ARM64-NEXT:  SymbolCount: 0
42 # ARM64-NEXT:  OptionalHeaderSize: 0
43 # ARM64-NEXT:  Characteristics [ (0x0)
44 # ARM64-NEXT:  ]
45 # ARM64-NEXT:}
46 # ARM64-NOT:{{.}}
48 --- !COFF
49 header:
50   Machine:         IMAGE_FILE_MACHINE_ARM64
51   Characteristics: [  ]
52 sections:
53 symbols:
55 # RUN: yaml2obj %s --docnum=3 -o %t.i386
56 # RUN: llvm-readobj -h %t.i386 \
57 # RUN:  | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386
59 #      I386:File: [[FILE]]
60 # I386-NEXT:Format: COFF-i386
61 # I386-NEXT:Arch: i386
62 # I386-NEXT:AddressSize: 32bit
63 # I386-NEXT:ImageFileHeader {
64 # I386-NEXT:  Machine: IMAGE_FILE_MACHINE_I386 (0x14C)
65 # I386-NEXT:  SectionCount: 0
66 # I386-NEXT:  TimeDateStamp: 1970-01-01 00:00:00 (0x0)
67 # I386-NEXT:  PointerToSymbolTable: 0x0
68 # I386-NEXT:  SymbolCount: 0
69 # I386-NEXT:  OptionalHeaderSize: 0
70 # I386-NEXT:  Characteristics [ (0x0)
71 # I386-NEXT:  ]
72 # I386-NEXT:}
73 # I386-NOT:{{.}}
75 --- !COFF
76 header:
77   Machine:         IMAGE_FILE_MACHINE_I386
78   Characteristics: [  ]
79 sections:
80 symbols:
82 # RUN: yaml2obj %s --docnum=4 -o %t.x86-64
83 # RUN: llvm-readobj -h %t.x86-64 \
84 # RUN:  | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.x86-64 --check-prefix X86-64
86 #      X86-64:File: [[FILE]]
87 # X86-64-NEXT:Format: COFF-x86-64
88 # X86-64-NEXT:Arch: x86_64
89 # X86-64-NEXT:AddressSize: 64bit
90 # X86-64-NEXT:ImageFileHeader {
91 # X86-64-NEXT:  Machine: IMAGE_FILE_MACHINE_AMD64 (0x8664)
92 # X86-64-NEXT:  SectionCount: 0
93 # X86-64-NEXT:  TimeDateStamp: 1970-01-01 00:00:00 (0x0)
94 # X86-64-NEXT:  PointerToSymbolTable: 0x0
95 # X86-64-NEXT:  SymbolCount: 0
96 # X86-64-NEXT:  OptionalHeaderSize: 0
97 # X86-64-NEXT:  Characteristics [ (0x0)
98 # X86-64-NEXT:  ]
99 # X86-64-NEXT:}
100 # X86-64-NOT:{{.}}
102 --- !COFF
103 header:
104   Machine:         IMAGE_FILE_MACHINE_AMD64
105   Characteristics: [  ]
106 sections:
107 symbols:
109 # RUN: yaml2obj %s --docnum=5 -o %t.i386
110 # RUN: llvm-readobj -h %t.i386 \
111 # RUN:  | FileCheck %s --strict-whitespace --match-full-lines -DFILE=%t.i386 --check-prefix I386-CUSTOM-HEADER
113 #      I386-CUSTOM-HEADER:File: [[FILE]]
114 # I386-CUSTOM-HEADER-NEXT:Format: COFF-i386
115 # I386-CUSTOM-HEADER-NEXT:Arch: i386
116 # I386-CUSTOM-HEADER-NEXT:AddressSize: 32bit
117 # I386-CUSTOM-HEADER-NEXT:ImageFileHeader {
118 # I386-CUSTOM-HEADER-NEXT:  Machine: IMAGE_FILE_MACHINE_I386 (0x14C)
119 # I386-CUSTOM-HEADER-NEXT:  SectionCount: 0
120 # I386-CUSTOM-HEADER-NEXT:  TimeDateStamp: 1970-01-01 00:00:00 (0x0)
121 # I386-CUSTOM-HEADER-NEXT:  PointerToSymbolTable: 0x0
122 # I386-CUSTOM-HEADER-NEXT:  SymbolCount: 0
123 # I386-CUSTOM-HEADER-NEXT:  OptionalHeaderSize: 224
124 # I386-CUSTOM-HEADER-NEXT:  Characteristics [ (0x102)
125 # I386-CUSTOM-HEADER-NEXT:    IMAGE_FILE_32BIT_MACHINE (0x100)
126 # I386-CUSTOM-HEADER-NEXT:    IMAGE_FILE_EXECUTABLE_IMAGE (0x2)
127 # I386-CUSTOM-HEADER-NEXT:  ]
128 # I386-CUSTOM-HEADER-NEXT:}
129 # I386-CUSTOM-HEADER-NEXT:ImageOptionalHeader {
130 # I386-CUSTOM-HEADER-NEXT:  Magic: 0x10B
131 # I386-CUSTOM-HEADER-NEXT:  MajorLinkerVersion: 0
132 # I386-CUSTOM-HEADER-NEXT:  MinorLinkerVersion: 0
133 # I386-CUSTOM-HEADER-NEXT:  SizeOfCode: 0
134 # I386-CUSTOM-HEADER-NEXT:  SizeOfInitializedData: 0
135 # I386-CUSTOM-HEADER-NEXT:  SizeOfUninitializedData: 0
136 # I386-CUSTOM-HEADER-NEXT:  AddressOfEntryPoint: 0x1000
137 # I386-CUSTOM-HEADER-NEXT:  BaseOfCode: 0x0
138 # I386-CUSTOM-HEADER-NEXT:  BaseOfData: 0x0
139 # I386-CUSTOM-HEADER-NEXT:  ImageBase: 0x400000
140 # I386-CUSTOM-HEADER-NEXT:  SectionAlignment: 4096
141 # I386-CUSTOM-HEADER-NEXT:  FileAlignment: 512
142 # I386-CUSTOM-HEADER-NEXT:  MajorOperatingSystemVersion: 6
143 # I386-CUSTOM-HEADER-NEXT:  MinorOperatingSystemVersion: 0
144 # I386-CUSTOM-HEADER-NEXT:  MajorImageVersion: 0
145 # I386-CUSTOM-HEADER-NEXT:  MinorImageVersion: 0
146 # I386-CUSTOM-HEADER-NEXT:  MajorSubsystemVersion: 6
147 # I386-CUSTOM-HEADER-NEXT:  MinorSubsystemVersion: 0
148 # I386-CUSTOM-HEADER-NEXT:  SizeOfImage: 4096
149 # I386-CUSTOM-HEADER-NEXT:  SizeOfHeaders: 512
150 # I386-CUSTOM-HEADER-NEXT:  Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
151 # I386-CUSTOM-HEADER-NEXT:  Characteristics [ (0x8140)
152 # I386-CUSTOM-HEADER-NEXT:    IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE (0x40)
153 # I386-CUSTOM-HEADER-NEXT:    IMAGE_DLL_CHARACTERISTICS_NX_COMPAT (0x100)
154 # I386-CUSTOM-HEADER-NEXT:    IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE (0x8000)
155 # I386-CUSTOM-HEADER-NEXT:  ]
156 # I386-CUSTOM-HEADER-NEXT:  SizeOfStackReserve: 1048576
157 # I386-CUSTOM-HEADER-NEXT:  SizeOfStackCommit: 4096
158 # I386-CUSTOM-HEADER-NEXT:  SizeOfHeapReserve: 1048576
159 # I386-CUSTOM-HEADER-NEXT:  SizeOfHeapCommit: 4096
160 # I386-CUSTOM-HEADER-NEXT:  NumberOfRvaAndSize: 16
161 # I386-CUSTOM-HEADER-NEXT:  DataDirectory {
162 # I386-CUSTOM-HEADER-NEXT:    ExportTableRVA: 0x0
163 # I386-CUSTOM-HEADER-NEXT:    ExportTableSize: 0x0
164 # I386-CUSTOM-HEADER-NEXT:    ImportTableRVA: 0x0
165 # I386-CUSTOM-HEADER-NEXT:    ImportTableSize: 0x0
166 # I386-CUSTOM-HEADER-NEXT:    ResourceTableRVA: 0x0
167 # I386-CUSTOM-HEADER-NEXT:    ResourceTableSize: 0x0
168 # I386-CUSTOM-HEADER-NEXT:    ExceptionTableRVA: 0x0
169 # I386-CUSTOM-HEADER-NEXT:    ExceptionTableSize: 0x0
170 # I386-CUSTOM-HEADER-NEXT:    CertificateTableRVA: 0x0
171 # I386-CUSTOM-HEADER-NEXT:    CertificateTableSize: 0x0
172 # I386-CUSTOM-HEADER-NEXT:    BaseRelocationTableRVA: 0x0
173 # I386-CUSTOM-HEADER-NEXT:    BaseRelocationTableSize: 0x0
174 # I386-CUSTOM-HEADER-NEXT:    DebugRVA: 0x0
175 # I386-CUSTOM-HEADER-NEXT:    DebugSize: 0x0
176 # I386-CUSTOM-HEADER-NEXT:    ArchitectureRVA: 0x0
177 # I386-CUSTOM-HEADER-NEXT:    ArchitectureSize: 0x0
178 # I386-CUSTOM-HEADER-NEXT:    GlobalPtrRVA: 0x0
179 # I386-CUSTOM-HEADER-NEXT:    GlobalPtrSize: 0x0
180 # I386-CUSTOM-HEADER-NEXT:    TLSTableRVA: 0x0
181 # I386-CUSTOM-HEADER-NEXT:    TLSTableSize: 0x0
182 # I386-CUSTOM-HEADER-NEXT:    LoadConfigTableRVA: 0x0
183 # I386-CUSTOM-HEADER-NEXT:    LoadConfigTableSize: 0x0
184 # I386-CUSTOM-HEADER-NEXT:    BoundImportRVA: 0x0
185 # I386-CUSTOM-HEADER-NEXT:    BoundImportSize: 0x0
186 # I386-CUSTOM-HEADER-NEXT:    IATRVA: 0x0
187 # I386-CUSTOM-HEADER-NEXT:    IATSize: 0x0
188 # I386-CUSTOM-HEADER-NEXT:    DelayImportDescriptorRVA: 0x0
189 # I386-CUSTOM-HEADER-NEXT:    DelayImportDescriptorSize: 0x0
190 # I386-CUSTOM-HEADER-NEXT:    CLRRuntimeHeaderRVA: 0x0
191 # I386-CUSTOM-HEADER-NEXT:    CLRRuntimeHeaderSize: 0x0
192 # I386-CUSTOM-HEADER-NEXT:    ReservedRVA: 0x0
193 # I386-CUSTOM-HEADER-NEXT:    ReservedSize: 0x0
194 # I386-CUSTOM-HEADER-NEXT:  }
195 # I386-CUSTOM-HEADER-NEXT:}
196 # I386-CUSTOM-HEADER-NEXT:DOSHeader {
197 # I386-CUSTOM-HEADER-NEXT:  Magic: MZ
198 # I386-CUSTOM-HEADER-NEXT:  UsedBytesInTheLastPage: 0
199 # I386-CUSTOM-HEADER-NEXT:  FileSizeInPages: 0
200 # I386-CUSTOM-HEADER-NEXT:  NumberOfRelocationItems: 0
201 # I386-CUSTOM-HEADER-NEXT:  HeaderSizeInParagraphs: 0
202 # I386-CUSTOM-HEADER-NEXT:  MinimumExtraParagraphs: 0
203 # I386-CUSTOM-HEADER-NEXT:  MaximumExtraParagraphs: 0
204 # I386-CUSTOM-HEADER-NEXT:  InitialRelativeSS: 0
205 # I386-CUSTOM-HEADER-NEXT:  InitialSP: 0
206 # I386-CUSTOM-HEADER-NEXT:  Checksum: 0
207 # I386-CUSTOM-HEADER-NEXT:  InitialIP: 0
208 # I386-CUSTOM-HEADER-NEXT:  InitialRelativeCS: 0
209 # I386-CUSTOM-HEADER-NEXT:  AddressOfRelocationTable: 64
210 # I386-CUSTOM-HEADER-NEXT:  OverlayNumber: 0
211 # I386-CUSTOM-HEADER-NEXT:  OEMid: 0
212 # I386-CUSTOM-HEADER-NEXT:  OEMinfo: 0
213 # I386-CUSTOM-HEADER-NEXT:  AddressOfNewExeHeader: 128
214 # I386-CUSTOM-HEADER-NEXT:}
215 # I386-CUSTOM-HEADER-NOT:{{.}}
217 --- !COFF
218 OptionalHeader:
219   AddressOfEntryPoint: 4096
220   ImageBase:       4194304
221   SectionAlignment: 4096
222   FileAlignment:   512
223   MajorOperatingSystemVersion: 6
224   MinorOperatingSystemVersion: 0
225   MajorImageVersion: 0
226   MinorImageVersion: 0
227   MajorSubsystemVersion: 6
228   MinorSubsystemVersion: 0
229   Subsystem:       IMAGE_SUBSYSTEM_WINDOWS_CUI
230   DLLCharacteristics: [ IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE, IMAGE_DLL_CHARACTERISTICS_NX_COMPAT, IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE ]
231   SizeOfStackReserve: 1048576
232   SizeOfStackCommit: 4096
233   SizeOfHeapReserve: 1048576
234   SizeOfHeapCommit: 4096
235   ExportTable:
236     RelativeVirtualAddress: 0
237     Size:            0
238   ImportTable:
239     RelativeVirtualAddress: 0
240     Size:            0
241   ResourceTable:
242     RelativeVirtualAddress: 0
243     Size:            0
244   ExceptionTable:
245     RelativeVirtualAddress: 0
246     Size:            0
247   CertificateTable:
248     RelativeVirtualAddress: 0
249     Size:            0
250   BaseRelocationTable:
251     RelativeVirtualAddress: 0
252     Size:            0
253   Debug:
254     RelativeVirtualAddress: 0
255     Size:            0
256   Architecture:
257     RelativeVirtualAddress: 0
258     Size:            0
259   GlobalPtr:
260     RelativeVirtualAddress: 0
261     Size:            0
262   TlsTable:
263     RelativeVirtualAddress: 0
264     Size:            0
265   LoadConfigTable:
266     RelativeVirtualAddress: 0
267     Size:            0
268   BoundImport:
269     RelativeVirtualAddress: 0
270     Size:            0
271   IAT:
272     RelativeVirtualAddress: 0
273     Size:            0
274   DelayImportDescriptor:
275     RelativeVirtualAddress: 0
276     Size:            0
277   ClrRuntimeHeader:
278     RelativeVirtualAddress: 0
279     Size:            0
280 header:
281   Machine:         IMAGE_FILE_MACHINE_I386
282   Characteristics: [ IMAGE_FILE_EXECUTABLE_IMAGE, IMAGE_FILE_32BIT_MACHINE ]
283 sections:
284 symbols:         []
287 # RUN: yaml2obj %s --docnum=6 -o %t.unknown
288 # RUN: llvm-readobj -h %t.unknown \
289 # RUN:  | FileCheck %s --strict-whitespace --match-full-lines --check-prefix UNKNOWN
291 #      UNKNOWN:Format: COFF-<unknown arch>
292 # UNKNOWN-NEXT:Arch: unknown
293 # UNKNOWN-NEXT:AddressSize: 32bit
294 # UNKNOWN-NEXT:ImageFileHeader {
295 # UNKNOWN-NEXT:  Machine: IMAGE_FILE_MACHINE_UNKNOWN (0x0)
296 # UNKNOWN-NEXT:  SectionCount: 0
297 # UNKNOWN-NEXT:  TimeDateStamp: 1970-01-01 00:00:00 (0x0)
298 # UNKNOWN-NEXT:  PointerToSymbolTable: 0x0
299 # UNKNOWN-NEXT:  SymbolCount: 0
300 # UNKNOWN-NEXT:  OptionalHeaderSize: 0
301 # UNKNOWN-NEXT:  Characteristics [ (0x0)
302 # UNKNOWN-NEXT:  ]
303 # UNKNOWN-NEXT:}
304 # UNKNOWN-NOT:{{.}}
306 --- !COFF
307 header:
308   Machine:         IMAGE_FILE_MACHINE_UNKNOWN
309   Characteristics: [  ]
310 sections:
311 symbols:
313 # RUN: llvm-readobj -h %p/Inputs/magic.coff-importlib \
314 # RUN:   | FileCheck %s --strict-whitespace --match-full-lines --check-prefix IMPORTLIB
316 #      IMPORTLIB:Format: COFF-import-file
317 # IMPORTLIB-NEXT:Type: code
318 # IMPORTLIB-NEXT:Name type: noprefix
319 # IMPORTLIB-NEXT:Symbol: __imp__func
320 # IMPORTLIB-NEXT:Symbol: _func
321 # IMPORTLIB-NOT:{{.}}