blob: b4e808552dffed25af2f5133d7e9e054e28c390f [file] [log] [blame]
Chris Bieneman9062ab92016-05-12 16:04:16 +00001//===- 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"
Chris Bieneman3f2eb832016-05-17 19:44:06 +000016#include "llvm/Support/Format.h"
17
Chris Bieneman2de17d42016-05-18 16:17:23 +000018#include <string.h> // For memcpy, memset and strnlen.
Chris Bieneman9062ab92016-05-12 16:04:16 +000019
20namespace llvm {
21
Chris Bieneman8b5906e2016-05-13 17:41:41 +000022MachOYAML::LoadCommand::~LoadCommand() {}
23
Chris Bieneman9062ab92016-05-12 16:04:16 +000024namespace yaml {
25
Chris Bieneman3f2eb832016-05-17 19:44:06 +000026void ScalarTraits<char_16>::output(const char_16 &Val, void *,
27 llvm::raw_ostream &Out) {
Chris Bieneman2de17d42016-05-18 16:17:23 +000028 auto Len = strnlen(&Val[0], 16);
29 Out << StringRef(&Val[0], Len);
Chris Bieneman3f2eb832016-05-17 19:44:06 +000030}
31
32StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {
33 size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();
34 memcpy((void *)Val, Scalar.data(), CopySize);
35
36 if (Scalar.size() < 16) {
37 memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());
38 }
39
40 return StringRef();
41}
42
43bool ScalarTraits<char_16>::mustQuote(StringRef S) { return needsQuotes(S); }
44
45void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *,
46 llvm::raw_ostream &Out) {
47 for (int Idx = 0; Idx < 16; ++Idx) {
48 Out << format("%02" PRIX32, Val[Idx]);
49 if (Idx == 3 || Idx == 5 || Idx == 7 || Idx == 9)
50 Out << "-";
51 }
52}
53
54StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) {
55 size_t OutIdx = 0;
56 for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {
57 if (Scalar[Idx] == '-' || OutIdx >= 16)
58 continue;
59 unsigned long long TempInt;
60 if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))
61 return "invalid number";
62 if (TempInt > 0xFF)
63 return "out of range number";
64 Val[OutIdx] = static_cast<uint8_t>(TempInt);
65 ++Idx; // increment idx an extra time because we're consuming 2 chars
66 ++OutIdx;
67 }
68 return StringRef();
69}
70
71bool ScalarTraits<uuid_t>::mustQuote(StringRef S) { return needsQuotes(S); }
72
Chris Bieneman9062ab92016-05-12 16:04:16 +000073void MappingTraits<MachOYAML::FileHeader>::mapping(
74 IO &IO, MachOYAML::FileHeader &FileHdr) {
Chris Bieneman24f07472016-05-12 17:44:43 +000075 IO.mapRequired("magic", FileHdr.magic);
Chris Bieneman9062ab92016-05-12 16:04:16 +000076 IO.mapRequired("cputype", FileHdr.cputype);
77 IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
Chris Bieneman668beb22016-05-12 17:53:01 +000078 IO.mapRequired("filetype", FileHdr.filetype);
Chris Bieneman9062ab92016-05-12 16:04:16 +000079 IO.mapRequired("ncmds", FileHdr.ncmds);
Chris Bieneman24f07472016-05-12 17:44:43 +000080 IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
Chris Bieneman9062ab92016-05-12 16:04:16 +000081 IO.mapRequired("flags", FileHdr.flags);
Chris Bienemanfc889272016-05-12 18:21:09 +000082 IO.mapOptional("reserved", FileHdr.reserved,
83 static_cast<llvm::yaml::Hex32>(0xDEADBEEFu));
Chris Bieneman9062ab92016-05-12 16:04:16 +000084}
85
86void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
87 MachOYAML::Object &Object) {
88 // If the context isn't already set, tag the document as !mach-o.
89 // For Fat files there will be a different tag so they can be differentiated.
Chris Bieneman24f07472016-05-12 17:44:43 +000090 if (!IO.getContext()) {
Chris Bieneman9062ab92016-05-12 16:04:16 +000091 IO.setContext(&Object);
92 IO.mapTag("!mach-o", true);
93 }
94 IO.mapRequired("FileHeader", Object.Header);
Chris Bieneman8b5906e2016-05-13 17:41:41 +000095 IO.mapOptional("LoadCommands", Object.LoadCommands);
Chris Bienemane8e75552016-05-25 17:09:07 +000096 IO.mapOptional("LinkEditData", Object.LinkEdit);
Chris Bieneman9062ab92016-05-12 16:04:16 +000097 IO.setContext(nullptr);
98}
99
Chris Bieneman524243d2016-05-26 20:06:14 +0000100void MappingTraits<MachOYAML::LinkEditData>::mapping(
101 IO &IO, MachOYAML::LinkEditData &LinkEditData) {
Chris Bienemane8e75552016-05-25 17:09:07 +0000102 IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes);
Chris Bieneman524243d2016-05-26 20:06:14 +0000103 IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);
Chris Bieneman659b35a2016-05-26 20:50:05 +0000104 IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);
Chris Bieneman44474c42016-05-26 21:29:39 +0000105 IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);
Chris Bieneman68527752016-05-31 17:26:36 +0000106 IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);
Chris Bieneman07bb3c82016-06-02 22:54:06 +0000107 IO.mapOptional("NameList", LinkEditData.NameList);
108 IO.mapOptional("StringTable", LinkEditData.StringTable);
Chris Bienemane8e75552016-05-25 17:09:07 +0000109}
110
Chris Bieneman524243d2016-05-26 20:06:14 +0000111void MappingTraits<MachOYAML::RebaseOpcode>::mapping(
112 IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) {
Chris Bienemane8e75552016-05-25 17:09:07 +0000113 IO.mapRequired("Opcode", RebaseOpcode.Opcode);
114 IO.mapRequired("Imm", RebaseOpcode.Imm);
115 IO.mapOptional("ExtraData", RebaseOpcode.ExtraData);
116}
117
Chris Bieneman524243d2016-05-26 20:06:14 +0000118void MappingTraits<MachOYAML::BindOpcode>::mapping(
119 IO &IO, MachOYAML::BindOpcode &BindOpcode) {
120 IO.mapRequired("Opcode", BindOpcode.Opcode);
121 IO.mapRequired("Imm", BindOpcode.Imm);
122 IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData);
123 IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData);
124 IO.mapOptional("Symbol", BindOpcode.Symbol);
125}
126
Chris Bieneman68527752016-05-31 17:26:36 +0000127void MappingTraits<MachOYAML::ExportEntry>::mapping(
128 IO &IO, MachOYAML::ExportEntry &ExportEntry) {
129 IO.mapRequired("TerminalSize", ExportEntry.TerminalSize);
130 IO.mapOptional("NodeOffset", ExportEntry.NodeOffset);
131 IO.mapOptional("Name", ExportEntry.Name);
132 IO.mapOptional("Flags", ExportEntry.Flags);
133 IO.mapOptional("Address", ExportEntry.Address);
134 IO.mapOptional("Other", ExportEntry.Other);
135 IO.mapOptional("ImportName", ExportEntry.ImportName);
136 IO.mapOptional("Children", ExportEntry.Children);
137}
138
Chris Bieneman07bb3c82016-06-02 22:54:06 +0000139void MappingTraits<MachOYAML::NListEntry>::mapping(
140 IO &IO, MachOYAML::NListEntry &NListEntry) {
141 IO.mapRequired("n_strx", NListEntry.n_strx);
142 IO.mapRequired("n_type", NListEntry.n_type);
143 IO.mapRequired("n_sect", NListEntry.n_sect);
144 IO.mapRequired("n_desc", NListEntry.n_desc);
145 IO.mapRequired("n_value", NListEntry.n_value);
146}
147
Chris Bieneman9f243e92016-05-19 20:54:43 +0000148template <typename StructType>
149void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {}
150
151template <>
152void mapLoadCommandData<MachO::segment_command>(
153 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
154 IO.mapOptional("Sections", LoadCommand.Sections);
155}
156
157template <>
158void mapLoadCommandData<MachO::segment_command_64>(
159 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
160 IO.mapOptional("Sections", LoadCommand.Sections);
161}
162
163template <>
164void mapLoadCommandData<MachO::dylib_command>(
165 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
166 IO.mapOptional("PayloadString", LoadCommand.PayloadString);
167}
168
169template <>
Chris Bieneman68527752016-05-31 17:26:36 +0000170void mapLoadCommandData<MachO::rpath_command>(
171 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
172 IO.mapOptional("PayloadString", LoadCommand.PayloadString);
173}
174
175template <>
Chris Bieneman9f243e92016-05-19 20:54:43 +0000176void mapLoadCommandData<MachO::dylinker_command>(
177 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
178 IO.mapOptional("PayloadString", LoadCommand.PayloadString);
179}
180
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000181void MappingTraits<MachOYAML::LoadCommand>::mapping(
182 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
183 IO.mapRequired(
184 "cmd", (MachO::LoadCommandType &)LoadCommand.Data.load_command_data.cmd);
185 IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);
186
187#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
188 case MachO::LCName: \
189 MappingTraits<MachO::LCStruct>::mapping(IO, \
190 LoadCommand.Data.LCStruct##_data); \
Chris Bieneman9f243e92016-05-19 20:54:43 +0000191 mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000192 break;
193
194 switch (LoadCommand.Data.load_command_data.cmd) {
195#include "llvm/Support/MachO.def"
196 }
Chris Bieneman9f243e92016-05-19 20:54:43 +0000197 IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes);
198 IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull);
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000199}
200
201void MappingTraits<MachO::dyld_info_command>::mapping(
202 IO &IO, MachO::dyld_info_command &LoadCommand) {
203 IO.mapRequired("rebase_off", LoadCommand.rebase_off);
204 IO.mapRequired("rebase_size", LoadCommand.rebase_size);
Chris Bieneman2de17d42016-05-18 16:17:23 +0000205 IO.mapRequired("bind_off", LoadCommand.bind_off);
206 IO.mapRequired("bind_size", LoadCommand.bind_size);
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000207 IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
208 IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
Chris Bieneman2de17d42016-05-18 16:17:23 +0000209 IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
210 IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000211 IO.mapRequired("export_off", LoadCommand.export_off);
212 IO.mapRequired("export_size", LoadCommand.export_size);
213}
214
Chris Bieneman2de17d42016-05-18 16:17:23 +0000215void MappingTraits<MachOYAML::Section>::mapping(IO &IO,
216 MachOYAML::Section &Section) {
217 IO.mapRequired("sectname", Section.sectname);
218 IO.mapRequired("segname", Section.segname);
219 IO.mapRequired("addr", Section.addr);
220 IO.mapRequired("size", Section.size);
221 IO.mapRequired("offset", Section.offset);
222 IO.mapRequired("align", Section.align);
223 IO.mapRequired("reloff", Section.reloff);
224 IO.mapRequired("nreloc", Section.nreloc);
225 IO.mapRequired("flags", Section.flags);
226 IO.mapRequired("reserved1", Section.reserved1);
227 IO.mapRequired("reserved2", Section.reserved2);
228 IO.mapOptional("reserved3", Section.reserved3);
229}
230
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000231void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {
232 IO.mapRequired("name", DylibStruct.name);
233 IO.mapRequired("timestamp", DylibStruct.timestamp);
234 IO.mapRequired("current_version", DylibStruct.current_version);
235 IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);
236}
237
238void MappingTraits<MachO::dylib_command>::mapping(
239 IO &IO, MachO::dylib_command &LoadCommand) {
240 IO.mapRequired("dylib", LoadCommand.dylib);
241}
242
243void MappingTraits<MachO::dylinker_command>::mapping(
244 IO &IO, MachO::dylinker_command &LoadCommand) {
245
246 IO.mapRequired("name", LoadCommand.name);
247}
248
249void MappingTraits<MachO::dysymtab_command>::mapping(
250 IO &IO, MachO::dysymtab_command &LoadCommand) {
251
252 IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);
253 IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);
254 IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);
255 IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);
256 IO.mapRequired("iundefsym", LoadCommand.iundefsym);
257 IO.mapRequired("nundefsym", LoadCommand.nundefsym);
258 IO.mapRequired("tocoff", LoadCommand.tocoff);
259 IO.mapRequired("ntoc", LoadCommand.ntoc);
260 IO.mapRequired("modtaboff", LoadCommand.modtaboff);
261 IO.mapRequired("nmodtab", LoadCommand.nmodtab);
262 IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);
263 IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);
264 IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);
265 IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);
266 IO.mapRequired("extreloff", LoadCommand.extreloff);
267 IO.mapRequired("nextrel", LoadCommand.nextrel);
268 IO.mapRequired("locreloff", LoadCommand.locreloff);
269 IO.mapRequired("nlocrel", LoadCommand.nlocrel);
270}
271
272void MappingTraits<MachO::encryption_info_command>::mapping(
273 IO &IO, MachO::encryption_info_command &LoadCommand) {
274
275 IO.mapRequired("cryptoff", LoadCommand.cryptoff);
276 IO.mapRequired("cryptsize", LoadCommand.cryptsize);
277 IO.mapRequired("cryptid", LoadCommand.cryptid);
278}
279
280void MappingTraits<MachO::encryption_info_command_64>::mapping(
281 IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
282
283 IO.mapRequired("cryptoff", LoadCommand.cryptoff);
284 IO.mapRequired("cryptsize", LoadCommand.cryptsize);
285 IO.mapRequired("cryptid", LoadCommand.cryptid);
286 IO.mapRequired("pad", LoadCommand.pad);
287}
288
289void MappingTraits<MachO::entry_point_command>::mapping(
290 IO &IO, MachO::entry_point_command &LoadCommand) {
291
292 IO.mapRequired("entryoff", LoadCommand.entryoff);
293 IO.mapRequired("stacksize", LoadCommand.stacksize);
294}
295
296void MappingTraits<MachO::fvmfile_command>::mapping(
297 IO &IO, MachO::fvmfile_command &LoadCommand) {
298
299 IO.mapRequired("name", LoadCommand.name);
300 IO.mapRequired("header_addr", LoadCommand.header_addr);
301}
302
303void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {
304 IO.mapRequired("name", FVMLib.name);
305 IO.mapRequired("minor_version", FVMLib.minor_version);
306 IO.mapRequired("header_addr", FVMLib.header_addr);
307}
308
309void MappingTraits<MachO::fvmlib_command>::mapping(
310 IO &IO, MachO::fvmlib_command &LoadCommand) {
311
312 IO.mapRequired("fvmlib", LoadCommand.fvmlib);
313}
314
315void MappingTraits<MachO::ident_command>::mapping(
316 IO &IO, MachO::ident_command &LoadCommand) {}
317
318void MappingTraits<MachO::linkedit_data_command>::mapping(
319 IO &IO, MachO::linkedit_data_command &LoadCommand) {
320
321 IO.mapRequired("dataoff", LoadCommand.dataoff);
322 IO.mapRequired("datasize", LoadCommand.datasize);
323}
324
325void MappingTraits<MachO::linker_option_command>::mapping(
326 IO &IO, MachO::linker_option_command &LoadCommand) {
327
328 IO.mapRequired("count", LoadCommand.count);
329}
330
331void MappingTraits<MachO::prebind_cksum_command>::mapping(
332 IO &IO, MachO::prebind_cksum_command &LoadCommand) {
333
334 IO.mapRequired("cksum", LoadCommand.cksum);
335}
336
337void MappingTraits<MachO::load_command>::mapping(
338 IO &IO, MachO::load_command &LoadCommand) {}
339
340void MappingTraits<MachO::prebound_dylib_command>::mapping(
341 IO &IO, MachO::prebound_dylib_command &LoadCommand) {
342
343 IO.mapRequired("name", LoadCommand.name);
344 IO.mapRequired("nmodules", LoadCommand.nmodules);
345 IO.mapRequired("linked_modules", LoadCommand.linked_modules);
346}
347
348void MappingTraits<MachO::routines_command>::mapping(
349 IO &IO, MachO::routines_command &LoadCommand) {
350
351 IO.mapRequired("init_address", LoadCommand.init_address);
352 IO.mapRequired("init_module", LoadCommand.init_module);
353 IO.mapRequired("reserved1", LoadCommand.reserved1);
354 IO.mapRequired("reserved2", LoadCommand.reserved2);
355 IO.mapRequired("reserved3", LoadCommand.reserved3);
356 IO.mapRequired("reserved4", LoadCommand.reserved4);
357 IO.mapRequired("reserved5", LoadCommand.reserved5);
358 IO.mapRequired("reserved6", LoadCommand.reserved6);
359}
360
361void MappingTraits<MachO::routines_command_64>::mapping(
362 IO &IO, MachO::routines_command_64 &LoadCommand) {
363
364 IO.mapRequired("init_address", LoadCommand.init_address);
365 IO.mapRequired("init_module", LoadCommand.init_module);
366 IO.mapRequired("reserved1", LoadCommand.reserved1);
367 IO.mapRequired("reserved2", LoadCommand.reserved2);
368 IO.mapRequired("reserved3", LoadCommand.reserved3);
369 IO.mapRequired("reserved4", LoadCommand.reserved4);
370 IO.mapRequired("reserved5", LoadCommand.reserved5);
371 IO.mapRequired("reserved6", LoadCommand.reserved6);
372}
373
374void MappingTraits<MachO::rpath_command>::mapping(
375 IO &IO, MachO::rpath_command &LoadCommand) {
376
377 IO.mapRequired("path", LoadCommand.path);
378}
379
380void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) {
381 IO.mapRequired("sectname", Section.sectname);
382 IO.mapRequired("segname", Section.segname);
383 IO.mapRequired("addr", Section.addr);
384 IO.mapRequired("size", Section.size);
385 IO.mapRequired("offset", Section.offset);
386 IO.mapRequired("align", Section.align);
387 IO.mapRequired("reloff", Section.reloff);
388 IO.mapRequired("nreloc", Section.nreloc);
389 IO.mapRequired("flags", Section.flags);
390 IO.mapRequired("reserved1", Section.reserved1);
391 IO.mapRequired("reserved2", Section.reserved2);
392}
393
394void MappingTraits<MachO::section_64>::mapping(IO &IO,
395 MachO::section_64 &Section) {
396 IO.mapRequired("sectname", Section.sectname);
397 IO.mapRequired("segname", Section.segname);
398 IO.mapRequired("addr", Section.addr);
399 IO.mapRequired("size", Section.size);
400 IO.mapRequired("offset", Section.offset);
401 IO.mapRequired("align", Section.align);
402 IO.mapRequired("reloff", Section.reloff);
403 IO.mapRequired("nreloc", Section.nreloc);
404 IO.mapRequired("flags", Section.flags);
405 IO.mapRequired("reserved1", Section.reserved1);
406 IO.mapRequired("reserved2", Section.reserved2);
407 IO.mapRequired("reserved3", Section.reserved3);
408}
409
410void MappingTraits<MachO::segment_command>::mapping(
411 IO &IO, MachO::segment_command &LoadCommand) {
412
413 IO.mapRequired("segname", LoadCommand.segname);
414 IO.mapRequired("vmaddr", LoadCommand.vmaddr);
415 IO.mapRequired("vmsize", LoadCommand.vmsize);
416 IO.mapRequired("fileoff", LoadCommand.fileoff);
417 IO.mapRequired("filesize", LoadCommand.filesize);
418 IO.mapRequired("maxprot", LoadCommand.maxprot);
419 IO.mapRequired("initprot", LoadCommand.initprot);
420 IO.mapRequired("nsects", LoadCommand.nsects);
421 IO.mapRequired("flags", LoadCommand.flags);
422}
423
424void MappingTraits<MachO::segment_command_64>::mapping(
425 IO &IO, MachO::segment_command_64 &LoadCommand) {
426
427 IO.mapRequired("segname", LoadCommand.segname);
428 IO.mapRequired("vmaddr", LoadCommand.vmaddr);
429 IO.mapRequired("vmsize", LoadCommand.vmsize);
430 IO.mapRequired("fileoff", LoadCommand.fileoff);
431 IO.mapRequired("filesize", LoadCommand.filesize);
432 IO.mapRequired("maxprot", LoadCommand.maxprot);
433 IO.mapRequired("initprot", LoadCommand.initprot);
434 IO.mapRequired("nsects", LoadCommand.nsects);
435 IO.mapRequired("flags", LoadCommand.flags);
436}
437
438void MappingTraits<MachO::source_version_command>::mapping(
439 IO &IO, MachO::source_version_command &LoadCommand) {
440
441 IO.mapRequired("version", LoadCommand.version);
442}
443
444void MappingTraits<MachO::sub_client_command>::mapping(
445 IO &IO, MachO::sub_client_command &LoadCommand) {
446
447 IO.mapRequired("client", LoadCommand.client);
448}
449
450void MappingTraits<MachO::sub_framework_command>::mapping(
451 IO &IO, MachO::sub_framework_command &LoadCommand) {
452
453 IO.mapRequired("umbrella", LoadCommand.umbrella);
454}
455
456void MappingTraits<MachO::sub_library_command>::mapping(
457 IO &IO, MachO::sub_library_command &LoadCommand) {
458
459 IO.mapRequired("sub_library", LoadCommand.sub_library);
460}
461
462void MappingTraits<MachO::sub_umbrella_command>::mapping(
463 IO &IO, MachO::sub_umbrella_command &LoadCommand) {
464
465 IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);
466}
467
468void MappingTraits<MachO::symseg_command>::mapping(
469 IO &IO, MachO::symseg_command &LoadCommand) {
470
471 IO.mapRequired("offset", LoadCommand.offset);
472 IO.mapRequired("size", LoadCommand.size);
473}
474
475void MappingTraits<MachO::symtab_command>::mapping(
476 IO &IO, MachO::symtab_command &LoadCommand) {
477
478 IO.mapRequired("symoff", LoadCommand.symoff);
479 IO.mapRequired("nsyms", LoadCommand.nsyms);
480 IO.mapRequired("stroff", LoadCommand.stroff);
481 IO.mapRequired("strsize", LoadCommand.strsize);
482}
483
484void MappingTraits<MachO::thread_command>::mapping(
485 IO &IO, MachO::thread_command &LoadCommand) {}
486
487void MappingTraits<MachO::twolevel_hints_command>::mapping(
488 IO &IO, MachO::twolevel_hints_command &LoadCommand) {
489
490 IO.mapRequired("offset", LoadCommand.offset);
491 IO.mapRequired("nhints", LoadCommand.nhints);
492}
493
494void MappingTraits<MachO::uuid_command>::mapping(
495 IO &IO, MachO::uuid_command &LoadCommand) {
496
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000497 IO.mapRequired("uuid", LoadCommand.uuid);
498}
499
500void MappingTraits<MachO::version_min_command>::mapping(
501 IO &IO, MachO::version_min_command &LoadCommand) {
502
503 IO.mapRequired("version", LoadCommand.version);
504 IO.mapRequired("sdk", LoadCommand.sdk);
Chris Bieneman8b5906e2016-05-13 17:41:41 +0000505}
506
Chris Bieneman9062ab92016-05-12 16:04:16 +0000507} // namespace llvm::yaml
508
509} // namespace llvm