]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/ObjectYAML/MachOYAML.cpp
Merge ^/head r304537 through r304699.
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / ObjectYAML / MachOYAML.cpp
1 //===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines classes for handling the YAML representation of MachO.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ObjectYAML/MachOYAML.h"
15 #include "llvm/Support/Casting.h"
16 #include "llvm/Support/Format.h"
17 #include "llvm/Support/MachO.h"
18
19 #include <string.h> // For memcpy, memset and strnlen.
20
21 namespace llvm {
22
23 MachOYAML::LoadCommand::~LoadCommand() {}
24
25 namespace yaml {
26
27 void ScalarTraits<char_16>::output(const char_16 &Val, void *,
28                                    llvm::raw_ostream &Out) {
29   auto Len = strnlen(&Val[0], 16);
30   Out << StringRef(&Val[0], Len);
31 }
32
33 StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {
34   size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();
35   memcpy((void *)Val, Scalar.data(), CopySize);
36
37   if (Scalar.size() < 16) {
38     memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());
39   }
40
41   return StringRef();
42 }
43
44 bool ScalarTraits<char_16>::mustQuote(StringRef S) { return needsQuotes(S); }
45
46 void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *,
47                                   llvm::raw_ostream &Out) {
48   for (int Idx = 0; Idx < 16; ++Idx) {
49     Out << format("%02" PRIX32, Val[Idx]);
50     if (Idx == 3 || Idx == 5 || Idx == 7 || Idx == 9)
51       Out << "-";
52   }
53 }
54
55 StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) {
56   size_t OutIdx = 0;
57   for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {
58     if (Scalar[Idx] == '-' || OutIdx >= 16)
59       continue;
60     unsigned long long TempInt;
61     if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))
62       return "invalid number";
63     if (TempInt > 0xFF)
64       return "out of range number";
65     Val[OutIdx] = static_cast<uint8_t>(TempInt);
66     ++Idx; // increment idx an extra time because we're consuming 2 chars
67     ++OutIdx;
68   }
69   return StringRef();
70 }
71
72 bool ScalarTraits<uuid_t>::mustQuote(StringRef S) { return needsQuotes(S); }
73
74 void MappingTraits<MachOYAML::FileHeader>::mapping(
75     IO &IO, MachOYAML::FileHeader &FileHdr) {
76   IO.mapRequired("magic", FileHdr.magic);
77   IO.mapRequired("cputype", FileHdr.cputype);
78   IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
79   IO.mapRequired("filetype", FileHdr.filetype);
80   IO.mapRequired("ncmds", FileHdr.ncmds);
81   IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
82   IO.mapRequired("flags", FileHdr.flags);
83   if (FileHdr.magic == MachO::MH_MAGIC_64 ||
84       FileHdr.magic == MachO::MH_CIGAM_64)
85     IO.mapRequired("reserved", FileHdr.reserved);
86 }
87
88 void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
89                                                MachOYAML::Object &Object) {
90   // If the context isn't already set, tag the document as !mach-o.
91   // For Fat files there will be a different tag so they can be differentiated.
92   if (!IO.getContext()) {
93     IO.setContext(&Object);
94   }
95   IO.mapTag("!mach-o", true);
96   IO.mapRequired("FileHeader", Object.Header);
97   IO.mapOptional("LoadCommands", Object.LoadCommands);
98   IO.mapOptional("LinkEditData", Object.LinkEdit);
99
100   if (IO.getContext() == &Object)
101     IO.setContext(nullptr);
102 }
103
104 void MappingTraits<MachOYAML::FatHeader>::mapping(
105     IO &IO, MachOYAML::FatHeader &FatHeader) {
106   IO.mapRequired("magic", FatHeader.magic);
107   IO.mapRequired("nfat_arch", FatHeader.nfat_arch);
108 }
109
110 void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO,
111                                                 MachOYAML::FatArch &FatArch) {
112   IO.mapRequired("cputype", FatArch.cputype);
113   IO.mapRequired("cpusubtype", FatArch.cpusubtype);
114   IO.mapRequired("offset", FatArch.offset);
115   IO.mapRequired("size", FatArch.size);
116   IO.mapRequired("align", FatArch.align);
117   IO.mapOptional("reserved", FatArch.reserved,
118                  static_cast<llvm::yaml::Hex32>(0));
119 }
120
121 void MappingTraits<MachOYAML::UniversalBinary>::mapping(
122     IO &IO, MachOYAML::UniversalBinary &UniversalBinary) {
123   if (!IO.getContext()) {
124     IO.setContext(&UniversalBinary);
125     IO.mapTag("!fat-mach-o", true);
126   }
127   IO.mapRequired("FatHeader", UniversalBinary.Header);
128   IO.mapRequired("FatArchs", UniversalBinary.FatArchs);
129   IO.mapRequired("Slices", UniversalBinary.Slices);
130
131   if (IO.getContext() == &UniversalBinary)
132     IO.setContext(nullptr);
133 }
134
135 void MappingTraits<MachOYAML::LinkEditData>::mapping(
136     IO &IO, MachOYAML::LinkEditData &LinkEditData) {
137   IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes);
138   IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);
139   IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);
140   IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);
141   IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);
142   IO.mapOptional("NameList", LinkEditData.NameList);
143   IO.mapOptional("StringTable", LinkEditData.StringTable);
144 }
145
146 void MappingTraits<MachOYAML::RebaseOpcode>::mapping(
147     IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) {
148   IO.mapRequired("Opcode", RebaseOpcode.Opcode);
149   IO.mapRequired("Imm", RebaseOpcode.Imm);
150   IO.mapOptional("ExtraData", RebaseOpcode.ExtraData);
151 }
152
153 void MappingTraits<MachOYAML::BindOpcode>::mapping(
154     IO &IO, MachOYAML::BindOpcode &BindOpcode) {
155   IO.mapRequired("Opcode", BindOpcode.Opcode);
156   IO.mapRequired("Imm", BindOpcode.Imm);
157   IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData);
158   IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData);
159   IO.mapOptional("Symbol", BindOpcode.Symbol);
160 }
161
162 void MappingTraits<MachOYAML::ExportEntry>::mapping(
163     IO &IO, MachOYAML::ExportEntry &ExportEntry) {
164   IO.mapRequired("TerminalSize", ExportEntry.TerminalSize);
165   IO.mapOptional("NodeOffset", ExportEntry.NodeOffset);
166   IO.mapOptional("Name", ExportEntry.Name);
167   IO.mapOptional("Flags", ExportEntry.Flags);
168   IO.mapOptional("Address", ExportEntry.Address);
169   IO.mapOptional("Other", ExportEntry.Other);
170   IO.mapOptional("ImportName", ExportEntry.ImportName);
171   IO.mapOptional("Children", ExportEntry.Children);
172 }
173
174 void MappingTraits<MachOYAML::NListEntry>::mapping(
175     IO &IO, MachOYAML::NListEntry &NListEntry) {
176   IO.mapRequired("n_strx", NListEntry.n_strx);
177   IO.mapRequired("n_type", NListEntry.n_type);
178   IO.mapRequired("n_sect", NListEntry.n_sect);
179   IO.mapRequired("n_desc", NListEntry.n_desc);
180   IO.mapRequired("n_value", NListEntry.n_value);
181 }
182
183 template <typename StructType>
184 void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {}
185
186 template <>
187 void mapLoadCommandData<MachO::segment_command>(
188     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
189   IO.mapOptional("Sections", LoadCommand.Sections);
190 }
191
192 template <>
193 void mapLoadCommandData<MachO::segment_command_64>(
194     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
195   IO.mapOptional("Sections", LoadCommand.Sections);
196 }
197
198 template <>
199 void mapLoadCommandData<MachO::dylib_command>(
200     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
201   IO.mapOptional("PayloadString", LoadCommand.PayloadString);
202 }
203
204 template <>
205 void mapLoadCommandData<MachO::rpath_command>(
206     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
207   IO.mapOptional("PayloadString", LoadCommand.PayloadString);
208 }
209
210 template <>
211 void mapLoadCommandData<MachO::dylinker_command>(
212     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
213   IO.mapOptional("PayloadString", LoadCommand.PayloadString);
214 }
215
216 void MappingTraits<MachOYAML::LoadCommand>::mapping(
217     IO &IO, MachOYAML::LoadCommand &LoadCommand) {
218   MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>(
219       LoadCommand.Data.load_command_data.cmd);
220   IO.mapRequired("cmd", TempCmd);
221   LoadCommand.Data.load_command_data.cmd = TempCmd;
222   IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);
223
224 #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct)                         \
225   case MachO::LCName:                                                          \
226     MappingTraits<MachO::LCStruct>::mapping(IO,                                \
227                                             LoadCommand.Data.LCStruct##_data); \
228     mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand);                      \
229     break;
230
231   switch (LoadCommand.Data.load_command_data.cmd) {
232 #include "llvm/Support/MachO.def"
233   }
234   IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes);
235   IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull);
236 }
237
238 void MappingTraits<MachO::dyld_info_command>::mapping(
239     IO &IO, MachO::dyld_info_command &LoadCommand) {
240   IO.mapRequired("rebase_off", LoadCommand.rebase_off);
241   IO.mapRequired("rebase_size", LoadCommand.rebase_size);
242   IO.mapRequired("bind_off", LoadCommand.bind_off);
243   IO.mapRequired("bind_size", LoadCommand.bind_size);
244   IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
245   IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
246   IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
247   IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
248   IO.mapRequired("export_off", LoadCommand.export_off);
249   IO.mapRequired("export_size", LoadCommand.export_size);
250 }
251
252 void MappingTraits<MachOYAML::Section>::mapping(IO &IO,
253                                                 MachOYAML::Section &Section) {
254   IO.mapRequired("sectname", Section.sectname);
255   IO.mapRequired("segname", Section.segname);
256   IO.mapRequired("addr", Section.addr);
257   IO.mapRequired("size", Section.size);
258   IO.mapRequired("offset", Section.offset);
259   IO.mapRequired("align", Section.align);
260   IO.mapRequired("reloff", Section.reloff);
261   IO.mapRequired("nreloc", Section.nreloc);
262   IO.mapRequired("flags", Section.flags);
263   IO.mapRequired("reserved1", Section.reserved1);
264   IO.mapRequired("reserved2", Section.reserved2);
265   IO.mapOptional("reserved3", Section.reserved3);
266 }
267
268 void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {
269   IO.mapRequired("name", DylibStruct.name);
270   IO.mapRequired("timestamp", DylibStruct.timestamp);
271   IO.mapRequired("current_version", DylibStruct.current_version);
272   IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);
273 }
274
275 void MappingTraits<MachO::dylib_command>::mapping(
276     IO &IO, MachO::dylib_command &LoadCommand) {
277   IO.mapRequired("dylib", LoadCommand.dylib);
278 }
279
280 void MappingTraits<MachO::dylinker_command>::mapping(
281     IO &IO, MachO::dylinker_command &LoadCommand) {
282
283   IO.mapRequired("name", LoadCommand.name);
284 }
285
286 void MappingTraits<MachO::dysymtab_command>::mapping(
287     IO &IO, MachO::dysymtab_command &LoadCommand) {
288
289   IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);
290   IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);
291   IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);
292   IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);
293   IO.mapRequired("iundefsym", LoadCommand.iundefsym);
294   IO.mapRequired("nundefsym", LoadCommand.nundefsym);
295   IO.mapRequired("tocoff", LoadCommand.tocoff);
296   IO.mapRequired("ntoc", LoadCommand.ntoc);
297   IO.mapRequired("modtaboff", LoadCommand.modtaboff);
298   IO.mapRequired("nmodtab", LoadCommand.nmodtab);
299   IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);
300   IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);
301   IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);
302   IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);
303   IO.mapRequired("extreloff", LoadCommand.extreloff);
304   IO.mapRequired("nextrel", LoadCommand.nextrel);
305   IO.mapRequired("locreloff", LoadCommand.locreloff);
306   IO.mapRequired("nlocrel", LoadCommand.nlocrel);
307 }
308
309 void MappingTraits<MachO::encryption_info_command>::mapping(
310     IO &IO, MachO::encryption_info_command &LoadCommand) {
311
312   IO.mapRequired("cryptoff", LoadCommand.cryptoff);
313   IO.mapRequired("cryptsize", LoadCommand.cryptsize);
314   IO.mapRequired("cryptid", LoadCommand.cryptid);
315 }
316
317 void MappingTraits<MachO::encryption_info_command_64>::mapping(
318     IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
319
320   IO.mapRequired("cryptoff", LoadCommand.cryptoff);
321   IO.mapRequired("cryptsize", LoadCommand.cryptsize);
322   IO.mapRequired("cryptid", LoadCommand.cryptid);
323   IO.mapRequired("pad", LoadCommand.pad);
324 }
325
326 void MappingTraits<MachO::entry_point_command>::mapping(
327     IO &IO, MachO::entry_point_command &LoadCommand) {
328
329   IO.mapRequired("entryoff", LoadCommand.entryoff);
330   IO.mapRequired("stacksize", LoadCommand.stacksize);
331 }
332
333 void MappingTraits<MachO::fvmfile_command>::mapping(
334     IO &IO, MachO::fvmfile_command &LoadCommand) {
335
336   IO.mapRequired("name", LoadCommand.name);
337   IO.mapRequired("header_addr", LoadCommand.header_addr);
338 }
339
340 void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {
341   IO.mapRequired("name", FVMLib.name);
342   IO.mapRequired("minor_version", FVMLib.minor_version);
343   IO.mapRequired("header_addr", FVMLib.header_addr);
344 }
345
346 void MappingTraits<MachO::fvmlib_command>::mapping(
347     IO &IO, MachO::fvmlib_command &LoadCommand) {
348
349   IO.mapRequired("fvmlib", LoadCommand.fvmlib);
350 }
351
352 void MappingTraits<MachO::ident_command>::mapping(
353     IO &IO, MachO::ident_command &LoadCommand) {}
354
355 void MappingTraits<MachO::linkedit_data_command>::mapping(
356     IO &IO, MachO::linkedit_data_command &LoadCommand) {
357
358   IO.mapRequired("dataoff", LoadCommand.dataoff);
359   IO.mapRequired("datasize", LoadCommand.datasize);
360 }
361
362 void MappingTraits<MachO::linker_option_command>::mapping(
363     IO &IO, MachO::linker_option_command &LoadCommand) {
364
365   IO.mapRequired("count", LoadCommand.count);
366 }
367
368 void MappingTraits<MachO::prebind_cksum_command>::mapping(
369     IO &IO, MachO::prebind_cksum_command &LoadCommand) {
370
371   IO.mapRequired("cksum", LoadCommand.cksum);
372 }
373
374 void MappingTraits<MachO::load_command>::mapping(
375     IO &IO, MachO::load_command &LoadCommand) {}
376
377 void MappingTraits<MachO::prebound_dylib_command>::mapping(
378     IO &IO, MachO::prebound_dylib_command &LoadCommand) {
379
380   IO.mapRequired("name", LoadCommand.name);
381   IO.mapRequired("nmodules", LoadCommand.nmodules);
382   IO.mapRequired("linked_modules", LoadCommand.linked_modules);
383 }
384
385 void MappingTraits<MachO::routines_command>::mapping(
386     IO &IO, MachO::routines_command &LoadCommand) {
387
388   IO.mapRequired("init_address", LoadCommand.init_address);
389   IO.mapRequired("init_module", LoadCommand.init_module);
390   IO.mapRequired("reserved1", LoadCommand.reserved1);
391   IO.mapRequired("reserved2", LoadCommand.reserved2);
392   IO.mapRequired("reserved3", LoadCommand.reserved3);
393   IO.mapRequired("reserved4", LoadCommand.reserved4);
394   IO.mapRequired("reserved5", LoadCommand.reserved5);
395   IO.mapRequired("reserved6", LoadCommand.reserved6);
396 }
397
398 void MappingTraits<MachO::routines_command_64>::mapping(
399     IO &IO, MachO::routines_command_64 &LoadCommand) {
400
401   IO.mapRequired("init_address", LoadCommand.init_address);
402   IO.mapRequired("init_module", LoadCommand.init_module);
403   IO.mapRequired("reserved1", LoadCommand.reserved1);
404   IO.mapRequired("reserved2", LoadCommand.reserved2);
405   IO.mapRequired("reserved3", LoadCommand.reserved3);
406   IO.mapRequired("reserved4", LoadCommand.reserved4);
407   IO.mapRequired("reserved5", LoadCommand.reserved5);
408   IO.mapRequired("reserved6", LoadCommand.reserved6);
409 }
410
411 void MappingTraits<MachO::rpath_command>::mapping(
412     IO &IO, MachO::rpath_command &LoadCommand) {
413
414   IO.mapRequired("path", LoadCommand.path);
415 }
416
417 void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) {
418   IO.mapRequired("sectname", Section.sectname);
419   IO.mapRequired("segname", Section.segname);
420   IO.mapRequired("addr", Section.addr);
421   IO.mapRequired("size", Section.size);
422   IO.mapRequired("offset", Section.offset);
423   IO.mapRequired("align", Section.align);
424   IO.mapRequired("reloff", Section.reloff);
425   IO.mapRequired("nreloc", Section.nreloc);
426   IO.mapRequired("flags", Section.flags);
427   IO.mapRequired("reserved1", Section.reserved1);
428   IO.mapRequired("reserved2", Section.reserved2);
429 }
430
431 void MappingTraits<MachO::section_64>::mapping(IO &IO,
432                                                MachO::section_64 &Section) {
433   IO.mapRequired("sectname", Section.sectname);
434   IO.mapRequired("segname", Section.segname);
435   IO.mapRequired("addr", Section.addr);
436   IO.mapRequired("size", Section.size);
437   IO.mapRequired("offset", Section.offset);
438   IO.mapRequired("align", Section.align);
439   IO.mapRequired("reloff", Section.reloff);
440   IO.mapRequired("nreloc", Section.nreloc);
441   IO.mapRequired("flags", Section.flags);
442   IO.mapRequired("reserved1", Section.reserved1);
443   IO.mapRequired("reserved2", Section.reserved2);
444   IO.mapRequired("reserved3", Section.reserved3);
445 }
446
447 void MappingTraits<MachO::segment_command>::mapping(
448     IO &IO, MachO::segment_command &LoadCommand) {
449
450   IO.mapRequired("segname", LoadCommand.segname);
451   IO.mapRequired("vmaddr", LoadCommand.vmaddr);
452   IO.mapRequired("vmsize", LoadCommand.vmsize);
453   IO.mapRequired("fileoff", LoadCommand.fileoff);
454   IO.mapRequired("filesize", LoadCommand.filesize);
455   IO.mapRequired("maxprot", LoadCommand.maxprot);
456   IO.mapRequired("initprot", LoadCommand.initprot);
457   IO.mapRequired("nsects", LoadCommand.nsects);
458   IO.mapRequired("flags", LoadCommand.flags);
459 }
460
461 void MappingTraits<MachO::segment_command_64>::mapping(
462     IO &IO, MachO::segment_command_64 &LoadCommand) {
463
464   IO.mapRequired("segname", LoadCommand.segname);
465   IO.mapRequired("vmaddr", LoadCommand.vmaddr);
466   IO.mapRequired("vmsize", LoadCommand.vmsize);
467   IO.mapRequired("fileoff", LoadCommand.fileoff);
468   IO.mapRequired("filesize", LoadCommand.filesize);
469   IO.mapRequired("maxprot", LoadCommand.maxprot);
470   IO.mapRequired("initprot", LoadCommand.initprot);
471   IO.mapRequired("nsects", LoadCommand.nsects);
472   IO.mapRequired("flags", LoadCommand.flags);
473 }
474
475 void MappingTraits<MachO::source_version_command>::mapping(
476     IO &IO, MachO::source_version_command &LoadCommand) {
477
478   IO.mapRequired("version", LoadCommand.version);
479 }
480
481 void MappingTraits<MachO::sub_client_command>::mapping(
482     IO &IO, MachO::sub_client_command &LoadCommand) {
483
484   IO.mapRequired("client", LoadCommand.client);
485 }
486
487 void MappingTraits<MachO::sub_framework_command>::mapping(
488     IO &IO, MachO::sub_framework_command &LoadCommand) {
489
490   IO.mapRequired("umbrella", LoadCommand.umbrella);
491 }
492
493 void MappingTraits<MachO::sub_library_command>::mapping(
494     IO &IO, MachO::sub_library_command &LoadCommand) {
495
496   IO.mapRequired("sub_library", LoadCommand.sub_library);
497 }
498
499 void MappingTraits<MachO::sub_umbrella_command>::mapping(
500     IO &IO, MachO::sub_umbrella_command &LoadCommand) {
501
502   IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);
503 }
504
505 void MappingTraits<MachO::symseg_command>::mapping(
506     IO &IO, MachO::symseg_command &LoadCommand) {
507
508   IO.mapRequired("offset", LoadCommand.offset);
509   IO.mapRequired("size", LoadCommand.size);
510 }
511
512 void MappingTraits<MachO::symtab_command>::mapping(
513     IO &IO, MachO::symtab_command &LoadCommand) {
514
515   IO.mapRequired("symoff", LoadCommand.symoff);
516   IO.mapRequired("nsyms", LoadCommand.nsyms);
517   IO.mapRequired("stroff", LoadCommand.stroff);
518   IO.mapRequired("strsize", LoadCommand.strsize);
519 }
520
521 void MappingTraits<MachO::thread_command>::mapping(
522     IO &IO, MachO::thread_command &LoadCommand) {}
523
524 void MappingTraits<MachO::twolevel_hints_command>::mapping(
525     IO &IO, MachO::twolevel_hints_command &LoadCommand) {
526
527   IO.mapRequired("offset", LoadCommand.offset);
528   IO.mapRequired("nhints", LoadCommand.nhints);
529 }
530
531 void MappingTraits<MachO::uuid_command>::mapping(
532     IO &IO, MachO::uuid_command &LoadCommand) {
533
534   IO.mapRequired("uuid", LoadCommand.uuid);
535 }
536
537 void MappingTraits<MachO::version_min_command>::mapping(
538     IO &IO, MachO::version_min_command &LoadCommand) {
539
540   IO.mapRequired("version", LoadCommand.version);
541   IO.mapRequired("sdk", LoadCommand.sdk);
542 }
543
544 } // namespace llvm::yaml
545
546 } // namespace llvm