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/Object/COFFYAML.h"
16 #define ECase(X) IO.enumCase(Value, #X, COFF::X);
20 Section::Section() { memset(&Header, 0, sizeof(COFF::section)); }
21 Symbol::Symbol() { memset(&Header, 0, sizeof(COFF::symbol)); }
22 Object::Object() { memset(&Header, 0, sizeof(COFF::header)); }
26 void ScalarEnumerationTraits<COFFYAML::COMDATType>::enumeration(
27 IO &IO, COFFYAML::COMDATType &Value) {
28 IO.enumCase(Value, "0", 0);
29 ECase(IMAGE_COMDAT_SELECT_NODUPLICATES);
30 ECase(IMAGE_COMDAT_SELECT_ANY);
31 ECase(IMAGE_COMDAT_SELECT_SAME_SIZE);
32 ECase(IMAGE_COMDAT_SELECT_EXACT_MATCH);
33 ECase(IMAGE_COMDAT_SELECT_ASSOCIATIVE);
34 ECase(IMAGE_COMDAT_SELECT_LARGEST);
35 ECase(IMAGE_COMDAT_SELECT_NEWEST);
39 ScalarEnumerationTraits<COFFYAML::WeakExternalCharacteristics>::enumeration(
40 IO &IO, COFFYAML::WeakExternalCharacteristics &Value) {
41 IO.enumCase(Value, "0", 0);
42 ECase(IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY);
43 ECase(IMAGE_WEAK_EXTERN_SEARCH_LIBRARY);
44 ECase(IMAGE_WEAK_EXTERN_SEARCH_ALIAS);
47 void ScalarEnumerationTraits<COFFYAML::AuxSymbolType>::enumeration(
48 IO &IO, COFFYAML::AuxSymbolType &Value) {
49 ECase(IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF);
52 void ScalarEnumerationTraits<COFF::MachineTypes>::enumeration(
53 IO &IO, COFF::MachineTypes &Value) {
54 ECase(IMAGE_FILE_MACHINE_UNKNOWN);
55 ECase(IMAGE_FILE_MACHINE_AM33);
56 ECase(IMAGE_FILE_MACHINE_AMD64);
57 ECase(IMAGE_FILE_MACHINE_ARM);
58 ECase(IMAGE_FILE_MACHINE_ARMNT);
59 ECase(IMAGE_FILE_MACHINE_EBC);
60 ECase(IMAGE_FILE_MACHINE_I386);
61 ECase(IMAGE_FILE_MACHINE_IA64);
62 ECase(IMAGE_FILE_MACHINE_M32R);
63 ECase(IMAGE_FILE_MACHINE_MIPS16);
64 ECase(IMAGE_FILE_MACHINE_MIPSFPU);
65 ECase(IMAGE_FILE_MACHINE_MIPSFPU16);
66 ECase(IMAGE_FILE_MACHINE_POWERPC);
67 ECase(IMAGE_FILE_MACHINE_POWERPCFP);
68 ECase(IMAGE_FILE_MACHINE_R4000);
69 ECase(IMAGE_FILE_MACHINE_SH3);
70 ECase(IMAGE_FILE_MACHINE_SH3DSP);
71 ECase(IMAGE_FILE_MACHINE_SH4);
72 ECase(IMAGE_FILE_MACHINE_SH5);
73 ECase(IMAGE_FILE_MACHINE_THUMB);
74 ECase(IMAGE_FILE_MACHINE_WCEMIPSV2);
77 void ScalarEnumerationTraits<COFF::SymbolBaseType>::enumeration(
78 IO &IO, COFF::SymbolBaseType &Value) {
79 ECase(IMAGE_SYM_TYPE_NULL);
80 ECase(IMAGE_SYM_TYPE_VOID);
81 ECase(IMAGE_SYM_TYPE_CHAR);
82 ECase(IMAGE_SYM_TYPE_SHORT);
83 ECase(IMAGE_SYM_TYPE_INT);
84 ECase(IMAGE_SYM_TYPE_LONG);
85 ECase(IMAGE_SYM_TYPE_FLOAT);
86 ECase(IMAGE_SYM_TYPE_DOUBLE);
87 ECase(IMAGE_SYM_TYPE_STRUCT);
88 ECase(IMAGE_SYM_TYPE_UNION);
89 ECase(IMAGE_SYM_TYPE_ENUM);
90 ECase(IMAGE_SYM_TYPE_MOE);
91 ECase(IMAGE_SYM_TYPE_BYTE);
92 ECase(IMAGE_SYM_TYPE_WORD);
93 ECase(IMAGE_SYM_TYPE_UINT);
94 ECase(IMAGE_SYM_TYPE_DWORD);
97 void ScalarEnumerationTraits<COFF::SymbolStorageClass>::enumeration(
98 IO &IO, COFF::SymbolStorageClass &Value) {
99 ECase(IMAGE_SYM_CLASS_END_OF_FUNCTION);
100 ECase(IMAGE_SYM_CLASS_NULL);
101 ECase(IMAGE_SYM_CLASS_AUTOMATIC);
102 ECase(IMAGE_SYM_CLASS_EXTERNAL);
103 ECase(IMAGE_SYM_CLASS_STATIC);
104 ECase(IMAGE_SYM_CLASS_REGISTER);
105 ECase(IMAGE_SYM_CLASS_EXTERNAL_DEF);
106 ECase(IMAGE_SYM_CLASS_LABEL);
107 ECase(IMAGE_SYM_CLASS_UNDEFINED_LABEL);
108 ECase(IMAGE_SYM_CLASS_MEMBER_OF_STRUCT);
109 ECase(IMAGE_SYM_CLASS_ARGUMENT);
110 ECase(IMAGE_SYM_CLASS_STRUCT_TAG);
111 ECase(IMAGE_SYM_CLASS_MEMBER_OF_UNION);
112 ECase(IMAGE_SYM_CLASS_UNION_TAG);
113 ECase(IMAGE_SYM_CLASS_TYPE_DEFINITION);
114 ECase(IMAGE_SYM_CLASS_UNDEFINED_STATIC);
115 ECase(IMAGE_SYM_CLASS_ENUM_TAG);
116 ECase(IMAGE_SYM_CLASS_MEMBER_OF_ENUM);
117 ECase(IMAGE_SYM_CLASS_REGISTER_PARAM);
118 ECase(IMAGE_SYM_CLASS_BIT_FIELD);
119 ECase(IMAGE_SYM_CLASS_BLOCK);
120 ECase(IMAGE_SYM_CLASS_FUNCTION);
121 ECase(IMAGE_SYM_CLASS_END_OF_STRUCT);
122 ECase(IMAGE_SYM_CLASS_FILE);
123 ECase(IMAGE_SYM_CLASS_SECTION);
124 ECase(IMAGE_SYM_CLASS_WEAK_EXTERNAL);
125 ECase(IMAGE_SYM_CLASS_CLR_TOKEN);
128 void ScalarEnumerationTraits<COFF::SymbolComplexType>::enumeration(
129 IO &IO, COFF::SymbolComplexType &Value) {
130 ECase(IMAGE_SYM_DTYPE_NULL);
131 ECase(IMAGE_SYM_DTYPE_POINTER);
132 ECase(IMAGE_SYM_DTYPE_FUNCTION);
133 ECase(IMAGE_SYM_DTYPE_ARRAY);
136 void ScalarEnumerationTraits<COFF::RelocationTypeI386>::enumeration(
137 IO &IO, COFF::RelocationTypeI386 &Value) {
138 ECase(IMAGE_REL_I386_ABSOLUTE);
139 ECase(IMAGE_REL_I386_DIR16);
140 ECase(IMAGE_REL_I386_REL16);
141 ECase(IMAGE_REL_I386_DIR32);
142 ECase(IMAGE_REL_I386_DIR32NB);
143 ECase(IMAGE_REL_I386_SEG12);
144 ECase(IMAGE_REL_I386_SECTION);
145 ECase(IMAGE_REL_I386_SECREL);
146 ECase(IMAGE_REL_I386_TOKEN);
147 ECase(IMAGE_REL_I386_SECREL7);
148 ECase(IMAGE_REL_I386_REL32);
151 void ScalarEnumerationTraits<COFF::RelocationTypeAMD64>::enumeration(
152 IO &IO, COFF::RelocationTypeAMD64 &Value) {
153 ECase(IMAGE_REL_AMD64_ABSOLUTE);
154 ECase(IMAGE_REL_AMD64_ADDR64);
155 ECase(IMAGE_REL_AMD64_ADDR32);
156 ECase(IMAGE_REL_AMD64_ADDR32NB);
157 ECase(IMAGE_REL_AMD64_REL32);
158 ECase(IMAGE_REL_AMD64_REL32_1);
159 ECase(IMAGE_REL_AMD64_REL32_2);
160 ECase(IMAGE_REL_AMD64_REL32_3);
161 ECase(IMAGE_REL_AMD64_REL32_4);
162 ECase(IMAGE_REL_AMD64_REL32_5);
163 ECase(IMAGE_REL_AMD64_SECTION);
164 ECase(IMAGE_REL_AMD64_SECREL);
165 ECase(IMAGE_REL_AMD64_SECREL7);
166 ECase(IMAGE_REL_AMD64_TOKEN);
167 ECase(IMAGE_REL_AMD64_SREL32);
168 ECase(IMAGE_REL_AMD64_PAIR);
169 ECase(IMAGE_REL_AMD64_SSPAN32);
172 void ScalarEnumerationTraits<COFF::WindowsSubsystem>::enumeration(
173 IO &IO, COFF::WindowsSubsystem &Value) {
174 ECase(IMAGE_SUBSYSTEM_UNKNOWN);
175 ECase(IMAGE_SUBSYSTEM_NATIVE);
176 ECase(IMAGE_SUBSYSTEM_WINDOWS_GUI);
177 ECase(IMAGE_SUBSYSTEM_WINDOWS_CUI);
178 ECase(IMAGE_SUBSYSTEM_OS2_CUI);
179 ECase(IMAGE_SUBSYSTEM_POSIX_CUI);
180 ECase(IMAGE_SUBSYSTEM_NATIVE_WINDOWS);
181 ECase(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI);
182 ECase(IMAGE_SUBSYSTEM_EFI_APPLICATION);
183 ECase(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER);
184 ECase(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER);
185 ECase(IMAGE_SUBSYSTEM_EFI_ROM);
186 ECase(IMAGE_SUBSYSTEM_XBOX);
187 ECase(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION);
191 #define BCase(X) IO.bitSetCase(Value, #X, COFF::X);
192 void ScalarBitSetTraits<COFF::Characteristics>::bitset(
193 IO &IO, COFF::Characteristics &Value) {
194 BCase(IMAGE_FILE_RELOCS_STRIPPED);
195 BCase(IMAGE_FILE_EXECUTABLE_IMAGE);
196 BCase(IMAGE_FILE_LINE_NUMS_STRIPPED);
197 BCase(IMAGE_FILE_LOCAL_SYMS_STRIPPED);
198 BCase(IMAGE_FILE_AGGRESSIVE_WS_TRIM);
199 BCase(IMAGE_FILE_LARGE_ADDRESS_AWARE);
200 BCase(IMAGE_FILE_BYTES_REVERSED_LO);
201 BCase(IMAGE_FILE_32BIT_MACHINE);
202 BCase(IMAGE_FILE_DEBUG_STRIPPED);
203 BCase(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP);
204 BCase(IMAGE_FILE_NET_RUN_FROM_SWAP);
205 BCase(IMAGE_FILE_SYSTEM);
206 BCase(IMAGE_FILE_DLL);
207 BCase(IMAGE_FILE_UP_SYSTEM_ONLY);
208 BCase(IMAGE_FILE_BYTES_REVERSED_HI);
211 void ScalarBitSetTraits<COFF::SectionCharacteristics>::bitset(
212 IO &IO, COFF::SectionCharacteristics &Value) {
213 BCase(IMAGE_SCN_TYPE_NO_PAD);
214 BCase(IMAGE_SCN_CNT_CODE);
215 BCase(IMAGE_SCN_CNT_INITIALIZED_DATA);
216 BCase(IMAGE_SCN_CNT_UNINITIALIZED_DATA);
217 BCase(IMAGE_SCN_LNK_OTHER);
218 BCase(IMAGE_SCN_LNK_INFO);
219 BCase(IMAGE_SCN_LNK_REMOVE);
220 BCase(IMAGE_SCN_LNK_COMDAT);
221 BCase(IMAGE_SCN_GPREL);
222 BCase(IMAGE_SCN_MEM_PURGEABLE);
223 BCase(IMAGE_SCN_MEM_16BIT);
224 BCase(IMAGE_SCN_MEM_LOCKED);
225 BCase(IMAGE_SCN_MEM_PRELOAD);
226 BCase(IMAGE_SCN_LNK_NRELOC_OVFL);
227 BCase(IMAGE_SCN_MEM_DISCARDABLE);
228 BCase(IMAGE_SCN_MEM_NOT_CACHED);
229 BCase(IMAGE_SCN_MEM_NOT_PAGED);
230 BCase(IMAGE_SCN_MEM_SHARED);
231 BCase(IMAGE_SCN_MEM_EXECUTE);
232 BCase(IMAGE_SCN_MEM_READ);
233 BCase(IMAGE_SCN_MEM_WRITE);
236 void ScalarBitSetTraits<COFF::DLLCharacteristics>::bitset(
237 IO &IO, COFF::DLLCharacteristics &Value) {
238 BCase(IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA);
239 BCase(IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE);
240 BCase(IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY);
241 BCase(IMAGE_DLL_CHARACTERISTICS_NX_COMPAT);
242 BCase(IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION);
243 BCase(IMAGE_DLL_CHARACTERISTICS_NO_SEH);
244 BCase(IMAGE_DLL_CHARACTERISTICS_NO_BIND);
245 BCase(IMAGE_DLL_CHARACTERISTICS_APPCONTAINER);
246 BCase(IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER);
247 BCase(IMAGE_DLL_CHARACTERISTICS_GUARD_CF);
248 BCase(IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE);
253 struct NSectionSelectionType {
254 NSectionSelectionType(IO &)
255 : SelectionType(COFFYAML::COMDATType(0)) {}
256 NSectionSelectionType(IO &, uint8_t C)
257 : SelectionType(COFFYAML::COMDATType(C)) {}
258 uint8_t denormalize(IO &) { return SelectionType; }
259 COFFYAML::COMDATType SelectionType;
262 struct NWeakExternalCharacteristics {
263 NWeakExternalCharacteristics(IO &)
264 : Characteristics(COFFYAML::WeakExternalCharacteristics(0)) {}
265 NWeakExternalCharacteristics(IO &, uint32_t C)
266 : Characteristics(COFFYAML::WeakExternalCharacteristics(C)) {}
267 uint32_t denormalize(IO &) { return Characteristics; }
268 COFFYAML::WeakExternalCharacteristics Characteristics;
271 struct NSectionCharacteristics {
272 NSectionCharacteristics(IO &)
273 : Characteristics(COFF::SectionCharacteristics(0)) {}
274 NSectionCharacteristics(IO &, uint32_t C)
275 : Characteristics(COFF::SectionCharacteristics(C)) {}
276 uint32_t denormalize(IO &) { return Characteristics; }
277 COFF::SectionCharacteristics Characteristics;
280 struct NAuxTokenType {
282 : AuxType(COFFYAML::AuxSymbolType(0)) {}
283 NAuxTokenType(IO &, uint8_t C)
284 : AuxType(COFFYAML::AuxSymbolType(C)) {}
285 uint32_t denormalize(IO &) { return AuxType; }
286 COFFYAML::AuxSymbolType AuxType;
289 struct NStorageClass {
290 NStorageClass(IO &) : StorageClass(COFF::SymbolStorageClass(0)) {}
291 NStorageClass(IO &, uint8_t S) : StorageClass(COFF::SymbolStorageClass(S)) {}
292 uint8_t denormalize(IO &) { return StorageClass; }
294 COFF::SymbolStorageClass StorageClass;
298 NMachine(IO &) : Machine(COFF::MachineTypes(0)) {}
299 NMachine(IO &, uint16_t M) : Machine(COFF::MachineTypes(M)) {}
300 uint16_t denormalize(IO &) { return Machine; }
301 COFF::MachineTypes Machine;
304 struct NHeaderCharacteristics {
305 NHeaderCharacteristics(IO &) : Characteristics(COFF::Characteristics(0)) {}
306 NHeaderCharacteristics(IO &, uint16_t C)
307 : Characteristics(COFF::Characteristics(C)) {}
308 uint16_t denormalize(IO &) { return Characteristics; }
310 COFF::Characteristics Characteristics;
313 template <typename RelocType>
315 NType(IO &) : Type(RelocType(0)) {}
316 NType(IO &, uint16_t T) : Type(RelocType(T)) {}
317 uint16_t denormalize(IO &) { return Type; }
321 struct NWindowsSubsystem {
322 NWindowsSubsystem(IO &) : Subsystem(COFF::WindowsSubsystem(0)) {}
323 NWindowsSubsystem(IO &, uint16_t C) : Subsystem(COFF::WindowsSubsystem(C)) {}
324 uint16_t denormalize(IO &) { return Subsystem; }
326 COFF::WindowsSubsystem Subsystem;
329 struct NDLLCharacteristics {
330 NDLLCharacteristics(IO &) : Characteristics(COFF::DLLCharacteristics(0)) {}
331 NDLLCharacteristics(IO &, uint16_t C)
332 : Characteristics(COFF::DLLCharacteristics(C)) {}
333 uint16_t denormalize(IO &) { return Characteristics; }
335 COFF::DLLCharacteristics Characteristics;
340 void MappingTraits<COFFYAML::Relocation>::mapping(IO &IO,
341 COFFYAML::Relocation &Rel) {
342 IO.mapRequired("VirtualAddress", Rel.VirtualAddress);
343 IO.mapRequired("SymbolName", Rel.SymbolName);
345 COFF::header &H = *static_cast<COFF::header *>(IO.getContext());
346 if (H.Machine == COFF::IMAGE_FILE_MACHINE_I386) {
347 MappingNormalization<NType<COFF::RelocationTypeI386>, uint16_t> NT(
349 IO.mapRequired("Type", NT->Type);
350 } else if (H.Machine == COFF::IMAGE_FILE_MACHINE_AMD64) {
351 MappingNormalization<NType<COFF::RelocationTypeAMD64>, uint16_t> NT(
353 IO.mapRequired("Type", NT->Type);
355 IO.mapRequired("Type", Rel.Type);
359 void MappingTraits<COFF::DataDirectory>::mapping(IO &IO,
360 COFF::DataDirectory &DD) {
361 IO.mapRequired("RelativeVirtualAddress", DD.RelativeVirtualAddress);
362 IO.mapRequired("Size", DD.Size);
365 void MappingTraits<COFFYAML::PEHeader>::mapping(IO &IO,
366 COFFYAML::PEHeader &PH) {
367 MappingNormalization<NWindowsSubsystem, uint16_t> NWS(IO,
368 PH.Header.Subsystem);
369 MappingNormalization<NDLLCharacteristics, uint16_t> NDC(
370 IO, PH.Header.DLLCharacteristics);
372 IO.mapRequired("AddressOfEntryPoint", PH.Header.AddressOfEntryPoint);
373 IO.mapRequired("ImageBase", PH.Header.ImageBase);
374 IO.mapRequired("SectionAlignment", PH.Header.SectionAlignment);
375 IO.mapRequired("FileAlignment", PH.Header.FileAlignment);
376 IO.mapRequired("MajorOperatingSystemVersion",
377 PH.Header.MajorOperatingSystemVersion);
378 IO.mapRequired("MinorOperatingSystemVersion",
379 PH.Header.MinorOperatingSystemVersion);
380 IO.mapRequired("MajorImageVersion", PH.Header.MajorImageVersion);
381 IO.mapRequired("MinorImageVersion", PH.Header.MinorImageVersion);
382 IO.mapRequired("MajorSubsystemVersion", PH.Header.MajorSubsystemVersion);
383 IO.mapRequired("MinorSubsystemVersion", PH.Header.MinorSubsystemVersion);
384 IO.mapRequired("Subsystem", NWS->Subsystem);
385 IO.mapRequired("DLLCharacteristics", NDC->Characteristics);
386 IO.mapRequired("SizeOfStackReserve", PH.Header.SizeOfStackReserve);
387 IO.mapRequired("SizeOfStackCommit", PH.Header.SizeOfStackCommit);
388 IO.mapRequired("SizeOfHeapReserve", PH.Header.SizeOfHeapReserve);
389 IO.mapRequired("SizeOfHeapCommit", PH.Header.SizeOfHeapCommit);
391 IO.mapOptional("ExportTable", PH.DataDirectories[COFF::EXPORT_TABLE]);
392 IO.mapOptional("ImportTable", PH.DataDirectories[COFF::IMPORT_TABLE]);
393 IO.mapOptional("ResourceTable", PH.DataDirectories[COFF::RESOURCE_TABLE]);
394 IO.mapOptional("ExceptionTable", PH.DataDirectories[COFF::EXCEPTION_TABLE]);
395 IO.mapOptional("CertificateTable", PH.DataDirectories[COFF::CERTIFICATE_TABLE]);
396 IO.mapOptional("BaseRelocationTable",
397 PH.DataDirectories[COFF::BASE_RELOCATION_TABLE]);
398 IO.mapOptional("Debug", PH.DataDirectories[COFF::DEBUG]);
399 IO.mapOptional("Architecture", PH.DataDirectories[COFF::ARCHITECTURE]);
400 IO.mapOptional("GlobalPtr", PH.DataDirectories[COFF::GLOBAL_PTR]);
401 IO.mapOptional("TlsTable", PH.DataDirectories[COFF::TLS_TABLE]);
402 IO.mapOptional("LoadConfigTable",
403 PH.DataDirectories[COFF::LOAD_CONFIG_TABLE]);
404 IO.mapOptional("BoundImport", PH.DataDirectories[COFF::BOUND_IMPORT]);
405 IO.mapOptional("IAT", PH.DataDirectories[COFF::IAT]);
406 IO.mapOptional("DelayImportDescriptor",
407 PH.DataDirectories[COFF::DELAY_IMPORT_DESCRIPTOR]);
408 IO.mapOptional("ClrRuntimeHeader",
409 PH.DataDirectories[COFF::CLR_RUNTIME_HEADER]);
412 void MappingTraits<COFF::header>::mapping(IO &IO, COFF::header &H) {
413 MappingNormalization<NMachine, uint16_t> NM(IO, H.Machine);
414 MappingNormalization<NHeaderCharacteristics, uint16_t> NC(IO,
417 IO.mapRequired("Machine", NM->Machine);
418 IO.mapOptional("Characteristics", NC->Characteristics);
419 IO.setContext(static_cast<void *>(&H));
422 void MappingTraits<COFF::AuxiliaryFunctionDefinition>::mapping(
423 IO &IO, COFF::AuxiliaryFunctionDefinition &AFD) {
424 IO.mapRequired("TagIndex", AFD.TagIndex);
425 IO.mapRequired("TotalSize", AFD.TotalSize);
426 IO.mapRequired("PointerToLinenumber", AFD.PointerToLinenumber);
427 IO.mapRequired("PointerToNextFunction", AFD.PointerToNextFunction);
430 void MappingTraits<COFF::AuxiliarybfAndefSymbol>::mapping(
431 IO &IO, COFF::AuxiliarybfAndefSymbol &AAS) {
432 IO.mapRequired("Linenumber", AAS.Linenumber);
433 IO.mapRequired("PointerToNextFunction", AAS.PointerToNextFunction);
436 void MappingTraits<COFF::AuxiliaryWeakExternal>::mapping(
437 IO &IO, COFF::AuxiliaryWeakExternal &AWE) {
438 MappingNormalization<NWeakExternalCharacteristics, uint32_t> NWEC(
439 IO, AWE.Characteristics);
440 IO.mapRequired("TagIndex", AWE.TagIndex);
441 IO.mapRequired("Characteristics", NWEC->Characteristics);
444 void MappingTraits<COFF::AuxiliarySectionDefinition>::mapping(
445 IO &IO, COFF::AuxiliarySectionDefinition &ASD) {
446 MappingNormalization<NSectionSelectionType, uint8_t> NSST(
449 IO.mapRequired("Length", ASD.Length);
450 IO.mapRequired("NumberOfRelocations", ASD.NumberOfRelocations);
451 IO.mapRequired("NumberOfLinenumbers", ASD.NumberOfLinenumbers);
452 IO.mapRequired("CheckSum", ASD.CheckSum);
453 IO.mapRequired("Number", ASD.Number);
454 IO.mapOptional("Selection", NSST->SelectionType, COFFYAML::COMDATType(0));
457 void MappingTraits<COFF::AuxiliaryCLRToken>::mapping(
458 IO &IO, COFF::AuxiliaryCLRToken &ACT) {
459 MappingNormalization<NAuxTokenType, uint8_t> NATT(IO, ACT.AuxType);
460 IO.mapRequired("AuxType", NATT->AuxType);
461 IO.mapRequired("SymbolTableIndex", ACT.SymbolTableIndex);
464 void MappingTraits<COFFYAML::Symbol>::mapping(IO &IO, COFFYAML::Symbol &S) {
465 MappingNormalization<NStorageClass, uint8_t> NS(IO, S.Header.StorageClass);
467 IO.mapRequired("Name", S.Name);
468 IO.mapRequired("Value", S.Header.Value);
469 IO.mapRequired("SectionNumber", S.Header.SectionNumber);
470 IO.mapRequired("SimpleType", S.SimpleType);
471 IO.mapRequired("ComplexType", S.ComplexType);
472 IO.mapRequired("StorageClass", NS->StorageClass);
473 IO.mapOptional("FunctionDefinition", S.FunctionDefinition);
474 IO.mapOptional("bfAndefSymbol", S.bfAndefSymbol);
475 IO.mapOptional("WeakExternal", S.WeakExternal);
476 IO.mapOptional("File", S.File, StringRef());
477 IO.mapOptional("SectionDefinition", S.SectionDefinition);
478 IO.mapOptional("CLRToken", S.CLRToken);
481 void MappingTraits<COFFYAML::Section>::mapping(IO &IO, COFFYAML::Section &Sec) {
482 MappingNormalization<NSectionCharacteristics, uint32_t> NC(
483 IO, Sec.Header.Characteristics);
484 IO.mapRequired("Name", Sec.Name);
485 IO.mapRequired("Characteristics", NC->Characteristics);
486 IO.mapOptional("VirtualAddress", Sec.Header.VirtualAddress, 0U);
487 IO.mapOptional("VirtualSize", Sec.Header.VirtualSize, 0U);
488 IO.mapOptional("Alignment", Sec.Alignment);
489 IO.mapRequired("SectionData", Sec.SectionData);
490 IO.mapOptional("Relocations", Sec.Relocations);
493 void MappingTraits<COFFYAML::Object>::mapping(IO &IO, COFFYAML::Object &Obj) {
494 IO.mapOptional("OptionalHeader", Obj.OptionalHeader);
495 IO.mapRequired("header", Obj.Header);
496 IO.mapRequired("sections", Obj.Sections);
497 IO.mapRequired("symbols", Obj.Symbols);