xref: /minix3/external/bsd/llvm/dist/llvm/lib/Object/COFFYAML.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc //===- COFFYAML.cpp - COFF YAMLIO implementation --------------------------===//
2*f4a2713aSLionel Sambuc //
3*f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4*f4a2713aSLionel Sambuc //
5*f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6*f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7*f4a2713aSLionel Sambuc //
8*f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9*f4a2713aSLionel Sambuc //
10*f4a2713aSLionel Sambuc // This file defines classes for handling the YAML representation of COFF.
11*f4a2713aSLionel Sambuc //
12*f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc #include "llvm/Object/COFFYAML.h"
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc #define ECase(X) IO.enumCase(Value, #X, COFF::X);
17*f4a2713aSLionel Sambuc namespace llvm {
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc namespace COFFYAML {
20*f4a2713aSLionel Sambuc Section::Section() { memset(&Header, 0, sizeof(COFF::section)); }
21*f4a2713aSLionel Sambuc Symbol::Symbol() { memset(&Header, 0, sizeof(COFF::symbol)); }
22*f4a2713aSLionel Sambuc Object::Object() { memset(&Header, 0, sizeof(COFF::header)); }
23*f4a2713aSLionel Sambuc }
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc namespace yaml {
26*f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::MachineTypes>::enumeration(
27*f4a2713aSLionel Sambuc     IO &IO, COFF::MachineTypes &Value) {
28*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_UNKNOWN);
29*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_AM33);
30*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_AMD64);
31*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_ARM);
32*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_ARMV7);
33*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_EBC);
34*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_I386);
35*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_IA64);
36*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_M32R);
37*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_MIPS16);
38*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_MIPSFPU);
39*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_MIPSFPU16);
40*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_POWERPC);
41*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_POWERPCFP);
42*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_R4000);
43*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH3);
44*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH3DSP);
45*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH4);
46*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_SH5);
47*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_THUMB);
48*f4a2713aSLionel Sambuc   ECase(IMAGE_FILE_MACHINE_WCEMIPSV2);
49*f4a2713aSLionel Sambuc }
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::SymbolBaseType>::enumeration(
52*f4a2713aSLionel Sambuc     IO &IO, COFF::SymbolBaseType &Value) {
53*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_NULL);
54*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_VOID);
55*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_CHAR);
56*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_SHORT);
57*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_INT);
58*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_LONG);
59*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_FLOAT);
60*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_DOUBLE);
61*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_STRUCT);
62*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_UNION);
63*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_ENUM);
64*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_MOE);
65*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_BYTE);
66*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_WORD);
67*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_UINT);
68*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_TYPE_DWORD);
69*f4a2713aSLionel Sambuc }
70*f4a2713aSLionel Sambuc 
71*f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::SymbolStorageClass>::enumeration(
72*f4a2713aSLionel Sambuc     IO &IO, COFF::SymbolStorageClass &Value) {
73*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_END_OF_FUNCTION);
74*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_NULL);
75*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_AUTOMATIC);
76*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_EXTERNAL);
77*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_STATIC);
78*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_REGISTER);
79*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_EXTERNAL_DEF);
80*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_LABEL);
81*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_UNDEFINED_LABEL);
82*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_MEMBER_OF_STRUCT);
83*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_ARGUMENT);
84*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_STRUCT_TAG);
85*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_MEMBER_OF_UNION);
86*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_UNION_TAG);
87*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_TYPE_DEFINITION);
88*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_UNDEFINED_STATIC);
89*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_ENUM_TAG);
90*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_MEMBER_OF_ENUM);
91*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_REGISTER_PARAM);
92*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_BIT_FIELD);
93*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_BLOCK);
94*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_FUNCTION);
95*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_END_OF_STRUCT);
96*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_FILE);
97*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_SECTION);
98*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_WEAK_EXTERNAL);
99*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_CLASS_CLR_TOKEN);
100*f4a2713aSLionel Sambuc }
101*f4a2713aSLionel Sambuc 
102*f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::SymbolComplexType>::enumeration(
103*f4a2713aSLionel Sambuc     IO &IO, COFF::SymbolComplexType &Value) {
104*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_NULL);
105*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_POINTER);
106*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_FUNCTION);
107*f4a2713aSLionel Sambuc   ECase(IMAGE_SYM_DTYPE_ARRAY);
108*f4a2713aSLionel Sambuc }
109*f4a2713aSLionel Sambuc 
110*f4a2713aSLionel Sambuc void ScalarEnumerationTraits<COFF::RelocationTypeX86>::enumeration(
111*f4a2713aSLionel Sambuc     IO &IO, COFF::RelocationTypeX86 &Value) {
112*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_ABSOLUTE);
113*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_DIR16);
114*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_REL16);
115*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_DIR32);
116*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_DIR32NB);
117*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SEG12);
118*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SECTION);
119*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SECREL);
120*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_TOKEN);
121*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_SECREL7);
122*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_I386_REL32);
123*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ABSOLUTE);
124*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ADDR64);
125*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ADDR32);
126*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_ADDR32NB);
127*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32);
128*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_1);
129*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_2);
130*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_3);
131*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_4);
132*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_REL32_5);
133*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SECTION);
134*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SECREL);
135*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SECREL7);
136*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_TOKEN);
137*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SREL32);
138*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_PAIR);
139*f4a2713aSLionel Sambuc   ECase(IMAGE_REL_AMD64_SSPAN32);
140*f4a2713aSLionel Sambuc }
141*f4a2713aSLionel Sambuc #undef ECase
142*f4a2713aSLionel Sambuc 
143*f4a2713aSLionel Sambuc #define BCase(X) IO.bitSetCase(Value, #X, COFF::X);
144*f4a2713aSLionel Sambuc void ScalarBitSetTraits<COFF::Characteristics>::bitset(
145*f4a2713aSLionel Sambuc     IO &IO, COFF::Characteristics &Value) {
146*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_RELOCS_STRIPPED);
147*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_EXECUTABLE_IMAGE);
148*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_LINE_NUMS_STRIPPED);
149*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_LOCAL_SYMS_STRIPPED);
150*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_AGGRESSIVE_WS_TRIM);
151*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_LARGE_ADDRESS_AWARE);
152*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_BYTES_REVERSED_LO);
153*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_32BIT_MACHINE);
154*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_DEBUG_STRIPPED);
155*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP);
156*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_NET_RUN_FROM_SWAP);
157*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_SYSTEM);
158*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_DLL);
159*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_UP_SYSTEM_ONLY);
160*f4a2713aSLionel Sambuc   BCase(IMAGE_FILE_BYTES_REVERSED_HI);
161*f4a2713aSLionel Sambuc }
162*f4a2713aSLionel Sambuc 
163*f4a2713aSLionel Sambuc void ScalarBitSetTraits<COFF::SectionCharacteristics>::bitset(
164*f4a2713aSLionel Sambuc     IO &IO, COFF::SectionCharacteristics &Value) {
165*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_TYPE_NO_PAD);
166*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_CNT_CODE);
167*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_CNT_INITIALIZED_DATA);
168*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_CNT_UNINITIALIZED_DATA);
169*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_OTHER);
170*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_INFO);
171*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_REMOVE);
172*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_COMDAT);
173*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_GPREL);
174*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_PURGEABLE);
175*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_16BIT);
176*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_LOCKED);
177*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_PRELOAD);
178*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_LNK_NRELOC_OVFL);
179*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_DISCARDABLE);
180*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_NOT_CACHED);
181*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_NOT_PAGED);
182*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_SHARED);
183*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_EXECUTE);
184*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_READ);
185*f4a2713aSLionel Sambuc   BCase(IMAGE_SCN_MEM_WRITE);
186*f4a2713aSLionel Sambuc }
187*f4a2713aSLionel Sambuc #undef BCase
188*f4a2713aSLionel Sambuc 
189*f4a2713aSLionel Sambuc namespace {
190*f4a2713aSLionel Sambuc struct NSectionCharacteristics {
191*f4a2713aSLionel Sambuc   NSectionCharacteristics(IO &)
192*f4a2713aSLionel Sambuc       : Characteristics(COFF::SectionCharacteristics(0)) {}
193*f4a2713aSLionel Sambuc   NSectionCharacteristics(IO &, uint32_t C)
194*f4a2713aSLionel Sambuc       : Characteristics(COFF::SectionCharacteristics(C)) {}
195*f4a2713aSLionel Sambuc   uint32_t denormalize(IO &) { return Characteristics; }
196*f4a2713aSLionel Sambuc   COFF::SectionCharacteristics Characteristics;
197*f4a2713aSLionel Sambuc };
198*f4a2713aSLionel Sambuc 
199*f4a2713aSLionel Sambuc struct NStorageClass {
200*f4a2713aSLionel Sambuc   NStorageClass(IO &) : StorageClass(COFF::SymbolStorageClass(0)) {}
201*f4a2713aSLionel Sambuc   NStorageClass(IO &, uint8_t S) : StorageClass(COFF::SymbolStorageClass(S)) {}
202*f4a2713aSLionel Sambuc   uint8_t denormalize(IO &) { return StorageClass; }
203*f4a2713aSLionel Sambuc 
204*f4a2713aSLionel Sambuc   COFF::SymbolStorageClass StorageClass;
205*f4a2713aSLionel Sambuc };
206*f4a2713aSLionel Sambuc 
207*f4a2713aSLionel Sambuc struct NMachine {
208*f4a2713aSLionel Sambuc   NMachine(IO &) : Machine(COFF::MachineTypes(0)) {}
209*f4a2713aSLionel Sambuc   NMachine(IO &, uint16_t M) : Machine(COFF::MachineTypes(M)) {}
210*f4a2713aSLionel Sambuc   uint16_t denormalize(IO &) { return Machine; }
211*f4a2713aSLionel Sambuc   COFF::MachineTypes Machine;
212*f4a2713aSLionel Sambuc };
213*f4a2713aSLionel Sambuc 
214*f4a2713aSLionel Sambuc struct NHeaderCharacteristics {
215*f4a2713aSLionel Sambuc   NHeaderCharacteristics(IO &) : Characteristics(COFF::Characteristics(0)) {}
216*f4a2713aSLionel Sambuc   NHeaderCharacteristics(IO &, uint16_t C)
217*f4a2713aSLionel Sambuc       : Characteristics(COFF::Characteristics(C)) {}
218*f4a2713aSLionel Sambuc   uint16_t denormalize(IO &) { return Characteristics; }
219*f4a2713aSLionel Sambuc 
220*f4a2713aSLionel Sambuc   COFF::Characteristics Characteristics;
221*f4a2713aSLionel Sambuc };
222*f4a2713aSLionel Sambuc 
223*f4a2713aSLionel Sambuc struct NType {
224*f4a2713aSLionel Sambuc   NType(IO &) : Type(COFF::RelocationTypeX86(0)) {}
225*f4a2713aSLionel Sambuc   NType(IO &, uint16_t T) : Type(COFF::RelocationTypeX86(T)) {}
226*f4a2713aSLionel Sambuc   uint16_t denormalize(IO &) { return Type; }
227*f4a2713aSLionel Sambuc   COFF::RelocationTypeX86 Type;
228*f4a2713aSLionel Sambuc };
229*f4a2713aSLionel Sambuc 
230*f4a2713aSLionel Sambuc }
231*f4a2713aSLionel Sambuc 
232*f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Relocation>::mapping(IO &IO,
233*f4a2713aSLionel Sambuc                                                   COFFYAML::Relocation &Rel) {
234*f4a2713aSLionel Sambuc   MappingNormalization<NType, uint16_t> NT(IO, Rel.Type);
235*f4a2713aSLionel Sambuc 
236*f4a2713aSLionel Sambuc   IO.mapRequired("VirtualAddress", Rel.VirtualAddress);
237*f4a2713aSLionel Sambuc   IO.mapRequired("SymbolName", Rel.SymbolName);
238*f4a2713aSLionel Sambuc   IO.mapRequired("Type", NT->Type);
239*f4a2713aSLionel Sambuc }
240*f4a2713aSLionel Sambuc 
241*f4a2713aSLionel Sambuc void MappingTraits<COFF::header>::mapping(IO &IO, COFF::header &H) {
242*f4a2713aSLionel Sambuc   MappingNormalization<NMachine, uint16_t> NM(IO, H.Machine);
243*f4a2713aSLionel Sambuc   MappingNormalization<NHeaderCharacteristics, uint16_t> NC(IO,
244*f4a2713aSLionel Sambuc                                                             H.Characteristics);
245*f4a2713aSLionel Sambuc 
246*f4a2713aSLionel Sambuc   IO.mapRequired("Machine", NM->Machine);
247*f4a2713aSLionel Sambuc   IO.mapOptional("Characteristics", NC->Characteristics);
248*f4a2713aSLionel Sambuc }
249*f4a2713aSLionel Sambuc 
250*f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Symbol>::mapping(IO &IO, COFFYAML::Symbol &S) {
251*f4a2713aSLionel Sambuc   MappingNormalization<NStorageClass, uint8_t> NS(IO, S.Header.StorageClass);
252*f4a2713aSLionel Sambuc 
253*f4a2713aSLionel Sambuc   IO.mapRequired("Name", S.Name);
254*f4a2713aSLionel Sambuc   IO.mapRequired("Value", S.Header.Value);
255*f4a2713aSLionel Sambuc   IO.mapRequired("SectionNumber", S.Header.SectionNumber);
256*f4a2713aSLionel Sambuc   IO.mapRequired("SimpleType", S.SimpleType);
257*f4a2713aSLionel Sambuc   IO.mapRequired("ComplexType", S.ComplexType);
258*f4a2713aSLionel Sambuc   IO.mapRequired("StorageClass", NS->StorageClass);
259*f4a2713aSLionel Sambuc   IO.mapOptional("NumberOfAuxSymbols", S.Header.NumberOfAuxSymbols,
260*f4a2713aSLionel Sambuc                  (uint8_t) 0);
261*f4a2713aSLionel Sambuc   IO.mapOptional("AuxiliaryData", S.AuxiliaryData, object::yaml::BinaryRef());
262*f4a2713aSLionel Sambuc }
263*f4a2713aSLionel Sambuc 
264*f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Section>::mapping(IO &IO, COFFYAML::Section &Sec) {
265*f4a2713aSLionel Sambuc   MappingNormalization<NSectionCharacteristics, uint32_t> NC(
266*f4a2713aSLionel Sambuc       IO, Sec.Header.Characteristics);
267*f4a2713aSLionel Sambuc   IO.mapRequired("Name", Sec.Name);
268*f4a2713aSLionel Sambuc   IO.mapRequired("Characteristics", NC->Characteristics);
269*f4a2713aSLionel Sambuc   IO.mapOptional("Alignment", Sec.Alignment);
270*f4a2713aSLionel Sambuc   IO.mapRequired("SectionData", Sec.SectionData);
271*f4a2713aSLionel Sambuc   IO.mapOptional("Relocations", Sec.Relocations);
272*f4a2713aSLionel Sambuc }
273*f4a2713aSLionel Sambuc 
274*f4a2713aSLionel Sambuc void MappingTraits<COFFYAML::Object>::mapping(IO &IO, COFFYAML::Object &Obj) {
275*f4a2713aSLionel Sambuc   IO.mapRequired("header", Obj.Header);
276*f4a2713aSLionel Sambuc   IO.mapRequired("sections", Obj.Sections);
277*f4a2713aSLionel Sambuc   IO.mapRequired("symbols", Obj.Symbols);
278*f4a2713aSLionel Sambuc }
279*f4a2713aSLionel Sambuc 
280*f4a2713aSLionel Sambuc }
281*f4a2713aSLionel Sambuc }
282