blob: 0f7cd1e1495cb531a76e8005e655fce20e90da51 [file] [log] [blame]
Chris Bieneman9062ab92016-05-12 16:04:16 +00001//===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Chris Bieneman9062ab92016-05-12 16:04:16 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file defines classes for handling the YAML representation of MachO.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/ObjectYAML/MachOYAML.h"
Eugene Zelenko28082ab2017-07-01 01:35:55 +000014#include "llvm/ADT/StringRef.h"
Zachary Turner264b5d92017-06-07 03:48:56 +000015#include "llvm/BinaryFormat/MachO.h"
Chris Bieneman3f2eb832016-05-17 19:44:06 +000016#include "llvm/Support/Format.h"
Chris Bieneman55de3a22016-12-22 21:58:03 +000017#include "llvm/Support/Host.h"
Eugene Zelenko28082ab2017-07-01 01:35:55 +000018#include "llvm/Support/YAMLTraits.h"
19#include "llvm/Support/raw_ostream.h"
20#include <cinttypes>
21#include <cstdint>
22#include <cstring>
Chris Bieneman9062ab92016-05-12 16:04:16 +000023
24namespace llvm {
25
Eugene Zelenko28082ab2017-07-01 01:35:55 +000026MachOYAML::LoadCommand::~LoadCommand() = default;
Chris Bieneman8b5906e2016-05-13 17:41:41 +000027
Chris Bieneman432ba9d2016-08-17 21:46:04 +000028bool MachOYAML::LinkEditData::isEmpty() const {
Chris Bieneman8b058ae2016-12-06 06:00:49 +000029 return 0 ==
30 RebaseOpcodes.size() + BindOpcodes.size() + WeakBindOpcodes.size() +
31 LazyBindOpcodes.size() + ExportTrie.Children.size() +
32 NameList.size() + StringTable.size();
33}
34
Chris Bieneman9062ab92016-05-12 16:04:16 +000035namespace yaml {
36
Chris Bieneman3f2eb832016-05-17 19:44:06 +000037void ScalarTraits<char_16>::output(const char_16 &Val, void *,
Eugene Zelenko28082ab2017-07-01 01:35:55 +000038 raw_ostream &Out) {
Chris Bieneman2de17d42016-05-18 16:17:23 +000039 auto Len = strnlen(&Val[0], 16);
40 Out << StringRef(&Val[0], Len);
Chris Bieneman3f2eb832016-05-17 19:44:06 +000041}
42
43StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {
44 size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();
45 memcpy((void *)Val, Scalar.data(), CopySize);
46
47 if (Scalar.size() < 16) {
48 memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());
49 }
50
51 return StringRef();
52}
53
Francis Visoiu Mistrihb213b272017-12-18 17:38:03 +000054QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) {
55 return needsQuotes(S);
56}
Chris Bieneman3f2eb832016-05-17 19:44:06 +000057
Eugene Zelenko28082ab2017-07-01 01:35:55 +000058void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) {
Adrian Prantl3dcd1222017-09-13 18:22:59 +000059 Out.write_uuid(Val);
Chris Bieneman3f2eb832016-05-17 19:44:06 +000060}
61
62StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) {
63 size_t OutIdx = 0;
64 for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {
65 if (Scalar[Idx] == '-' || OutIdx >= 16)
66 continue;
67 unsigned long long TempInt;
68 if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))
69 return "invalid number";
70 if (TempInt > 0xFF)
71 return "out of range number";
72 Val[OutIdx] = static_cast<uint8_t>(TempInt);
73 ++Idx; // increment idx an extra time because we're consuming 2 chars
74 ++OutIdx;
75 }
76 return StringRef();
77}
78
Francis Visoiu Mistrihb213b272017-12-18 17:38:03 +000079QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) {
80 return needsQuotes(S);
81}
Chris Bieneman3f2eb832016-05-17 19:44:06 +000082
Chris Bieneman9062ab92016-05-12 16:04:16 +000083void MappingTraits<MachOYAML::FileHeader>::mapping(
84 IO &IO, MachOYAML::FileHeader &FileHdr) {
Chris Bieneman24f07472016-05-12 17:44:43 +000085 IO.mapRequired("magic", FileHdr.magic);
Chris Bieneman9062ab92016-05-12 16:04:16 +000086 IO.mapRequired("cputype", FileHdr.cputype);
87 IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
Chris Bieneman668beb22016-05-12 17:53:01 +000088 IO.mapRequired("filetype", FileHdr.filetype);
Chris Bieneman9062ab92016-05-12 16:04:16 +000089 IO.mapRequired("ncmds", FileHdr.ncmds);
Chris Bieneman24f07472016-05-12 17:44:43 +000090 IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
Chris Bieneman9062ab92016-05-12 16:04:16 +000091 IO.mapRequired("flags", FileHdr.flags);
Chris Bieneman10dcd3b2016-06-23 22:36:31 +000092 if (FileHdr.magic == MachO::MH_MAGIC_64 ||
93 FileHdr.magic == MachO::MH_CIGAM_64)
94 IO.mapRequired("reserved", FileHdr.reserved);
Chris Bieneman9062ab92016-05-12 16:04:16 +000095}
96
97void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
98 MachOYAML::Object &Object) {
99 // If the context isn't already set, tag the document as !mach-o.
100 // For Fat files there will be a different tag so they can be differentiated.
Chris Bieneman24f07472016-05-12 17:44:43 +0000101 if (!IO.getContext()) {
Chris Bieneman9062ab92016-05-12 16:04:16 +0000102 IO.setContext(&Object);
Chris Bieneman9062ab92016-05-12 16:04:16 +0000103 }
Chris Bieneman92b2e8a2016-06-28 21:10:26 +0000104 IO.mapTag("!mach-o", true);
Chris Bieneman55de3a22016-12-22 21:58:03 +0000105 IO.mapOptional("IsLittleEndian", Object.IsLittleEndian,
106 sys::IsLittleEndianHost);
107 Object.DWARF.IsLittleEndian = Object.IsLittleEndian;
108
Chris Bieneman9062ab92016-05-12 16:04:16 +0000109 IO.mapRequired("FileHeader", Object.Header);
Chris Bieneman8b5906e2016-05-13 17:41:41 +0000110 IO.mapOptional("LoadCommands", Object.LoadCommands);
Chris Bieneman432ba9d2016-08-17 21:46:04 +0000111 if(!Object.LinkEdit.isEmpty() || !IO.outputting())
112 IO.mapOptional("LinkEditData", Object.LinkEdit);
Chris Bieneman93e71192016-06-24 20:42:28 +0000113
Chris Bieneman8b058ae2016-12-06 06:00:49 +0000114 if(!Object.DWARF.isEmpty() || !IO.outputting())
115 IO.mapOptional("DWARF", Object.DWARF);
116
Chris Bieneman93e71192016-06-24 20:42:28 +0000117 if (IO.getContext() == &Object)
118 IO.setContext(nullptr);
119}
120
121void MappingTraits<MachOYAML::FatHeader>::mapping(
122 IO &IO, MachOYAML::FatHeader &FatHeader) {
123 IO.mapRequired("magic", FatHeader.magic);
124 IO.mapRequired("nfat_arch", FatHeader.nfat_arch);
125}
126
127void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO,
128 MachOYAML::FatArch &FatArch) {
129 IO.mapRequired("cputype", FatArch.cputype);
130 IO.mapRequired("cpusubtype", FatArch.cpusubtype);
131 IO.mapRequired("offset", FatArch.offset);
132 IO.mapRequired("size", FatArch.size);
133 IO.mapRequired("align", FatArch.align);
134 IO.mapOptional("reserved", FatArch.reserved,
135 static_cast<llvm::yaml::Hex32>(0));
136}
137
138void MappingTraits<MachOYAML::UniversalBinary>::mapping(
139 IO &IO, MachOYAML::UniversalBinary &UniversalBinary) {
140 if (!IO.getContext()) {
141 IO.setContext(&UniversalBinary);
142 IO.mapTag("!fat-mach-o", true);
143 }
144 IO.mapRequired("FatHeader", UniversalBinary.Header);
145 IO.mapRequired("FatArchs", UniversalBinary.FatArchs);
146 IO.mapRequired("Slices", UniversalBinary.Slices);
147
148 if (IO.getContext() == &UniversalBinary)
149 IO.setContext(nullptr);
150}
151
Chris Bieneman524243d2016-05-26 20:06:14 +0000152void MappingTraits<MachOYAML::LinkEditData>::mapping(
153 IO &IO, MachOYAML::LinkEditData &LinkEditData) {
Chris Bienemane8e75552016-05-25 17:09:07 +0000154 IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes);
Chris Bieneman524243d2016-05-26 20:06:14 +0000155 IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);
Chris Bieneman659b35a2016-05-26 20:50:05 +0000156 IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);
Chris Bieneman44474c42016-05-26 21:29:39 +0000157 IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);
Eugene Zelenko28082ab2017-07-01 01:35:55 +0000158 if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting())
Chris Bienemanca5de9d2016-08-11 00:20:03 +0000159 IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);
Chris Bieneman07bb3c82016-06-02 22:54:06 +0000160 IO.mapOptional("NameList", LinkEditData.NameList);
161 IO.mapOptional("StringTable", LinkEditData.StringTable);
Chris Bienemane8e75552016-05-25 17:09:07 +0000162}
163
Chris Bieneman524243d2016-05-26 20:06:14 +0000164void MappingTraits<MachOYAML::RebaseOpcode>::mapping(
165 IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) {
Chris Bienemane8e75552016-05-25 17:09:07 +0000166 IO.mapRequired("Opcode", RebaseOpcode.Opcode);
167 IO.mapRequired("Imm", RebaseOpcode.Imm);
168 IO.mapOptional("ExtraData", RebaseOpcode.ExtraData);
169}
170
Chris Bieneman524243d2016-05-26 20:06:14 +0000171void MappingTraits<MachOYAML::BindOpcode>::mapping(
172 IO &IO, MachOYAML::BindOpcode &BindOpcode) {
173 IO.mapRequired("Opcode", BindOpcode.Opcode);
174 IO.mapRequired("Imm", BindOpcode.Imm);
175 IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData);
176 IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData);
177 IO.mapOptional("Symbol", BindOpcode.Symbol);
178}
179
Chris Bieneman68527752016-05-31 17:26:36 +0000180void MappingTraits<MachOYAML::ExportEntry>::mapping(
181 IO &IO, MachOYAML::ExportEntry &ExportEntry) {
182 IO.mapRequired("TerminalSize", ExportEntry.TerminalSize);
183 IO.mapOptional("NodeOffset", ExportEntry.NodeOffset);
184 IO.mapOptional("Name", ExportEntry.Name);
185 IO.mapOptional("Flags", ExportEntry.Flags);
186 IO.mapOptional("Address", ExportEntry.Address);
187 IO.mapOptional("Other", ExportEntry.Other);
188 IO.mapOptional("ImportName", ExportEntry.ImportName);
189 IO.mapOptional("Children", ExportEntry.Children);
190}
191
Chris Bieneman07bb3c82016-06-02 22:54:06 +0000192void MappingTraits<MachOYAML::NListEntry>::mapping(
193 IO &IO, MachOYAML::NListEntry &NListEntry) {
194 IO.mapRequired("n_strx", NListEntry.n_strx);
195 IO.mapRequired("n_type", NListEntry.n_type);
196 IO.mapRequired("n_sect", NListEntry.n_sect);
197 IO.mapRequired("n_desc", NListEntry.n_desc);
198 IO.mapRequired("n_value", NListEntry.n_value);
199}
200
Chris Bieneman9f243e92016-05-19 20:54:43 +0000201template <typename StructType>
202void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {}
203
204template <>
205void mapLoadCommandData<MachO::segment_command>(
206 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
207 IO.mapOptional("Sections", LoadCommand.Sections);
208}
209
210template <>
211void mapLoadCommandData<MachO::segment_command_64>(
212 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
213 IO.mapOptional("Sections", LoadCommand.Sections);
214}
215
216template <>
217void mapLoadCommandData<MachO::dylib_command>(
218 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
219 IO.mapOptional("PayloadString", LoadCommand.PayloadString);
220}
221
222template <>
Chris Bieneman68527752016-05-31 17:26:36 +0000223void mapLoadCommandData<MachO::rpath_command>(
224 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
225 IO.mapOptional("PayloadString", LoadCommand.PayloadString);
226}
227
228template <>
Chris Bieneman9f243e92016-05-19 20:54:43 +0000229void mapLoadCommandData<MachO::dylinker_command>(
230 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
231 IO.mapOptional("PayloadString", LoadCommand.PayloadString);
232}
233
Steven Wu5b54a422017-01-23 20:07:55 +0000234template <>
235void mapLoadCommandData<MachO::build_version_command>(
236 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
237 IO.mapOptional("Tools", LoadCommand.Tools);
238}
239
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000240void MappingTraits<MachOYAML::LoadCommand>::mapping(
241 IO &IO, MachOYAML::LoadCommand &LoadCommand) {
Chris Bieneman606f1782016-06-23 23:01:47 +0000242 MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>(
243 LoadCommand.Data.load_command_data.cmd);
244 IO.mapRequired("cmd", TempCmd);
245 LoadCommand.Data.load_command_data.cmd = TempCmd;
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000246 IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);
247
248#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
249 case MachO::LCName: \
250 MappingTraits<MachO::LCStruct>::mapping(IO, \
251 LoadCommand.Data.LCStruct##_data); \
Chris Bieneman9f243e92016-05-19 20:54:43 +0000252 mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000253 break;
254
255 switch (LoadCommand.Data.load_command_data.cmd) {
Zachary Turner264b5d92017-06-07 03:48:56 +0000256#include "llvm/BinaryFormat/MachO.def"
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000257 }
Chris Bieneman9f243e92016-05-19 20:54:43 +0000258 IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes);
259 IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull);
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000260}
261
262void MappingTraits<MachO::dyld_info_command>::mapping(
263 IO &IO, MachO::dyld_info_command &LoadCommand) {
264 IO.mapRequired("rebase_off", LoadCommand.rebase_off);
265 IO.mapRequired("rebase_size", LoadCommand.rebase_size);
Chris Bieneman2de17d42016-05-18 16:17:23 +0000266 IO.mapRequired("bind_off", LoadCommand.bind_off);
267 IO.mapRequired("bind_size", LoadCommand.bind_size);
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000268 IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
269 IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
Chris Bieneman2de17d42016-05-18 16:17:23 +0000270 IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
271 IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000272 IO.mapRequired("export_off", LoadCommand.export_off);
273 IO.mapRequired("export_size", LoadCommand.export_size);
274}
275
Chris Bieneman2de17d42016-05-18 16:17:23 +0000276void MappingTraits<MachOYAML::Section>::mapping(IO &IO,
277 MachOYAML::Section &Section) {
278 IO.mapRequired("sectname", Section.sectname);
279 IO.mapRequired("segname", Section.segname);
280 IO.mapRequired("addr", Section.addr);
281 IO.mapRequired("size", Section.size);
282 IO.mapRequired("offset", Section.offset);
283 IO.mapRequired("align", Section.align);
284 IO.mapRequired("reloff", Section.reloff);
285 IO.mapRequired("nreloc", Section.nreloc);
286 IO.mapRequired("flags", Section.flags);
287 IO.mapRequired("reserved1", Section.reserved1);
288 IO.mapRequired("reserved2", Section.reserved2);
289 IO.mapOptional("reserved3", Section.reserved3);
Seiya Nuta52237742019-08-20 08:49:07 +0000290 IO.mapOptional("content", Section.content);
291}
292
293StringRef
294MappingTraits<MachOYAML::Section>::validate(IO &IO,
295 MachOYAML::Section &Section) {
296 if (Section.content && Section.size < Section.content->binary_size())
297 return "Section size must be greater than or equal to the content size";
298 return {};
Chris Bieneman2de17d42016-05-18 16:17:23 +0000299}
300
Steven Wu5b54a422017-01-23 20:07:55 +0000301void MappingTraits<MachO::build_tool_version>::mapping(
302 IO &IO, MachO::build_tool_version &tool) {
303 IO.mapRequired("tool", tool.tool);
304 IO.mapRequired("version", tool.version);
305}
306
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000307void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {
308 IO.mapRequired("name", DylibStruct.name);
309 IO.mapRequired("timestamp", DylibStruct.timestamp);
310 IO.mapRequired("current_version", DylibStruct.current_version);
311 IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);
312}
313
314void MappingTraits<MachO::dylib_command>::mapping(
315 IO &IO, MachO::dylib_command &LoadCommand) {
316 IO.mapRequired("dylib", LoadCommand.dylib);
317}
318
319void MappingTraits<MachO::dylinker_command>::mapping(
320 IO &IO, MachO::dylinker_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000321 IO.mapRequired("name", LoadCommand.name);
322}
323
324void MappingTraits<MachO::dysymtab_command>::mapping(
325 IO &IO, MachO::dysymtab_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000326 IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);
327 IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);
328 IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);
329 IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);
330 IO.mapRequired("iundefsym", LoadCommand.iundefsym);
331 IO.mapRequired("nundefsym", LoadCommand.nundefsym);
332 IO.mapRequired("tocoff", LoadCommand.tocoff);
333 IO.mapRequired("ntoc", LoadCommand.ntoc);
334 IO.mapRequired("modtaboff", LoadCommand.modtaboff);
335 IO.mapRequired("nmodtab", LoadCommand.nmodtab);
336 IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);
337 IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);
338 IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);
339 IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);
340 IO.mapRequired("extreloff", LoadCommand.extreloff);
341 IO.mapRequired("nextrel", LoadCommand.nextrel);
342 IO.mapRequired("locreloff", LoadCommand.locreloff);
343 IO.mapRequired("nlocrel", LoadCommand.nlocrel);
344}
345
346void MappingTraits<MachO::encryption_info_command>::mapping(
347 IO &IO, MachO::encryption_info_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000348 IO.mapRequired("cryptoff", LoadCommand.cryptoff);
349 IO.mapRequired("cryptsize", LoadCommand.cryptsize);
350 IO.mapRequired("cryptid", LoadCommand.cryptid);
351}
352
353void MappingTraits<MachO::encryption_info_command_64>::mapping(
354 IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000355 IO.mapRequired("cryptoff", LoadCommand.cryptoff);
356 IO.mapRequired("cryptsize", LoadCommand.cryptsize);
357 IO.mapRequired("cryptid", LoadCommand.cryptid);
358 IO.mapRequired("pad", LoadCommand.pad);
359}
360
361void MappingTraits<MachO::entry_point_command>::mapping(
362 IO &IO, MachO::entry_point_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000363 IO.mapRequired("entryoff", LoadCommand.entryoff);
364 IO.mapRequired("stacksize", LoadCommand.stacksize);
365}
366
367void MappingTraits<MachO::fvmfile_command>::mapping(
368 IO &IO, MachO::fvmfile_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000369 IO.mapRequired("name", LoadCommand.name);
370 IO.mapRequired("header_addr", LoadCommand.header_addr);
371}
372
373void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {
374 IO.mapRequired("name", FVMLib.name);
375 IO.mapRequired("minor_version", FVMLib.minor_version);
376 IO.mapRequired("header_addr", FVMLib.header_addr);
377}
378
379void MappingTraits<MachO::fvmlib_command>::mapping(
380 IO &IO, MachO::fvmlib_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000381 IO.mapRequired("fvmlib", LoadCommand.fvmlib);
382}
383
384void MappingTraits<MachO::ident_command>::mapping(
385 IO &IO, MachO::ident_command &LoadCommand) {}
386
387void MappingTraits<MachO::linkedit_data_command>::mapping(
388 IO &IO, MachO::linkedit_data_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000389 IO.mapRequired("dataoff", LoadCommand.dataoff);
390 IO.mapRequired("datasize", LoadCommand.datasize);
391}
392
393void MappingTraits<MachO::linker_option_command>::mapping(
394 IO &IO, MachO::linker_option_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000395 IO.mapRequired("count", LoadCommand.count);
396}
397
398void MappingTraits<MachO::prebind_cksum_command>::mapping(
399 IO &IO, MachO::prebind_cksum_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000400 IO.mapRequired("cksum", LoadCommand.cksum);
401}
402
403void MappingTraits<MachO::load_command>::mapping(
404 IO &IO, MachO::load_command &LoadCommand) {}
405
406void MappingTraits<MachO::prebound_dylib_command>::mapping(
407 IO &IO, MachO::prebound_dylib_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000408 IO.mapRequired("name", LoadCommand.name);
409 IO.mapRequired("nmodules", LoadCommand.nmodules);
410 IO.mapRequired("linked_modules", LoadCommand.linked_modules);
411}
412
413void MappingTraits<MachO::routines_command>::mapping(
414 IO &IO, MachO::routines_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000415 IO.mapRequired("init_address", LoadCommand.init_address);
416 IO.mapRequired("init_module", LoadCommand.init_module);
417 IO.mapRequired("reserved1", LoadCommand.reserved1);
418 IO.mapRequired("reserved2", LoadCommand.reserved2);
419 IO.mapRequired("reserved3", LoadCommand.reserved3);
420 IO.mapRequired("reserved4", LoadCommand.reserved4);
421 IO.mapRequired("reserved5", LoadCommand.reserved5);
422 IO.mapRequired("reserved6", LoadCommand.reserved6);
423}
424
425void MappingTraits<MachO::routines_command_64>::mapping(
426 IO &IO, MachO::routines_command_64 &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000427 IO.mapRequired("init_address", LoadCommand.init_address);
428 IO.mapRequired("init_module", LoadCommand.init_module);
429 IO.mapRequired("reserved1", LoadCommand.reserved1);
430 IO.mapRequired("reserved2", LoadCommand.reserved2);
431 IO.mapRequired("reserved3", LoadCommand.reserved3);
432 IO.mapRequired("reserved4", LoadCommand.reserved4);
433 IO.mapRequired("reserved5", LoadCommand.reserved5);
434 IO.mapRequired("reserved6", LoadCommand.reserved6);
435}
436
437void MappingTraits<MachO::rpath_command>::mapping(
438 IO &IO, MachO::rpath_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000439 IO.mapRequired("path", LoadCommand.path);
440}
441
442void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) {
443 IO.mapRequired("sectname", Section.sectname);
444 IO.mapRequired("segname", Section.segname);
445 IO.mapRequired("addr", Section.addr);
446 IO.mapRequired("size", Section.size);
447 IO.mapRequired("offset", Section.offset);
448 IO.mapRequired("align", Section.align);
449 IO.mapRequired("reloff", Section.reloff);
450 IO.mapRequired("nreloc", Section.nreloc);
451 IO.mapRequired("flags", Section.flags);
452 IO.mapRequired("reserved1", Section.reserved1);
453 IO.mapRequired("reserved2", Section.reserved2);
454}
455
456void MappingTraits<MachO::section_64>::mapping(IO &IO,
457 MachO::section_64 &Section) {
458 IO.mapRequired("sectname", Section.sectname);
459 IO.mapRequired("segname", Section.segname);
460 IO.mapRequired("addr", Section.addr);
461 IO.mapRequired("size", Section.size);
462 IO.mapRequired("offset", Section.offset);
463 IO.mapRequired("align", Section.align);
464 IO.mapRequired("reloff", Section.reloff);
465 IO.mapRequired("nreloc", Section.nreloc);
466 IO.mapRequired("flags", Section.flags);
467 IO.mapRequired("reserved1", Section.reserved1);
468 IO.mapRequired("reserved2", Section.reserved2);
469 IO.mapRequired("reserved3", Section.reserved3);
470}
471
472void MappingTraits<MachO::segment_command>::mapping(
473 IO &IO, MachO::segment_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000474 IO.mapRequired("segname", LoadCommand.segname);
475 IO.mapRequired("vmaddr", LoadCommand.vmaddr);
476 IO.mapRequired("vmsize", LoadCommand.vmsize);
477 IO.mapRequired("fileoff", LoadCommand.fileoff);
478 IO.mapRequired("filesize", LoadCommand.filesize);
479 IO.mapRequired("maxprot", LoadCommand.maxprot);
480 IO.mapRequired("initprot", LoadCommand.initprot);
481 IO.mapRequired("nsects", LoadCommand.nsects);
482 IO.mapRequired("flags", LoadCommand.flags);
483}
484
485void MappingTraits<MachO::segment_command_64>::mapping(
486 IO &IO, MachO::segment_command_64 &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000487 IO.mapRequired("segname", LoadCommand.segname);
488 IO.mapRequired("vmaddr", LoadCommand.vmaddr);
489 IO.mapRequired("vmsize", LoadCommand.vmsize);
490 IO.mapRequired("fileoff", LoadCommand.fileoff);
491 IO.mapRequired("filesize", LoadCommand.filesize);
492 IO.mapRequired("maxprot", LoadCommand.maxprot);
493 IO.mapRequired("initprot", LoadCommand.initprot);
494 IO.mapRequired("nsects", LoadCommand.nsects);
495 IO.mapRequired("flags", LoadCommand.flags);
496}
497
498void MappingTraits<MachO::source_version_command>::mapping(
499 IO &IO, MachO::source_version_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000500 IO.mapRequired("version", LoadCommand.version);
501}
502
503void MappingTraits<MachO::sub_client_command>::mapping(
504 IO &IO, MachO::sub_client_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000505 IO.mapRequired("client", LoadCommand.client);
506}
507
508void MappingTraits<MachO::sub_framework_command>::mapping(
509 IO &IO, MachO::sub_framework_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000510 IO.mapRequired("umbrella", LoadCommand.umbrella);
511}
512
513void MappingTraits<MachO::sub_library_command>::mapping(
514 IO &IO, MachO::sub_library_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000515 IO.mapRequired("sub_library", LoadCommand.sub_library);
516}
517
518void MappingTraits<MachO::sub_umbrella_command>::mapping(
519 IO &IO, MachO::sub_umbrella_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000520 IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);
521}
522
523void MappingTraits<MachO::symseg_command>::mapping(
524 IO &IO, MachO::symseg_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000525 IO.mapRequired("offset", LoadCommand.offset);
526 IO.mapRequired("size", LoadCommand.size);
527}
528
529void MappingTraits<MachO::symtab_command>::mapping(
530 IO &IO, MachO::symtab_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000531 IO.mapRequired("symoff", LoadCommand.symoff);
532 IO.mapRequired("nsyms", LoadCommand.nsyms);
533 IO.mapRequired("stroff", LoadCommand.stroff);
534 IO.mapRequired("strsize", LoadCommand.strsize);
535}
536
537void MappingTraits<MachO::thread_command>::mapping(
538 IO &IO, MachO::thread_command &LoadCommand) {}
539
540void MappingTraits<MachO::twolevel_hints_command>::mapping(
541 IO &IO, MachO::twolevel_hints_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000542 IO.mapRequired("offset", LoadCommand.offset);
543 IO.mapRequired("nhints", LoadCommand.nhints);
544}
545
546void MappingTraits<MachO::uuid_command>::mapping(
547 IO &IO, MachO::uuid_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000548 IO.mapRequired("uuid", LoadCommand.uuid);
549}
550
551void MappingTraits<MachO::version_min_command>::mapping(
552 IO &IO, MachO::version_min_command &LoadCommand) {
Chris Bieneman3f2eb832016-05-17 19:44:06 +0000553 IO.mapRequired("version", LoadCommand.version);
554 IO.mapRequired("sdk", LoadCommand.sdk);
Chris Bieneman8b5906e2016-05-13 17:41:41 +0000555}
556
Kevin Enderbya4579c42017-01-19 17:36:31 +0000557void MappingTraits<MachO::note_command>::mapping(
558 IO &IO, MachO::note_command &LoadCommand) {
Kevin Enderbya4579c42017-01-19 17:36:31 +0000559 IO.mapRequired("data_owner", LoadCommand.data_owner);
560 IO.mapRequired("offset", LoadCommand.offset);
561 IO.mapRequired("size", LoadCommand.size);
562}
563
Steven Wu5b54a422017-01-23 20:07:55 +0000564void MappingTraits<MachO::build_version_command>::mapping(
565 IO &IO, MachO::build_version_command &LoadCommand) {
Steven Wu5b54a422017-01-23 20:07:55 +0000566 IO.mapRequired("platform", LoadCommand.platform);
567 IO.mapRequired("minos", LoadCommand.minos);
568 IO.mapRequired("sdk", LoadCommand.sdk);
569 IO.mapRequired("ntools", LoadCommand.ntools);
570}
571
Eugene Zelenko28082ab2017-07-01 01:35:55 +0000572} // end namespace yaml
Chris Bieneman9062ab92016-05-12 16:04:16 +0000573
Eugene Zelenko28082ab2017-07-01 01:35:55 +0000574} // end namespace llvm