1 //===- COFFYAML.cpp - COFF YAMLIO implementation --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines classes for handling the YAML representation of COFF.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/ObjectYAML/COFFYAML.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/YAMLTraits.h"
20 #define ECase(X) IO.enumCase(Value, #X, COFF::X);
26 Section::Section() { memset(&Header
, 0, sizeof(COFF::section
)); }
27 Symbol::Symbol() { memset(&Header
, 0, sizeof(COFF::symbol
)); }
28 Object::Object() { memset(&Header
, 0, sizeof(COFF::header
)); }
30 } // end namespace COFFYAML
34 void ScalarEnumerationTraits
<COFFYAML::COMDATType
>::enumeration(
35 IO
&IO
, COFFYAML::COMDATType
&Value
) {
36 IO
.enumCase(Value
, "0", 0);
37 ECase(IMAGE_COMDAT_SELECT_NODUPLICATES
);
38 ECase(IMAGE_COMDAT_SELECT_ANY
);
39 ECase(IMAGE_COMDAT_SELECT_SAME_SIZE
);
40 ECase(IMAGE_COMDAT_SELECT_EXACT_MATCH
);
41 ECase(IMAGE_COMDAT_SELECT_ASSOCIATIVE
);
42 ECase(IMAGE_COMDAT_SELECT_LARGEST
);
43 ECase(IMAGE_COMDAT_SELECT_NEWEST
);
47 ScalarEnumerationTraits
<COFFYAML::WeakExternalCharacteristics
>::enumeration(
48 IO
&IO
, COFFYAML::WeakExternalCharacteristics
&Value
) {
49 IO
.enumCase(Value
, "0", 0);
50 ECase(IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY
);
51 ECase(IMAGE_WEAK_EXTERN_SEARCH_LIBRARY
);
52 ECase(IMAGE_WEAK_EXTERN_SEARCH_ALIAS
);
55 void ScalarEnumerationTraits
<COFFYAML::AuxSymbolType
>::enumeration(
56 IO
&IO
, COFFYAML::AuxSymbolType
&Value
) {
57 ECase(IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF
);
60 void ScalarEnumerationTraits
<COFF::MachineTypes
>::enumeration(
61 IO
&IO
, COFF::MachineTypes
&Value
) {
62 ECase(IMAGE_FILE_MACHINE_UNKNOWN
);
63 ECase(IMAGE_FILE_MACHINE_AM33
);
64 ECase(IMAGE_FILE_MACHINE_AMD64
);
65 ECase(IMAGE_FILE_MACHINE_ARM
);
66 ECase(IMAGE_FILE_MACHINE_ARMNT
);
67 ECase(IMAGE_FILE_MACHINE_ARM64
);
68 ECase(IMAGE_FILE_MACHINE_EBC
);
69 ECase(IMAGE_FILE_MACHINE_I386
);
70 ECase(IMAGE_FILE_MACHINE_IA64
);
71 ECase(IMAGE_FILE_MACHINE_M32R
);
72 ECase(IMAGE_FILE_MACHINE_MIPS16
);
73 ECase(IMAGE_FILE_MACHINE_MIPSFPU
);
74 ECase(IMAGE_FILE_MACHINE_MIPSFPU16
);
75 ECase(IMAGE_FILE_MACHINE_POWERPC
);
76 ECase(IMAGE_FILE_MACHINE_POWERPCFP
);
77 ECase(IMAGE_FILE_MACHINE_R4000
);
78 ECase(IMAGE_FILE_MACHINE_SH3
);
79 ECase(IMAGE_FILE_MACHINE_SH3DSP
);
80 ECase(IMAGE_FILE_MACHINE_SH4
);
81 ECase(IMAGE_FILE_MACHINE_SH5
);
82 ECase(IMAGE_FILE_MACHINE_THUMB
);
83 ECase(IMAGE_FILE_MACHINE_WCEMIPSV2
);
86 void ScalarEnumerationTraits
<COFF::SymbolBaseType
>::enumeration(
87 IO
&IO
, COFF::SymbolBaseType
&Value
) {
88 ECase(IMAGE_SYM_TYPE_NULL
);
89 ECase(IMAGE_SYM_TYPE_VOID
);
90 ECase(IMAGE_SYM_TYPE_CHAR
);
91 ECase(IMAGE_SYM_TYPE_SHORT
);
92 ECase(IMAGE_SYM_TYPE_INT
);
93 ECase(IMAGE_SYM_TYPE_LONG
);
94 ECase(IMAGE_SYM_TYPE_FLOAT
);
95 ECase(IMAGE_SYM_TYPE_DOUBLE
);
96 ECase(IMAGE_SYM_TYPE_STRUCT
);
97 ECase(IMAGE_SYM_TYPE_UNION
);
98 ECase(IMAGE_SYM_TYPE_ENUM
);
99 ECase(IMAGE_SYM_TYPE_MOE
);
100 ECase(IMAGE_SYM_TYPE_BYTE
);
101 ECase(IMAGE_SYM_TYPE_WORD
);
102 ECase(IMAGE_SYM_TYPE_UINT
);
103 ECase(IMAGE_SYM_TYPE_DWORD
);
106 void ScalarEnumerationTraits
<COFF::SymbolStorageClass
>::enumeration(
107 IO
&IO
, COFF::SymbolStorageClass
&Value
) {
108 ECase(IMAGE_SYM_CLASS_END_OF_FUNCTION
);
109 ECase(IMAGE_SYM_CLASS_NULL
);
110 ECase(IMAGE_SYM_CLASS_AUTOMATIC
);
111 ECase(IMAGE_SYM_CLASS_EXTERNAL
);
112 ECase(IMAGE_SYM_CLASS_STATIC
);
113 ECase(IMAGE_SYM_CLASS_REGISTER
);
114 ECase(IMAGE_SYM_CLASS_EXTERNAL_DEF
);
115 ECase(IMAGE_SYM_CLASS_LABEL
);
116 ECase(IMAGE_SYM_CLASS_UNDEFINED_LABEL
);
117 ECase(IMAGE_SYM_CLASS_MEMBER_OF_STRUCT
);
118 ECase(IMAGE_SYM_CLASS_ARGUMENT
);
119 ECase(IMAGE_SYM_CLASS_STRUCT_TAG
);
120 ECase(IMAGE_SYM_CLASS_MEMBER_OF_UNION
);
121 ECase(IMAGE_SYM_CLASS_UNION_TAG
);
122 ECase(IMAGE_SYM_CLASS_TYPE_DEFINITION
);
123 ECase(IMAGE_SYM_CLASS_UNDEFINED_STATIC
);
124 ECase(IMAGE_SYM_CLASS_ENUM_TAG
);
125 ECase(IMAGE_SYM_CLASS_MEMBER_OF_ENUM
);
126 ECase(IMAGE_SYM_CLASS_REGISTER_PARAM
);
127 ECase(IMAGE_SYM_CLASS_BIT_FIELD
);
128 ECase(IMAGE_SYM_CLASS_BLOCK
);
129 ECase(IMAGE_SYM_CLASS_FUNCTION
);
130 ECase(IMAGE_SYM_CLASS_END_OF_STRUCT
);
131 ECase(IMAGE_SYM_CLASS_FILE
);
132 ECase(IMAGE_SYM_CLASS_SECTION
);
133 ECase(IMAGE_SYM_CLASS_WEAK_EXTERNAL
);
134 ECase(IMAGE_SYM_CLASS_CLR_TOKEN
);
137 void ScalarEnumerationTraits
<COFF::SymbolComplexType
>::enumeration(
138 IO
&IO
, COFF::SymbolComplexType
&Value
) {
139 ECase(IMAGE_SYM_DTYPE_NULL
);
140 ECase(IMAGE_SYM_DTYPE_POINTER
);
141 ECase(IMAGE_SYM_DTYPE_FUNCTION
);
142 ECase(IMAGE_SYM_DTYPE_ARRAY
);
145 void ScalarEnumerationTraits
<COFF::RelocationTypeI386
>::enumeration(
146 IO
&IO
, COFF::RelocationTypeI386
&Value
) {
147 ECase(IMAGE_REL_I386_ABSOLUTE
);
148 ECase(IMAGE_REL_I386_DIR16
);
149 ECase(IMAGE_REL_I386_REL16
);
150 ECase(IMAGE_REL_I386_DIR32
);
151 ECase(IMAGE_REL_I386_DIR32NB
);
152 ECase(IMAGE_REL_I386_SEG12
);
153 ECase(IMAGE_REL_I386_SECTION
);
154 ECase(IMAGE_REL_I386_SECREL
);
155 ECase(IMAGE_REL_I386_TOKEN
);
156 ECase(IMAGE_REL_I386_SECREL7
);
157 ECase(IMAGE_REL_I386_REL32
);
160 void ScalarEnumerationTraits
<COFF::RelocationTypeAMD64
>::enumeration(
161 IO
&IO
, COFF::RelocationTypeAMD64
&Value
) {
162 ECase(IMAGE_REL_AMD64_ABSOLUTE
);
163 ECase(IMAGE_REL_AMD64_ADDR64
);
164 ECase(IMAGE_REL_AMD64_ADDR32
);
165 ECase(IMAGE_REL_AMD64_ADDR32NB
);
166 ECase(IMAGE_REL_AMD64_REL32
);
167 ECase(IMAGE_REL_AMD64_REL32_1
);
168 ECase(IMAGE_REL_AMD64_REL32_2
);
169 ECase(IMAGE_REL_AMD64_REL32_3
);
170 ECase(IMAGE_REL_AMD64_REL32_4
);
171 ECase(IMAGE_REL_AMD64_REL32_5
);
172 ECase(IMAGE_REL_AMD64_SECTION
);
173 ECase(IMAGE_REL_AMD64_SECREL
);
174 ECase(IMAGE_REL_AMD64_SECREL7
);
175 ECase(IMAGE_REL_AMD64_TOKEN
);
176 ECase(IMAGE_REL_AMD64_SREL32
);
177 ECase(IMAGE_REL_AMD64_PAIR
);
178 ECase(IMAGE_REL_AMD64_SSPAN32
);
181 void ScalarEnumerationTraits
<COFF::RelocationTypesARM
>::enumeration(
182 IO
&IO
, COFF::RelocationTypesARM
&Value
) {
183 ECase(IMAGE_REL_ARM_ABSOLUTE
);
184 ECase(IMAGE_REL_ARM_ADDR32
);
185 ECase(IMAGE_REL_ARM_ADDR32NB
);
186 ECase(IMAGE_REL_ARM_BRANCH24
);
187 ECase(IMAGE_REL_ARM_BRANCH11
);
188 ECase(IMAGE_REL_ARM_TOKEN
);
189 ECase(IMAGE_REL_ARM_BLX24
);
190 ECase(IMAGE_REL_ARM_BLX11
);
191 ECase(IMAGE_REL_ARM_SECTION
);
192 ECase(IMAGE_REL_ARM_SECREL
);
193 ECase(IMAGE_REL_ARM_MOV32A
);
194 ECase(IMAGE_REL_ARM_MOV32T
);
195 ECase(IMAGE_REL_ARM_BRANCH20T
);
196 ECase(IMAGE_REL_ARM_BRANCH24T
);
197 ECase(IMAGE_REL_ARM_BLX23T
);
200 void ScalarEnumerationTraits
<COFF::RelocationTypesARM64
>::enumeration(
201 IO
&IO
, COFF::RelocationTypesARM64
&Value
) {
202 ECase(IMAGE_REL_ARM64_ABSOLUTE
);
203 ECase(IMAGE_REL_ARM64_ADDR32
);
204 ECase(IMAGE_REL_ARM64_ADDR32NB
);
205 ECase(IMAGE_REL_ARM64_BRANCH26
);
206 ECase(IMAGE_REL_ARM64_PAGEBASE_REL21
);
207 ECase(IMAGE_REL_ARM64_REL21
);
208 ECase(IMAGE_REL_ARM64_PAGEOFFSET_12A
);
209 ECase(IMAGE_REL_ARM64_PAGEOFFSET_12L
);
210 ECase(IMAGE_REL_ARM64_SECREL
);
211 ECase(IMAGE_REL_ARM64_SECREL_LOW12A
);
212 ECase(IMAGE_REL_ARM64_SECREL_HIGH12A
);
213 ECase(IMAGE_REL_ARM64_SECREL_LOW12L
);
214 ECase(IMAGE_REL_ARM64_TOKEN
);
215 ECase(IMAGE_REL_ARM64_SECTION
);
216 ECase(IMAGE_REL_ARM64_ADDR64
);
217 ECase(IMAGE_REL_ARM64_BRANCH19
);
218 ECase(IMAGE_REL_ARM64_BRANCH14
);
221 void ScalarEnumerationTraits
<COFF::WindowsSubsystem
>::enumeration(
222 IO
&IO
, COFF::WindowsSubsystem
&Value
) {
223 ECase(IMAGE_SUBSYSTEM_UNKNOWN
);
224 ECase(IMAGE_SUBSYSTEM_NATIVE
);
225 ECase(IMAGE_SUBSYSTEM_WINDOWS_GUI
);
226 ECase(IMAGE_SUBSYSTEM_WINDOWS_CUI
);
227 ECase(IMAGE_SUBSYSTEM_OS2_CUI
);
228 ECase(IMAGE_SUBSYSTEM_POSIX_CUI
);
229 ECase(IMAGE_SUBSYSTEM_NATIVE_WINDOWS
);
230 ECase(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI
);
231 ECase(IMAGE_SUBSYSTEM_EFI_APPLICATION
);
232 ECase(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
);
233 ECase(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
);
234 ECase(IMAGE_SUBSYSTEM_EFI_ROM
);
235 ECase(IMAGE_SUBSYSTEM_XBOX
);
236 ECase(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION
);
240 #define BCase(X) IO.bitSetCase(Value, #X, COFF::X);
241 void ScalarBitSetTraits
<COFF::Characteristics
>::bitset(
242 IO
&IO
, COFF::Characteristics
&Value
) {
243 BCase(IMAGE_FILE_RELOCS_STRIPPED
);
244 BCase(IMAGE_FILE_EXECUTABLE_IMAGE
);
245 BCase(IMAGE_FILE_LINE_NUMS_STRIPPED
);
246 BCase(IMAGE_FILE_LOCAL_SYMS_STRIPPED
);
247 BCase(IMAGE_FILE_AGGRESSIVE_WS_TRIM
);
248 BCase(IMAGE_FILE_LARGE_ADDRESS_AWARE
);
249 BCase(IMAGE_FILE_BYTES_REVERSED_LO
);
250 BCase(IMAGE_FILE_32BIT_MACHINE
);
251 BCase(IMAGE_FILE_DEBUG_STRIPPED
);
252 BCase(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP
);
253 BCase(IMAGE_FILE_NET_RUN_FROM_SWAP
);
254 BCase(IMAGE_FILE_SYSTEM
);
255 BCase(IMAGE_FILE_DLL
);
256 BCase(IMAGE_FILE_UP_SYSTEM_ONLY
);
257 BCase(IMAGE_FILE_BYTES_REVERSED_HI
);
260 void ScalarBitSetTraits
<COFF::SectionCharacteristics
>::bitset(
261 IO
&IO
, COFF::SectionCharacteristics
&Value
) {
262 BCase(IMAGE_SCN_TYPE_NOLOAD
);
263 BCase(IMAGE_SCN_TYPE_NO_PAD
);
264 BCase(IMAGE_SCN_CNT_CODE
);
265 BCase(IMAGE_SCN_CNT_INITIALIZED_DATA
);
266 BCase(IMAGE_SCN_CNT_UNINITIALIZED_DATA
);
267 BCase(IMAGE_SCN_LNK_OTHER
);
268 BCase(IMAGE_SCN_LNK_INFO
);
269 BCase(IMAGE_SCN_LNK_REMOVE
);
270 BCase(IMAGE_SCN_LNK_COMDAT
);
271 BCase(IMAGE_SCN_GPREL
);
272 BCase(IMAGE_SCN_MEM_PURGEABLE
);
273 BCase(IMAGE_SCN_MEM_16BIT
);
274 BCase(IMAGE_SCN_MEM_LOCKED
);
275 BCase(IMAGE_SCN_MEM_PRELOAD
);
276 BCase(IMAGE_SCN_LNK_NRELOC_OVFL
);
277 BCase(IMAGE_SCN_MEM_DISCARDABLE
);
278 BCase(IMAGE_SCN_MEM_NOT_CACHED
);
279 BCase(IMAGE_SCN_MEM_NOT_PAGED
);
280 BCase(IMAGE_SCN_MEM_SHARED
);
281 BCase(IMAGE_SCN_MEM_EXECUTE
);
282 BCase(IMAGE_SCN_MEM_READ
);
283 BCase(IMAGE_SCN_MEM_WRITE
);
286 void ScalarBitSetTraits
<COFF::DLLCharacteristics
>::bitset(
287 IO
&IO
, COFF::DLLCharacteristics
&Value
) {
288 BCase(IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA
);
289 BCase(IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
);
290 BCase(IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY
);
291 BCase(IMAGE_DLL_CHARACTERISTICS_NX_COMPAT
);
292 BCase(IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION
);
293 BCase(IMAGE_DLL_CHARACTERISTICS_NO_SEH
);
294 BCase(IMAGE_DLL_CHARACTERISTICS_NO_BIND
);
295 BCase(IMAGE_DLL_CHARACTERISTICS_APPCONTAINER
);
296 BCase(IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER
);
297 BCase(IMAGE_DLL_CHARACTERISTICS_GUARD_CF
);
298 BCase(IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE
);
304 struct NSectionSelectionType
{
305 NSectionSelectionType(IO
&)
306 : SelectionType(COFFYAML::COMDATType(0)) {}
307 NSectionSelectionType(IO
&, uint8_t C
)
308 : SelectionType(COFFYAML::COMDATType(C
)) {}
310 uint8_t denormalize(IO
&) { return SelectionType
; }
312 COFFYAML::COMDATType SelectionType
;
315 struct NWeakExternalCharacteristics
{
316 NWeakExternalCharacteristics(IO
&)
317 : Characteristics(COFFYAML::WeakExternalCharacteristics(0)) {}
318 NWeakExternalCharacteristics(IO
&, uint32_t C
)
319 : Characteristics(COFFYAML::WeakExternalCharacteristics(C
)) {}
321 uint32_t denormalize(IO
&) { return Characteristics
; }
323 COFFYAML::WeakExternalCharacteristics Characteristics
;
326 struct NSectionCharacteristics
{
327 NSectionCharacteristics(IO
&)
328 : Characteristics(COFF::SectionCharacteristics(0)) {}
329 NSectionCharacteristics(IO
&, uint32_t C
)
330 : Characteristics(COFF::SectionCharacteristics(C
)) {}
332 uint32_t denormalize(IO
&) { return Characteristics
; }
334 COFF::SectionCharacteristics Characteristics
;
337 struct NAuxTokenType
{
339 : AuxType(COFFYAML::AuxSymbolType(0)) {}
340 NAuxTokenType(IO
&, uint8_t C
)
341 : AuxType(COFFYAML::AuxSymbolType(C
)) {}
343 uint32_t denormalize(IO
&) { return AuxType
; }
345 COFFYAML::AuxSymbolType AuxType
;
348 struct NStorageClass
{
349 NStorageClass(IO
&) : StorageClass(COFF::SymbolStorageClass(0)) {}
350 NStorageClass(IO
&, uint8_t S
) : StorageClass(COFF::SymbolStorageClass(S
)) {}
352 uint8_t denormalize(IO
&) { return StorageClass
; }
354 COFF::SymbolStorageClass StorageClass
;
358 NMachine(IO
&) : Machine(COFF::MachineTypes(0)) {}
359 NMachine(IO
&, uint16_t M
) : Machine(COFF::MachineTypes(M
)) {}
361 uint16_t denormalize(IO
&) { return Machine
; }
363 COFF::MachineTypes Machine
;
366 struct NHeaderCharacteristics
{
367 NHeaderCharacteristics(IO
&) : Characteristics(COFF::Characteristics(0)) {}
368 NHeaderCharacteristics(IO
&, uint16_t C
)
369 : Characteristics(COFF::Characteristics(C
)) {}
371 uint16_t denormalize(IO
&) { return Characteristics
; }
373 COFF::Characteristics Characteristics
;
376 template <typename RelocType
>
378 NType(IO
&) : Type(RelocType(0)) {}
379 NType(IO
&, uint16_t T
) : Type(RelocType(T
)) {}
381 uint16_t denormalize(IO
&) { return Type
; }
386 struct NWindowsSubsystem
{
387 NWindowsSubsystem(IO
&) : Subsystem(COFF::WindowsSubsystem(0)) {}
388 NWindowsSubsystem(IO
&, uint16_t C
) : Subsystem(COFF::WindowsSubsystem(C
)) {}
390 uint16_t denormalize(IO
&) { return Subsystem
; }
392 COFF::WindowsSubsystem Subsystem
;
395 struct NDLLCharacteristics
{
396 NDLLCharacteristics(IO
&) : Characteristics(COFF::DLLCharacteristics(0)) {}
397 NDLLCharacteristics(IO
&, uint16_t C
)
398 : Characteristics(COFF::DLLCharacteristics(C
)) {}
400 uint16_t denormalize(IO
&) { return Characteristics
; }
402 COFF::DLLCharacteristics Characteristics
;
405 } // end anonymous namespace
407 void MappingTraits
<COFFYAML::Relocation
>::mapping(IO
&IO
,
408 COFFYAML::Relocation
&Rel
) {
409 IO
.mapRequired("VirtualAddress", Rel
.VirtualAddress
);
410 IO
.mapRequired("SymbolName", Rel
.SymbolName
);
412 COFF::header
&H
= *static_cast<COFF::header
*>(IO
.getContext());
413 if (H
.Machine
== COFF::IMAGE_FILE_MACHINE_I386
) {
414 MappingNormalization
<NType
<COFF::RelocationTypeI386
>, uint16_t> NT(
416 IO
.mapRequired("Type", NT
->Type
);
417 } else if (H
.Machine
== COFF::IMAGE_FILE_MACHINE_AMD64
) {
418 MappingNormalization
<NType
<COFF::RelocationTypeAMD64
>, uint16_t> NT(
420 IO
.mapRequired("Type", NT
->Type
);
421 } else if (H
.Machine
== COFF::IMAGE_FILE_MACHINE_ARMNT
) {
422 MappingNormalization
<NType
<COFF::RelocationTypesARM
>, uint16_t> NT(
424 IO
.mapRequired("Type", NT
->Type
);
425 } else if (H
.Machine
== COFF::IMAGE_FILE_MACHINE_ARM64
) {
426 MappingNormalization
<NType
<COFF::RelocationTypesARM64
>, uint16_t> NT(
428 IO
.mapRequired("Type", NT
->Type
);
430 IO
.mapRequired("Type", Rel
.Type
);
434 void MappingTraits
<COFF::DataDirectory
>::mapping(IO
&IO
,
435 COFF::DataDirectory
&DD
) {
436 IO
.mapRequired("RelativeVirtualAddress", DD
.RelativeVirtualAddress
);
437 IO
.mapRequired("Size", DD
.Size
);
440 void MappingTraits
<COFFYAML::PEHeader
>::mapping(IO
&IO
,
441 COFFYAML::PEHeader
&PH
) {
442 MappingNormalization
<NWindowsSubsystem
, uint16_t> NWS(IO
,
443 PH
.Header
.Subsystem
);
444 MappingNormalization
<NDLLCharacteristics
, uint16_t> NDC(
445 IO
, PH
.Header
.DLLCharacteristics
);
447 IO
.mapRequired("AddressOfEntryPoint", PH
.Header
.AddressOfEntryPoint
);
448 IO
.mapRequired("ImageBase", PH
.Header
.ImageBase
);
449 IO
.mapRequired("SectionAlignment", PH
.Header
.SectionAlignment
);
450 IO
.mapRequired("FileAlignment", PH
.Header
.FileAlignment
);
451 IO
.mapRequired("MajorOperatingSystemVersion",
452 PH
.Header
.MajorOperatingSystemVersion
);
453 IO
.mapRequired("MinorOperatingSystemVersion",
454 PH
.Header
.MinorOperatingSystemVersion
);
455 IO
.mapRequired("MajorImageVersion", PH
.Header
.MajorImageVersion
);
456 IO
.mapRequired("MinorImageVersion", PH
.Header
.MinorImageVersion
);
457 IO
.mapRequired("MajorSubsystemVersion", PH
.Header
.MajorSubsystemVersion
);
458 IO
.mapRequired("MinorSubsystemVersion", PH
.Header
.MinorSubsystemVersion
);
459 IO
.mapRequired("Subsystem", NWS
->Subsystem
);
460 IO
.mapRequired("DLLCharacteristics", NDC
->Characteristics
);
461 IO
.mapRequired("SizeOfStackReserve", PH
.Header
.SizeOfStackReserve
);
462 IO
.mapRequired("SizeOfStackCommit", PH
.Header
.SizeOfStackCommit
);
463 IO
.mapRequired("SizeOfHeapReserve", PH
.Header
.SizeOfHeapReserve
);
464 IO
.mapRequired("SizeOfHeapCommit", PH
.Header
.SizeOfHeapCommit
);
466 IO
.mapOptional("ExportTable", PH
.DataDirectories
[COFF::EXPORT_TABLE
]);
467 IO
.mapOptional("ImportTable", PH
.DataDirectories
[COFF::IMPORT_TABLE
]);
468 IO
.mapOptional("ResourceTable", PH
.DataDirectories
[COFF::RESOURCE_TABLE
]);
469 IO
.mapOptional("ExceptionTable", PH
.DataDirectories
[COFF::EXCEPTION_TABLE
]);
470 IO
.mapOptional("CertificateTable", PH
.DataDirectories
[COFF::CERTIFICATE_TABLE
]);
471 IO
.mapOptional("BaseRelocationTable",
472 PH
.DataDirectories
[COFF::BASE_RELOCATION_TABLE
]);
473 IO
.mapOptional("Debug", PH
.DataDirectories
[COFF::DEBUG_DIRECTORY
]);
474 IO
.mapOptional("Architecture", PH
.DataDirectories
[COFF::ARCHITECTURE
]);
475 IO
.mapOptional("GlobalPtr", PH
.DataDirectories
[COFF::GLOBAL_PTR
]);
476 IO
.mapOptional("TlsTable", PH
.DataDirectories
[COFF::TLS_TABLE
]);
477 IO
.mapOptional("LoadConfigTable",
478 PH
.DataDirectories
[COFF::LOAD_CONFIG_TABLE
]);
479 IO
.mapOptional("BoundImport", PH
.DataDirectories
[COFF::BOUND_IMPORT
]);
480 IO
.mapOptional("IAT", PH
.DataDirectories
[COFF::IAT
]);
481 IO
.mapOptional("DelayImportDescriptor",
482 PH
.DataDirectories
[COFF::DELAY_IMPORT_DESCRIPTOR
]);
483 IO
.mapOptional("ClrRuntimeHeader",
484 PH
.DataDirectories
[COFF::CLR_RUNTIME_HEADER
]);
487 void MappingTraits
<COFF::header
>::mapping(IO
&IO
, COFF::header
&H
) {
488 MappingNormalization
<NMachine
, uint16_t> NM(IO
, H
.Machine
);
489 MappingNormalization
<NHeaderCharacteristics
, uint16_t> NC(IO
,
492 IO
.mapRequired("Machine", NM
->Machine
);
493 IO
.mapOptional("Characteristics", NC
->Characteristics
);
494 IO
.setContext(static_cast<void *>(&H
));
497 void MappingTraits
<COFF::AuxiliaryFunctionDefinition
>::mapping(
498 IO
&IO
, COFF::AuxiliaryFunctionDefinition
&AFD
) {
499 IO
.mapRequired("TagIndex", AFD
.TagIndex
);
500 IO
.mapRequired("TotalSize", AFD
.TotalSize
);
501 IO
.mapRequired("PointerToLinenumber", AFD
.PointerToLinenumber
);
502 IO
.mapRequired("PointerToNextFunction", AFD
.PointerToNextFunction
);
505 void MappingTraits
<COFF::AuxiliarybfAndefSymbol
>::mapping(
506 IO
&IO
, COFF::AuxiliarybfAndefSymbol
&AAS
) {
507 IO
.mapRequired("Linenumber", AAS
.Linenumber
);
508 IO
.mapRequired("PointerToNextFunction", AAS
.PointerToNextFunction
);
511 void MappingTraits
<COFF::AuxiliaryWeakExternal
>::mapping(
512 IO
&IO
, COFF::AuxiliaryWeakExternal
&AWE
) {
513 MappingNormalization
<NWeakExternalCharacteristics
, uint32_t> NWEC(
514 IO
, AWE
.Characteristics
);
515 IO
.mapRequired("TagIndex", AWE
.TagIndex
);
516 IO
.mapRequired("Characteristics", NWEC
->Characteristics
);
519 void MappingTraits
<COFF::AuxiliarySectionDefinition
>::mapping(
520 IO
&IO
, COFF::AuxiliarySectionDefinition
&ASD
) {
521 MappingNormalization
<NSectionSelectionType
, uint8_t> NSST(
524 IO
.mapRequired("Length", ASD
.Length
);
525 IO
.mapRequired("NumberOfRelocations", ASD
.NumberOfRelocations
);
526 IO
.mapRequired("NumberOfLinenumbers", ASD
.NumberOfLinenumbers
);
527 IO
.mapRequired("CheckSum", ASD
.CheckSum
);
528 IO
.mapRequired("Number", ASD
.Number
);
529 IO
.mapOptional("Selection", NSST
->SelectionType
, COFFYAML::COMDATType(0));
532 void MappingTraits
<COFF::AuxiliaryCLRToken
>::mapping(
533 IO
&IO
, COFF::AuxiliaryCLRToken
&ACT
) {
534 MappingNormalization
<NAuxTokenType
, uint8_t> NATT(IO
, ACT
.AuxType
);
535 IO
.mapRequired("AuxType", NATT
->AuxType
);
536 IO
.mapRequired("SymbolTableIndex", ACT
.SymbolTableIndex
);
539 void MappingTraits
<COFFYAML::Symbol
>::mapping(IO
&IO
, COFFYAML::Symbol
&S
) {
540 MappingNormalization
<NStorageClass
, uint8_t> NS(IO
, S
.Header
.StorageClass
);
542 IO
.mapRequired("Name", S
.Name
);
543 IO
.mapRequired("Value", S
.Header
.Value
);
544 IO
.mapRequired("SectionNumber", S
.Header
.SectionNumber
);
545 IO
.mapRequired("SimpleType", S
.SimpleType
);
546 IO
.mapRequired("ComplexType", S
.ComplexType
);
547 IO
.mapRequired("StorageClass", NS
->StorageClass
);
548 IO
.mapOptional("FunctionDefinition", S
.FunctionDefinition
);
549 IO
.mapOptional("bfAndefSymbol", S
.bfAndefSymbol
);
550 IO
.mapOptional("WeakExternal", S
.WeakExternal
);
551 IO
.mapOptional("File", S
.File
, StringRef());
552 IO
.mapOptional("SectionDefinition", S
.SectionDefinition
);
553 IO
.mapOptional("CLRToken", S
.CLRToken
);
556 void MappingTraits
<COFFYAML::Section
>::mapping(IO
&IO
, COFFYAML::Section
&Sec
) {
557 MappingNormalization
<NSectionCharacteristics
, uint32_t> NC(
558 IO
, Sec
.Header
.Characteristics
);
559 IO
.mapRequired("Name", Sec
.Name
);
560 IO
.mapRequired("Characteristics", NC
->Characteristics
);
561 IO
.mapOptional("VirtualAddress", Sec
.Header
.VirtualAddress
, 0U);
562 IO
.mapOptional("VirtualSize", Sec
.Header
.VirtualSize
, 0U);
563 IO
.mapOptional("Alignment", Sec
.Alignment
, 0U);
565 // If this is a .debug$S .debug$T .debug$P, or .debug$H section parse the
566 // semantic representation of the symbols/types. If it is any other kind
567 // of section, just deal in raw bytes.
568 IO
.mapOptional("SectionData", Sec
.SectionData
);
569 if (Sec
.Name
== ".debug$S")
570 IO
.mapOptional("Subsections", Sec
.DebugS
);
571 else if (Sec
.Name
== ".debug$T")
572 IO
.mapOptional("Types", Sec
.DebugT
);
573 else if (Sec
.Name
== ".debug$P")
574 IO
.mapOptional("PrecompTypes", Sec
.DebugP
);
575 else if (Sec
.Name
== ".debug$H")
576 IO
.mapOptional("GlobalHashes", Sec
.DebugH
);
578 IO
.mapOptional("Relocations", Sec
.Relocations
);
581 void MappingTraits
<COFFYAML::Object
>::mapping(IO
&IO
, COFFYAML::Object
&Obj
) {
582 IO
.mapTag("!COFF", true);
583 IO
.mapOptional("OptionalHeader", Obj
.OptionalHeader
);
584 IO
.mapRequired("header", Obj
.Header
);
585 IO
.mapRequired("sections", Obj
.Sections
);
586 IO
.mapRequired("symbols", Obj
.Symbols
);
589 } // end namespace yaml
591 } // end namespace llvm