xref: /minix3/external/bsd/llvm/dist/llvm/lib/Object/COFFYAML.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc //===- COFFYAML.cpp - COFF YAMLIO implementation --------------------------===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc // This file defines classes for handling the YAML representation of COFF.
11f4a2713aSLionel Sambuc //
12f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc #include "llvm/Object/COFFYAML.h"
15f4a2713aSLionel Sambuc 
16f4a2713aSLionel Sambuc #define ECase(X) IO.enumCase(Value, #X, COFF::X);
17f4a2713aSLionel Sambuc namespace llvm {
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc namespace COFFYAML {
Section()20f4a2713aSLionel Sambuc Section::Section() { memset(&Header, 0, sizeof(COFF::section)); }
Symbol()21f4a2713aSLionel Sambuc Symbol::Symbol() { memset(&Header, 0, sizeof(COFF::symbol)); }
Object()22f4a2713aSLionel Sambuc Object::Object() { memset(&Header, 0, sizeof(COFF::header)); }
23f4a2713aSLionel Sambuc }
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc namespace yaml {
enumeration(IO & IO,COFFYAML::COMDATType & Value)26*0a6a1f1dSLionel Sambuc void ScalarEnumerationTraits<COFFYAML::COMDATType>::enumeration(
27*0a6a1f1dSLionel Sambuc     IO &IO, COFFYAML::COMDATType &Value) {
28*0a6a1f1dSLionel Sambuc   IO.enumCase(Value, "0", 0);
29*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_NODUPLICATES);
30*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_ANY);
31*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_SAME_SIZE);
32*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_EXACT_MATCH);
33*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_ASSOCIATIVE);
34*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_LARGEST);
35*0a6a1f1dSLionel Sambuc   ECase(IMAGE_COMDAT_SELECT_NEWEST);
36*0a6a1f1dSLionel Sambuc }
37*0a6a1f1dSLionel Sambuc 
38*0a6a1f1dSLionel Sambuc void
enumeration(IO & IO,COFFYAML::WeakExternalCharacteristics & Value)39*0a6a1f1dSLionel Sambuc ScalarEnumerationTraits<COFFYAML::WeakExternalCharacteristics>::enumeration(
40*0a6a1f1dSLionel Sambuc     IO &IO, COFFYAML::WeakExternalCharacteristics &Value) {
41*0a6a1f1dSLionel Sambuc   IO.enumCase(Value, "0", 0);
42*0a6a1f1dSLionel Sambuc   ECase(IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY);
43*0a6a1f1dSLionel Sambuc   ECase(IMAGE_WEAK_EXTERN_SEARCH_LIBRARY);
44*0a6a1f1dSLionel Sambuc   ECase(IMAGE_WEAK_EXTERN_SEARCH_ALIAS);
45*0a6a1f1dSLionel Sambuc }
46*0a6a1f1dSLionel Sambuc 
enumeration(IO & IO,COFFYAML::AuxSymbolType & Value)47*0a6a1f1dSLionel Sambuc void ScalarEnumerationTraits<COFFYAML::AuxSymbolType>::enumeration(
48*0a6a1f1dSLionel Sambuc     IO &IO, COFFYAML::AuxSymbolType &Value) {
49*0a6a1f1dSLionel Sambuc   ECase(IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF);
50*0a6a1f1dSLionel Sambuc }
51*0a6a1f1dSLionel Sambuc 
enumeration(IO & IO,COFF::MachineTypes & Value)52f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::MachineTypes>::enumeration(
53f4a2713aSLionel Sambuc     IO &IO, COFF::MachineTypes &Value) {
54f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_UNKNOWN);
55f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_AM33);
56f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_AMD64);
57f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_ARM);
58*0a6a1f1dSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_ARMNT);
59f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_EBC);
60f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_I386);
61f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_IA64);
62f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_M32R);
63f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_MIPS16);
64f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_MIPSFPU);
65f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_MIPSFPU16);
66f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_POWERPC);
67f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_POWERPCFP);
68f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_R4000);
69f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH3);
70f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH3DSP);
71f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH4);
72f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH5);
73f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_THUMB);
74f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_WCEMIPSV2);
75f4a2713aSLionel Sambuc }
76f4a2713aSLionel Sambuc 
enumeration(IO & IO,COFF::SymbolBaseType & Value)77f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::SymbolBaseType>::enumeration(
78f4a2713aSLionel Sambuc     IO &IO, COFF::SymbolBaseType &Value) {
79f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_NULL);
80f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_VOID);
81f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_CHAR);
82f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_SHORT);
83f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_INT);
84f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_LONG);
85f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_FLOAT);
86f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_DOUBLE);
87f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_STRUCT);
88f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_UNION);
89f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_ENUM);
90f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_MOE);
91f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_BYTE);
92f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_WORD);
93f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_UINT);
94f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_DWORD);
95f4a2713aSLionel Sambuc }
96f4a2713aSLionel Sambuc 
enumeration(IO & IO,COFF::SymbolStorageClass & Value)97f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::SymbolStorageClass>::enumeration(
98f4a2713aSLionel Sambuc     IO &IO, COFF::SymbolStorageClass &Value) {
99f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_END_OF_FUNCTION);
100f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_NULL);
101f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_AUTOMATIC);
102f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_EXTERNAL);
103f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_STATIC);
104f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_REGISTER);
105f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_EXTERNAL_DEF);
106f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_LABEL);
107f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_UNDEFINED_LABEL);
108f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_MEMBER_OF_STRUCT);
109f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_ARGUMENT);
110f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_STRUCT_TAG);
111f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_MEMBER_OF_UNION);
112f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_UNION_TAG);
113f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_TYPE_DEFINITION);
114f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_UNDEFINED_STATIC);
115f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_ENUM_TAG);
116f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_MEMBER_OF_ENUM);
117f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_REGISTER_PARAM);
118f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_BIT_FIELD);
119f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_BLOCK);
120f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_FUNCTION);
121f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_END_OF_STRUCT);
122f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_FILE);
123f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_SECTION);
124f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_WEAK_EXTERNAL);
125f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_CLR_TOKEN);
126f4a2713aSLionel Sambuc }
127f4a2713aSLionel Sambuc 
enumeration(IO & IO,COFF::SymbolComplexType & Value)128f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::SymbolComplexType>::enumeration(
129f4a2713aSLionel Sambuc     IO &IO, COFF::SymbolComplexType &Value) {
130f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_NULL);
131f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_POINTER);
132f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_FUNCTION);
133f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_ARRAY);
134f4a2713aSLionel Sambuc }
135f4a2713aSLionel Sambuc 
enumeration(IO & IO,COFF::RelocationTypeI386 & Value)136*0a6a1f1dSLionel Sambuc void ScalarEnumerationTraits<COFF::RelocationTypeI386>::enumeration(
137*0a6a1f1dSLionel Sambuc     IO &IO, COFF::RelocationTypeI386 &Value) {
138f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_ABSOLUTE);
139f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_DIR16);
140f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_REL16);
141f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_DIR32);
142f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_DIR32NB);
143f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SEG12);
144f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SECTION);
145f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SECREL);
146f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_TOKEN);
147f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SECREL7);
148f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_REL32);
149*0a6a1f1dSLionel Sambuc }
150*0a6a1f1dSLionel Sambuc 
enumeration(IO & IO,COFF::RelocationTypeAMD64 & Value)151*0a6a1f1dSLionel Sambuc void ScalarEnumerationTraits<COFF::RelocationTypeAMD64>::enumeration(
152*0a6a1f1dSLionel Sambuc     IO &IO, COFF::RelocationTypeAMD64 &Value) {
153f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ABSOLUTE);
154f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ADDR64);
155f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ADDR32);
156f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ADDR32NB);
157f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32);
158f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_1);
159f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_2);
160f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_3);
161f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_4);
162f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_5);
163f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SECTION);
164f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SECREL);
165f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SECREL7);
166f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_TOKEN);
167f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SREL32);
168f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_PAIR);
169f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SSPAN32);
170f4a2713aSLionel Sambuc }
171*0a6a1f1dSLionel Sambuc 
enumeration(IO & IO,COFF::WindowsSubsystem & Value)172*0a6a1f1dSLionel Sambuc void ScalarEnumerationTraits<COFF::WindowsSubsystem>::enumeration(
173*0a6a1f1dSLionel Sambuc     IO &IO, COFF::WindowsSubsystem &Value) {
174*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_UNKNOWN);
175*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_NATIVE);
176*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_WINDOWS_GUI);
177*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_WINDOWS_CUI);
178*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_OS2_CUI);
179*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_POSIX_CUI);
180*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_NATIVE_WINDOWS);
181*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_WINDOWS_CE_GUI);
182*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_EFI_APPLICATION);
183*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER);
184*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER);
185*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_EFI_ROM);
186*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_XBOX);
187*0a6a1f1dSLionel Sambuc     ECase(IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION);
188*0a6a1f1dSLionel Sambuc }
189f4a2713aSLionel Sambuc #undef ECase
190f4a2713aSLionel Sambuc 
191f4a2713aSLionel Sambuc #define BCase(X) IO.bitSetCase(Value, #X, COFF::X);
bitset(IO & IO,COFF::Characteristics & Value)192f4a2713aSLionel Sambuc void ScalarBitSetTraits<COFF::Characteristics>::bitset(
193f4a2713aSLionel Sambuc     IO &IO, COFF::Characteristics &Value) {
194f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_RELOCS_STRIPPED);
195f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_EXECUTABLE_IMAGE);
196f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_LINE_NUMS_STRIPPED);
197f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_LOCAL_SYMS_STRIPPED);
198f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_AGGRESSIVE_WS_TRIM);
199f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_LARGE_ADDRESS_AWARE);
200f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_BYTES_REVERSED_LO);
201f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_32BIT_MACHINE);
202f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_DEBUG_STRIPPED);
203f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP);
204f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_NET_RUN_FROM_SWAP);
205f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_SYSTEM);
206f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_DLL);
207f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_UP_SYSTEM_ONLY);
208f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_BYTES_REVERSED_HI);
209f4a2713aSLionel Sambuc }
210f4a2713aSLionel Sambuc 
bitset(IO & IO,COFF::SectionCharacteristics & Value)211f4a2713aSLionel Sambuc void ScalarBitSetTraits<COFF::SectionCharacteristics>::bitset(
212f4a2713aSLionel Sambuc     IO &IO, COFF::SectionCharacteristics &Value) {
213f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_TYPE_NO_PAD);
214f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_CNT_CODE);
215f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_CNT_INITIALIZED_DATA);
216f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_CNT_UNINITIALIZED_DATA);
217f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_OTHER);
218f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_INFO);
219f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_REMOVE);
220f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_COMDAT);
221f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_GPREL);
222f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_PURGEABLE);
223f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_16BIT);
224f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_LOCKED);
225f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_PRELOAD);
226f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_NRELOC_OVFL);
227f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_DISCARDABLE);
228f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_NOT_CACHED);
229f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_NOT_PAGED);
230f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_SHARED);
231f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_EXECUTE);
232f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_READ);
233f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_WRITE);
234f4a2713aSLionel Sambuc }
235*0a6a1f1dSLionel Sambuc 
bitset(IO & IO,COFF::DLLCharacteristics & Value)236*0a6a1f1dSLionel Sambuc void ScalarBitSetTraits<COFF::DLLCharacteristics>::bitset(
237*0a6a1f1dSLionel Sambuc     IO &IO, COFF::DLLCharacteristics &Value) {
238*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA);
239*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE);
240*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY);
241*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_NX_COMPAT);
242*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION);
243*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_NO_SEH);
244*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_NO_BIND);
245*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_APPCONTAINER);
246*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER);
247*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_GUARD_CF);
248*0a6a1f1dSLionel Sambuc   BCase(IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE);
249*0a6a1f1dSLionel Sambuc }
250f4a2713aSLionel Sambuc #undef BCase
251f4a2713aSLionel Sambuc 
252f4a2713aSLionel Sambuc namespace {
253*0a6a1f1dSLionel Sambuc struct NSectionSelectionType {
NSectionSelectionTypellvm::yaml::__anon1fe3e13a0111::NSectionSelectionType254*0a6a1f1dSLionel Sambuc   NSectionSelectionType(IO &)
255*0a6a1f1dSLionel Sambuc       : SelectionType(COFFYAML::COMDATType(0)) {}
NSectionSelectionTypellvm::yaml::__anon1fe3e13a0111::NSectionSelectionType256*0a6a1f1dSLionel Sambuc   NSectionSelectionType(IO &, uint8_t C)
257*0a6a1f1dSLionel Sambuc       : SelectionType(COFFYAML::COMDATType(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NSectionSelectionType258*0a6a1f1dSLionel Sambuc   uint8_t denormalize(IO &) { return SelectionType; }
259*0a6a1f1dSLionel Sambuc   COFFYAML::COMDATType SelectionType;
260*0a6a1f1dSLionel Sambuc };
261*0a6a1f1dSLionel Sambuc 
262*0a6a1f1dSLionel Sambuc struct NWeakExternalCharacteristics {
NWeakExternalCharacteristicsllvm::yaml::__anon1fe3e13a0111::NWeakExternalCharacteristics263*0a6a1f1dSLionel Sambuc   NWeakExternalCharacteristics(IO &)
264*0a6a1f1dSLionel Sambuc       : Characteristics(COFFYAML::WeakExternalCharacteristics(0)) {}
NWeakExternalCharacteristicsllvm::yaml::__anon1fe3e13a0111::NWeakExternalCharacteristics265*0a6a1f1dSLionel Sambuc   NWeakExternalCharacteristics(IO &, uint32_t C)
266*0a6a1f1dSLionel Sambuc       : Characteristics(COFFYAML::WeakExternalCharacteristics(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NWeakExternalCharacteristics267*0a6a1f1dSLionel Sambuc   uint32_t denormalize(IO &) { return Characteristics; }
268*0a6a1f1dSLionel Sambuc   COFFYAML::WeakExternalCharacteristics Characteristics;
269*0a6a1f1dSLionel Sambuc };
270*0a6a1f1dSLionel Sambuc 
271f4a2713aSLionel Sambuc struct NSectionCharacteristics {
NSectionCharacteristicsllvm::yaml::__anon1fe3e13a0111::NSectionCharacteristics272f4a2713aSLionel Sambuc   NSectionCharacteristics(IO &)
273f4a2713aSLionel Sambuc       : Characteristics(COFF::SectionCharacteristics(0)) {}
NSectionCharacteristicsllvm::yaml::__anon1fe3e13a0111::NSectionCharacteristics274f4a2713aSLionel Sambuc   NSectionCharacteristics(IO &, uint32_t C)
275f4a2713aSLionel Sambuc       : Characteristics(COFF::SectionCharacteristics(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NSectionCharacteristics276f4a2713aSLionel Sambuc   uint32_t denormalize(IO &) { return Characteristics; }
277f4a2713aSLionel Sambuc   COFF::SectionCharacteristics Characteristics;
278f4a2713aSLionel Sambuc };
279f4a2713aSLionel Sambuc 
280*0a6a1f1dSLionel Sambuc struct NAuxTokenType {
NAuxTokenTypellvm::yaml::__anon1fe3e13a0111::NAuxTokenType281*0a6a1f1dSLionel Sambuc   NAuxTokenType(IO &)
282*0a6a1f1dSLionel Sambuc       : AuxType(COFFYAML::AuxSymbolType(0)) {}
NAuxTokenTypellvm::yaml::__anon1fe3e13a0111::NAuxTokenType283*0a6a1f1dSLionel Sambuc   NAuxTokenType(IO &, uint8_t C)
284*0a6a1f1dSLionel Sambuc       : AuxType(COFFYAML::AuxSymbolType(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NAuxTokenType285*0a6a1f1dSLionel Sambuc   uint32_t denormalize(IO &) { return AuxType; }
286*0a6a1f1dSLionel Sambuc   COFFYAML::AuxSymbolType AuxType;
287*0a6a1f1dSLionel Sambuc };
288*0a6a1f1dSLionel Sambuc 
289f4a2713aSLionel Sambuc struct NStorageClass {
NStorageClassllvm::yaml::__anon1fe3e13a0111::NStorageClass290f4a2713aSLionel Sambuc   NStorageClass(IO &) : StorageClass(COFF::SymbolStorageClass(0)) {}
NStorageClassllvm::yaml::__anon1fe3e13a0111::NStorageClass291f4a2713aSLionel Sambuc   NStorageClass(IO &, uint8_t S) : StorageClass(COFF::SymbolStorageClass(S)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NStorageClass292f4a2713aSLionel Sambuc   uint8_t denormalize(IO &) { return StorageClass; }
293f4a2713aSLionel Sambuc 
294f4a2713aSLionel Sambuc   COFF::SymbolStorageClass StorageClass;
295f4a2713aSLionel Sambuc };
296f4a2713aSLionel Sambuc 
297f4a2713aSLionel Sambuc struct NMachine {
NMachinellvm::yaml::__anon1fe3e13a0111::NMachine298f4a2713aSLionel Sambuc   NMachine(IO &) : Machine(COFF::MachineTypes(0)) {}
NMachinellvm::yaml::__anon1fe3e13a0111::NMachine299f4a2713aSLionel Sambuc   NMachine(IO &, uint16_t M) : Machine(COFF::MachineTypes(M)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NMachine300f4a2713aSLionel Sambuc   uint16_t denormalize(IO &) { return Machine; }
301f4a2713aSLionel Sambuc   COFF::MachineTypes Machine;
302f4a2713aSLionel Sambuc };
303f4a2713aSLionel Sambuc 
304f4a2713aSLionel Sambuc struct NHeaderCharacteristics {
NHeaderCharacteristicsllvm::yaml::__anon1fe3e13a0111::NHeaderCharacteristics305f4a2713aSLionel Sambuc   NHeaderCharacteristics(IO &) : Characteristics(COFF::Characteristics(0)) {}
NHeaderCharacteristicsllvm::yaml::__anon1fe3e13a0111::NHeaderCharacteristics306f4a2713aSLionel Sambuc   NHeaderCharacteristics(IO &, uint16_t C)
307f4a2713aSLionel Sambuc       : Characteristics(COFF::Characteristics(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NHeaderCharacteristics308f4a2713aSLionel Sambuc   uint16_t denormalize(IO &) { return Characteristics; }
309f4a2713aSLionel Sambuc 
310f4a2713aSLionel Sambuc   COFF::Characteristics Characteristics;
311f4a2713aSLionel Sambuc };
312f4a2713aSLionel Sambuc 
313*0a6a1f1dSLionel Sambuc template <typename RelocType>
314f4a2713aSLionel Sambuc struct NType {
NTypellvm::yaml::__anon1fe3e13a0111::NType315*0a6a1f1dSLionel Sambuc   NType(IO &) : Type(RelocType(0)) {}
NTypellvm::yaml::__anon1fe3e13a0111::NType316*0a6a1f1dSLionel Sambuc   NType(IO &, uint16_t T) : Type(RelocType(T)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NType317f4a2713aSLionel Sambuc   uint16_t denormalize(IO &) { return Type; }
318*0a6a1f1dSLionel Sambuc   RelocType Type;
319*0a6a1f1dSLionel Sambuc };
320*0a6a1f1dSLionel Sambuc 
321*0a6a1f1dSLionel Sambuc struct NWindowsSubsystem {
NWindowsSubsystemllvm::yaml::__anon1fe3e13a0111::NWindowsSubsystem322*0a6a1f1dSLionel Sambuc   NWindowsSubsystem(IO &) : Subsystem(COFF::WindowsSubsystem(0)) {}
NWindowsSubsystemllvm::yaml::__anon1fe3e13a0111::NWindowsSubsystem323*0a6a1f1dSLionel Sambuc   NWindowsSubsystem(IO &, uint16_t C) : Subsystem(COFF::WindowsSubsystem(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NWindowsSubsystem324*0a6a1f1dSLionel Sambuc   uint16_t denormalize(IO &) { return Subsystem; }
325*0a6a1f1dSLionel Sambuc 
326*0a6a1f1dSLionel Sambuc   COFF::WindowsSubsystem Subsystem;
327*0a6a1f1dSLionel Sambuc };
328*0a6a1f1dSLionel Sambuc 
329*0a6a1f1dSLionel Sambuc struct NDLLCharacteristics {
NDLLCharacteristicsllvm::yaml::__anon1fe3e13a0111::NDLLCharacteristics330*0a6a1f1dSLionel Sambuc   NDLLCharacteristics(IO &) : Characteristics(COFF::DLLCharacteristics(0)) {}
NDLLCharacteristicsllvm::yaml::__anon1fe3e13a0111::NDLLCharacteristics331*0a6a1f1dSLionel Sambuc   NDLLCharacteristics(IO &, uint16_t C)
332*0a6a1f1dSLionel Sambuc       : Characteristics(COFF::DLLCharacteristics(C)) {}
denormalizellvm::yaml::__anon1fe3e13a0111::NDLLCharacteristics333*0a6a1f1dSLionel Sambuc   uint16_t denormalize(IO &) { return Characteristics; }
334*0a6a1f1dSLionel Sambuc 
335*0a6a1f1dSLionel Sambuc   COFF::DLLCharacteristics Characteristics;
336f4a2713aSLionel Sambuc };
337f4a2713aSLionel Sambuc 
338f4a2713aSLionel Sambuc }
339f4a2713aSLionel Sambuc 
mapping(IO & IO,COFFYAML::Relocation & Rel)340f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Relocation>::mapping(IO &IO,
341f4a2713aSLionel Sambuc                                                   COFFYAML::Relocation &Rel) {
342f4a2713aSLionel Sambuc   IO.mapRequired("VirtualAddress", Rel.VirtualAddress);
343f4a2713aSLionel Sambuc   IO.mapRequired("SymbolName", Rel.SymbolName);
344*0a6a1f1dSLionel Sambuc 
345*0a6a1f1dSLionel Sambuc   COFF::header &H = *static_cast<COFF::header *>(IO.getContext());
346*0a6a1f1dSLionel Sambuc   if (H.Machine == COFF::IMAGE_FILE_MACHINE_I386) {
347*0a6a1f1dSLionel Sambuc     MappingNormalization<NType<COFF::RelocationTypeI386>, uint16_t> NT(
348*0a6a1f1dSLionel Sambuc         IO, Rel.Type);
349f4a2713aSLionel Sambuc     IO.mapRequired("Type", NT->Type);
350*0a6a1f1dSLionel Sambuc   } else if (H.Machine == COFF::IMAGE_FILE_MACHINE_AMD64) {
351*0a6a1f1dSLionel Sambuc     MappingNormalization<NType<COFF::RelocationTypeAMD64>, uint16_t> NT(
352*0a6a1f1dSLionel Sambuc         IO, Rel.Type);
353*0a6a1f1dSLionel Sambuc     IO.mapRequired("Type", NT->Type);
354*0a6a1f1dSLionel Sambuc   } else {
355*0a6a1f1dSLionel Sambuc     IO.mapRequired("Type", Rel.Type);
356*0a6a1f1dSLionel Sambuc   }
357*0a6a1f1dSLionel Sambuc }
358*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFF::DataDirectory & DD)359*0a6a1f1dSLionel Sambuc void MappingTraits<COFF::DataDirectory>::mapping(IO &IO,
360*0a6a1f1dSLionel Sambuc                                                  COFF::DataDirectory &DD) {
361*0a6a1f1dSLionel Sambuc   IO.mapRequired("RelativeVirtualAddress", DD.RelativeVirtualAddress);
362*0a6a1f1dSLionel Sambuc   IO.mapRequired("Size", DD.Size);
363*0a6a1f1dSLionel Sambuc }
364*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFFYAML::PEHeader & PH)365*0a6a1f1dSLionel Sambuc void MappingTraits<COFFYAML::PEHeader>::mapping(IO &IO,
366*0a6a1f1dSLionel Sambuc                                                 COFFYAML::PEHeader &PH) {
367*0a6a1f1dSLionel Sambuc   MappingNormalization<NWindowsSubsystem, uint16_t> NWS(IO,
368*0a6a1f1dSLionel Sambuc                                                         PH.Header.Subsystem);
369*0a6a1f1dSLionel Sambuc   MappingNormalization<NDLLCharacteristics, uint16_t> NDC(
370*0a6a1f1dSLionel Sambuc       IO, PH.Header.DLLCharacteristics);
371*0a6a1f1dSLionel Sambuc 
372*0a6a1f1dSLionel Sambuc   IO.mapRequired("AddressOfEntryPoint", PH.Header.AddressOfEntryPoint);
373*0a6a1f1dSLionel Sambuc   IO.mapRequired("ImageBase", PH.Header.ImageBase);
374*0a6a1f1dSLionel Sambuc   IO.mapRequired("SectionAlignment", PH.Header.SectionAlignment);
375*0a6a1f1dSLionel Sambuc   IO.mapRequired("FileAlignment", PH.Header.FileAlignment);
376*0a6a1f1dSLionel Sambuc   IO.mapRequired("MajorOperatingSystemVersion",
377*0a6a1f1dSLionel Sambuc                  PH.Header.MajorOperatingSystemVersion);
378*0a6a1f1dSLionel Sambuc   IO.mapRequired("MinorOperatingSystemVersion",
379*0a6a1f1dSLionel Sambuc                  PH.Header.MinorOperatingSystemVersion);
380*0a6a1f1dSLionel Sambuc   IO.mapRequired("MajorImageVersion", PH.Header.MajorImageVersion);
381*0a6a1f1dSLionel Sambuc   IO.mapRequired("MinorImageVersion", PH.Header.MinorImageVersion);
382*0a6a1f1dSLionel Sambuc   IO.mapRequired("MajorSubsystemVersion", PH.Header.MajorSubsystemVersion);
383*0a6a1f1dSLionel Sambuc   IO.mapRequired("MinorSubsystemVersion", PH.Header.MinorSubsystemVersion);
384*0a6a1f1dSLionel Sambuc   IO.mapRequired("Subsystem", NWS->Subsystem);
385*0a6a1f1dSLionel Sambuc   IO.mapRequired("DLLCharacteristics", NDC->Characteristics);
386*0a6a1f1dSLionel Sambuc   IO.mapRequired("SizeOfStackReserve", PH.Header.SizeOfStackReserve);
387*0a6a1f1dSLionel Sambuc   IO.mapRequired("SizeOfStackCommit", PH.Header.SizeOfStackCommit);
388*0a6a1f1dSLionel Sambuc   IO.mapRequired("SizeOfHeapReserve", PH.Header.SizeOfHeapReserve);
389*0a6a1f1dSLionel Sambuc   IO.mapRequired("SizeOfHeapCommit", PH.Header.SizeOfHeapCommit);
390*0a6a1f1dSLionel Sambuc 
391*0a6a1f1dSLionel Sambuc   IO.mapOptional("ExportTable", PH.DataDirectories[COFF::EXPORT_TABLE]);
392*0a6a1f1dSLionel Sambuc   IO.mapOptional("ImportTable", PH.DataDirectories[COFF::IMPORT_TABLE]);
393*0a6a1f1dSLionel Sambuc   IO.mapOptional("ResourceTable", PH.DataDirectories[COFF::RESOURCE_TABLE]);
394*0a6a1f1dSLionel Sambuc   IO.mapOptional("ExceptionTable", PH.DataDirectories[COFF::EXCEPTION_TABLE]);
395*0a6a1f1dSLionel Sambuc   IO.mapOptional("CertificateTable", PH.DataDirectories[COFF::CERTIFICATE_TABLE]);
396*0a6a1f1dSLionel Sambuc   IO.mapOptional("BaseRelocationTable",
397*0a6a1f1dSLionel Sambuc                  PH.DataDirectories[COFF::BASE_RELOCATION_TABLE]);
398*0a6a1f1dSLionel Sambuc   IO.mapOptional("Debug", PH.DataDirectories[COFF::DEBUG]);
399*0a6a1f1dSLionel Sambuc   IO.mapOptional("Architecture", PH.DataDirectories[COFF::ARCHITECTURE]);
400*0a6a1f1dSLionel Sambuc   IO.mapOptional("GlobalPtr", PH.DataDirectories[COFF::GLOBAL_PTR]);
401*0a6a1f1dSLionel Sambuc   IO.mapOptional("TlsTable", PH.DataDirectories[COFF::TLS_TABLE]);
402*0a6a1f1dSLionel Sambuc   IO.mapOptional("LoadConfigTable",
403*0a6a1f1dSLionel Sambuc                  PH.DataDirectories[COFF::LOAD_CONFIG_TABLE]);
404*0a6a1f1dSLionel Sambuc   IO.mapOptional("BoundImport", PH.DataDirectories[COFF::BOUND_IMPORT]);
405*0a6a1f1dSLionel Sambuc   IO.mapOptional("IAT", PH.DataDirectories[COFF::IAT]);
406*0a6a1f1dSLionel Sambuc   IO.mapOptional("DelayImportDescriptor",
407*0a6a1f1dSLionel Sambuc                  PH.DataDirectories[COFF::DELAY_IMPORT_DESCRIPTOR]);
408*0a6a1f1dSLionel Sambuc   IO.mapOptional("ClrRuntimeHeader",
409*0a6a1f1dSLionel Sambuc                  PH.DataDirectories[COFF::CLR_RUNTIME_HEADER]);
410f4a2713aSLionel Sambuc }
411f4a2713aSLionel Sambuc 
mapping(IO & IO,COFF::header & H)412f4a2713aSLionel Sambuc void MappingTraits<COFF::header>::mapping(IO &IO, COFF::header &H) {
413f4a2713aSLionel Sambuc   MappingNormalization<NMachine, uint16_t> NM(IO, H.Machine);
414f4a2713aSLionel Sambuc   MappingNormalization<NHeaderCharacteristics, uint16_t> NC(IO,
415f4a2713aSLionel Sambuc                                                             H.Characteristics);
416f4a2713aSLionel Sambuc 
417f4a2713aSLionel Sambuc   IO.mapRequired("Machine", NM->Machine);
418f4a2713aSLionel Sambuc   IO.mapOptional("Characteristics", NC->Characteristics);
419*0a6a1f1dSLionel Sambuc   IO.setContext(static_cast<void *>(&H));
420*0a6a1f1dSLionel Sambuc }
421*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFF::AuxiliaryFunctionDefinition & AFD)422*0a6a1f1dSLionel Sambuc void MappingTraits<COFF::AuxiliaryFunctionDefinition>::mapping(
423*0a6a1f1dSLionel Sambuc     IO &IO, COFF::AuxiliaryFunctionDefinition &AFD) {
424*0a6a1f1dSLionel Sambuc   IO.mapRequired("TagIndex", AFD.TagIndex);
425*0a6a1f1dSLionel Sambuc   IO.mapRequired("TotalSize", AFD.TotalSize);
426*0a6a1f1dSLionel Sambuc   IO.mapRequired("PointerToLinenumber", AFD.PointerToLinenumber);
427*0a6a1f1dSLionel Sambuc   IO.mapRequired("PointerToNextFunction", AFD.PointerToNextFunction);
428*0a6a1f1dSLionel Sambuc }
429*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFF::AuxiliarybfAndefSymbol & AAS)430*0a6a1f1dSLionel Sambuc void MappingTraits<COFF::AuxiliarybfAndefSymbol>::mapping(
431*0a6a1f1dSLionel Sambuc     IO &IO, COFF::AuxiliarybfAndefSymbol &AAS) {
432*0a6a1f1dSLionel Sambuc   IO.mapRequired("Linenumber", AAS.Linenumber);
433*0a6a1f1dSLionel Sambuc   IO.mapRequired("PointerToNextFunction", AAS.PointerToNextFunction);
434*0a6a1f1dSLionel Sambuc }
435*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFF::AuxiliaryWeakExternal & AWE)436*0a6a1f1dSLionel Sambuc void MappingTraits<COFF::AuxiliaryWeakExternal>::mapping(
437*0a6a1f1dSLionel Sambuc     IO &IO, COFF::AuxiliaryWeakExternal &AWE) {
438*0a6a1f1dSLionel Sambuc   MappingNormalization<NWeakExternalCharacteristics, uint32_t> NWEC(
439*0a6a1f1dSLionel Sambuc       IO, AWE.Characteristics);
440*0a6a1f1dSLionel Sambuc   IO.mapRequired("TagIndex", AWE.TagIndex);
441*0a6a1f1dSLionel Sambuc   IO.mapRequired("Characteristics", NWEC->Characteristics);
442*0a6a1f1dSLionel Sambuc }
443*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFF::AuxiliarySectionDefinition & ASD)444*0a6a1f1dSLionel Sambuc void MappingTraits<COFF::AuxiliarySectionDefinition>::mapping(
445*0a6a1f1dSLionel Sambuc     IO &IO, COFF::AuxiliarySectionDefinition &ASD) {
446*0a6a1f1dSLionel Sambuc   MappingNormalization<NSectionSelectionType, uint8_t> NSST(
447*0a6a1f1dSLionel Sambuc       IO, ASD.Selection);
448*0a6a1f1dSLionel Sambuc 
449*0a6a1f1dSLionel Sambuc   IO.mapRequired("Length", ASD.Length);
450*0a6a1f1dSLionel Sambuc   IO.mapRequired("NumberOfRelocations", ASD.NumberOfRelocations);
451*0a6a1f1dSLionel Sambuc   IO.mapRequired("NumberOfLinenumbers", ASD.NumberOfLinenumbers);
452*0a6a1f1dSLionel Sambuc   IO.mapRequired("CheckSum", ASD.CheckSum);
453*0a6a1f1dSLionel Sambuc   IO.mapRequired("Number", ASD.Number);
454*0a6a1f1dSLionel Sambuc   IO.mapOptional("Selection", NSST->SelectionType, COFFYAML::COMDATType(0));
455*0a6a1f1dSLionel Sambuc }
456*0a6a1f1dSLionel Sambuc 
mapping(IO & IO,COFF::AuxiliaryCLRToken & ACT)457*0a6a1f1dSLionel Sambuc void MappingTraits<COFF::AuxiliaryCLRToken>::mapping(
458*0a6a1f1dSLionel Sambuc     IO &IO, COFF::AuxiliaryCLRToken &ACT) {
459*0a6a1f1dSLionel Sambuc   MappingNormalization<NAuxTokenType, uint8_t> NATT(IO, ACT.AuxType);
460*0a6a1f1dSLionel Sambuc   IO.mapRequired("AuxType", NATT->AuxType);
461*0a6a1f1dSLionel Sambuc   IO.mapRequired("SymbolTableIndex", ACT.SymbolTableIndex);
462f4a2713aSLionel Sambuc }
463f4a2713aSLionel Sambuc 
mapping(IO & IO,COFFYAML::Symbol & S)464f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Symbol>::mapping(IO &IO, COFFYAML::Symbol &S) {
465f4a2713aSLionel Sambuc   MappingNormalization<NStorageClass, uint8_t> NS(IO, S.Header.StorageClass);
466f4a2713aSLionel Sambuc 
467f4a2713aSLionel Sambuc   IO.mapRequired("Name", S.Name);
468f4a2713aSLionel Sambuc   IO.mapRequired("Value", S.Header.Value);
469f4a2713aSLionel Sambuc   IO.mapRequired("SectionNumber", S.Header.SectionNumber);
470f4a2713aSLionel Sambuc   IO.mapRequired("SimpleType", S.SimpleType);
471f4a2713aSLionel Sambuc   IO.mapRequired("ComplexType", S.ComplexType);
472f4a2713aSLionel Sambuc   IO.mapRequired("StorageClass", NS->StorageClass);
473*0a6a1f1dSLionel Sambuc   IO.mapOptional("FunctionDefinition", S.FunctionDefinition);
474*0a6a1f1dSLionel Sambuc   IO.mapOptional("bfAndefSymbol", S.bfAndefSymbol);
475*0a6a1f1dSLionel Sambuc   IO.mapOptional("WeakExternal", S.WeakExternal);
476*0a6a1f1dSLionel Sambuc   IO.mapOptional("File", S.File, StringRef());
477*0a6a1f1dSLionel Sambuc   IO.mapOptional("SectionDefinition", S.SectionDefinition);
478*0a6a1f1dSLionel Sambuc   IO.mapOptional("CLRToken", S.CLRToken);
479f4a2713aSLionel Sambuc }
480f4a2713aSLionel Sambuc 
mapping(IO & IO,COFFYAML::Section & Sec)481f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Section>::mapping(IO &IO, COFFYAML::Section &Sec) {
482f4a2713aSLionel Sambuc   MappingNormalization<NSectionCharacteristics, uint32_t> NC(
483f4a2713aSLionel Sambuc       IO, Sec.Header.Characteristics);
484f4a2713aSLionel Sambuc   IO.mapRequired("Name", Sec.Name);
485f4a2713aSLionel Sambuc   IO.mapRequired("Characteristics", NC->Characteristics);
486*0a6a1f1dSLionel Sambuc   IO.mapOptional("VirtualAddress", Sec.Header.VirtualAddress, 0U);
487*0a6a1f1dSLionel Sambuc   IO.mapOptional("VirtualSize", Sec.Header.VirtualSize, 0U);
488f4a2713aSLionel Sambuc   IO.mapOptional("Alignment", Sec.Alignment);
489f4a2713aSLionel Sambuc   IO.mapRequired("SectionData", Sec.SectionData);
490f4a2713aSLionel Sambuc   IO.mapOptional("Relocations", Sec.Relocations);
491f4a2713aSLionel Sambuc }
492f4a2713aSLionel Sambuc 
mapping(IO & IO,COFFYAML::Object & Obj)493f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Object>::mapping(IO &IO, COFFYAML::Object &Obj) {
494*0a6a1f1dSLionel Sambuc   IO.mapOptional("OptionalHeader", Obj.OptionalHeader);
495f4a2713aSLionel Sambuc   IO.mapRequired("header", Obj.Header);
496f4a2713aSLionel Sambuc   IO.mapRequired("sections", Obj.Sections);
497f4a2713aSLionel Sambuc   IO.mapRequired("symbols", Obj.Symbols);
498f4a2713aSLionel Sambuc }
499f4a2713aSLionel Sambuc 
500f4a2713aSLionel Sambuc }
501f4a2713aSLionel Sambuc }
502