19062ab94SChris Bieneman //===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===//
29062ab94SChris Bieneman //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
69062ab94SChris Bieneman //
79062ab94SChris Bieneman //===----------------------------------------------------------------------===//
89062ab94SChris Bieneman //
99062ab94SChris Bieneman // This file defines classes for handling the YAML representation of MachO.
109062ab94SChris Bieneman //
119062ab94SChris Bieneman //===----------------------------------------------------------------------===//
129062ab94SChris Bieneman
139062ab94SChris Bieneman #include "llvm/ObjectYAML/MachOYAML.h"
1428082ab0SEugene Zelenko #include "llvm/ADT/StringRef.h"
15264b5d9eSZachary Turner #include "llvm/BinaryFormat/MachO.h"
163f2eb836SChris Bieneman #include "llvm/Support/Format.h"
1755de3a24SChris Bieneman #include "llvm/Support/Host.h"
1828082ab0SEugene Zelenko #include "llvm/Support/YAMLTraits.h"
1928082ab0SEugene Zelenko #include "llvm/Support/raw_ostream.h"
2028082ab0SEugene Zelenko #include <cinttypes>
2128082ab0SEugene Zelenko #include <cstdint>
2228082ab0SEugene Zelenko #include <cstring>
239062ab94SChris Bieneman
249062ab94SChris Bieneman namespace llvm {
259062ab94SChris Bieneman
2628082ab0SEugene Zelenko MachOYAML::LoadCommand::~LoadCommand() = default;
278b5906eaSChris Bieneman
isEmpty() const28432ba9d8SChris Bieneman bool MachOYAML::LinkEditData::isEmpty() const {
29*a6e1b3c5SKeith Smiley return 0 == RebaseOpcodes.size() + BindOpcodes.size() +
30*a6e1b3c5SKeith Smiley WeakBindOpcodes.size() + LazyBindOpcodes.size() +
31*a6e1b3c5SKeith Smiley ExportTrie.Children.size() + NameList.size() +
32*a6e1b3c5SKeith Smiley StringTable.size() + FunctionStarts.size();
338b058aecSChris Bieneman }
348b058aecSChris Bieneman
359062ab94SChris Bieneman namespace yaml {
369062ab94SChris Bieneman
output(const char_16 & Val,void *,raw_ostream & Out)373f2eb836SChris Bieneman void ScalarTraits<char_16>::output(const char_16 &Val, void *,
3828082ab0SEugene Zelenko raw_ostream &Out) {
392de17d49SChris Bieneman auto Len = strnlen(&Val[0], 16);
402de17d49SChris Bieneman Out << StringRef(&Val[0], Len);
413f2eb836SChris Bieneman }
423f2eb836SChris Bieneman
input(StringRef Scalar,void *,char_16 & Val)433f2eb836SChris Bieneman StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {
443f2eb836SChris Bieneman size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();
453f2eb836SChris Bieneman memcpy((void *)Val, Scalar.data(), CopySize);
463f2eb836SChris Bieneman
473f2eb836SChris Bieneman if (Scalar.size() < 16) {
483f2eb836SChris Bieneman memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());
493f2eb836SChris Bieneman }
503f2eb836SChris Bieneman
513f2eb836SChris Bieneman return StringRef();
523f2eb836SChris Bieneman }
533f2eb836SChris Bieneman
mustQuote(StringRef S)54b213b27eSFrancis Visoiu Mistrih QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) {
55b213b27eSFrancis Visoiu Mistrih return needsQuotes(S);
56b213b27eSFrancis Visoiu Mistrih }
573f2eb836SChris Bieneman
output(const uuid_t & Val,void *,raw_ostream & Out)5828082ab0SEugene Zelenko void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) {
593dcd1221SAdrian Prantl Out.write_uuid(Val);
603f2eb836SChris Bieneman }
613f2eb836SChris Bieneman
input(StringRef Scalar,void *,uuid_t & Val)623f2eb836SChris Bieneman StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) {
633f2eb836SChris Bieneman size_t OutIdx = 0;
643f2eb836SChris Bieneman for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {
653f2eb836SChris Bieneman if (Scalar[Idx] == '-' || OutIdx >= 16)
663f2eb836SChris Bieneman continue;
673f2eb836SChris Bieneman unsigned long long TempInt;
683f2eb836SChris Bieneman if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))
693f2eb836SChris Bieneman return "invalid number";
703f2eb836SChris Bieneman if (TempInt > 0xFF)
713f2eb836SChris Bieneman return "out of range number";
723f2eb836SChris Bieneman Val[OutIdx] = static_cast<uint8_t>(TempInt);
733f2eb836SChris Bieneman ++Idx; // increment idx an extra time because we're consuming 2 chars
743f2eb836SChris Bieneman ++OutIdx;
753f2eb836SChris Bieneman }
763f2eb836SChris Bieneman return StringRef();
773f2eb836SChris Bieneman }
783f2eb836SChris Bieneman
mustQuote(StringRef S)79b213b27eSFrancis Visoiu Mistrih QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) {
80b213b27eSFrancis Visoiu Mistrih return needsQuotes(S);
81b213b27eSFrancis Visoiu Mistrih }
823f2eb836SChris Bieneman
mapping(IO & IO,MachOYAML::FileHeader & FileHdr)839062ab94SChris Bieneman void MappingTraits<MachOYAML::FileHeader>::mapping(
849062ab94SChris Bieneman IO &IO, MachOYAML::FileHeader &FileHdr) {
8524f07478SChris Bieneman IO.mapRequired("magic", FileHdr.magic);
869062ab94SChris Bieneman IO.mapRequired("cputype", FileHdr.cputype);
879062ab94SChris Bieneman IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
88668beb2cSChris Bieneman IO.mapRequired("filetype", FileHdr.filetype);
899062ab94SChris Bieneman IO.mapRequired("ncmds", FileHdr.ncmds);
9024f07478SChris Bieneman IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
919062ab94SChris Bieneman IO.mapRequired("flags", FileHdr.flags);
9210dcd3bdSChris Bieneman if (FileHdr.magic == MachO::MH_MAGIC_64 ||
9310dcd3bdSChris Bieneman FileHdr.magic == MachO::MH_CIGAM_64)
9410dcd3bdSChris Bieneman IO.mapRequired("reserved", FileHdr.reserved);
959062ab94SChris Bieneman }
969062ab94SChris Bieneman
mapping(IO & IO,MachOYAML::Object & Object)979062ab94SChris Bieneman void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
989062ab94SChris Bieneman MachOYAML::Object &Object) {
999062ab94SChris Bieneman // If the context isn't already set, tag the document as !mach-o.
1009062ab94SChris Bieneman // For Fat files there will be a different tag so they can be differentiated.
1019062ab94SChris Bieneman if (!IO.getContext()) {
1029062ab94SChris Bieneman IO.setContext(&Object);
1039062ab94SChris Bieneman }
10492b2e8a2SChris Bieneman IO.mapTag("!mach-o", true);
10555de3a24SChris Bieneman IO.mapOptional("IsLittleEndian", Object.IsLittleEndian,
10655de3a24SChris Bieneman sys::IsLittleEndianHost);
10755de3a24SChris Bieneman Object.DWARF.IsLittleEndian = Object.IsLittleEndian;
10855de3a24SChris Bieneman
1099062ab94SChris Bieneman IO.mapRequired("FileHeader", Object.Header);
110830a7c2aSXing GUO Object.DWARF.Is64BitAddrSize = Object.Header.magic == MachO::MH_MAGIC_64 ||
111ff9c1ae2SXing GUO Object.Header.magic == MachO::MH_CIGAM_64;
1128b5906eaSChris Bieneman IO.mapOptional("LoadCommands", Object.LoadCommands);
1138bd8dd16SAdrian Prantl
1148bd8dd16SAdrian Prantl if (Object.RawLinkEditSegment || !IO.outputting())
1158bd8dd16SAdrian Prantl IO.mapOptional("__LINKEDIT", Object.RawLinkEditSegment);
116432ba9d8SChris Bieneman if(!Object.LinkEdit.isEmpty() || !IO.outputting())
117e8e7555bSChris Bieneman IO.mapOptional("LinkEditData", Object.LinkEdit);
11893e71193SChris Bieneman
1198b058aecSChris Bieneman if(!Object.DWARF.isEmpty() || !IO.outputting())
1208b058aecSChris Bieneman IO.mapOptional("DWARF", Object.DWARF);
1218b058aecSChris Bieneman
12293e71193SChris Bieneman if (IO.getContext() == &Object)
12393e71193SChris Bieneman IO.setContext(nullptr);
12493e71193SChris Bieneman }
12593e71193SChris Bieneman
mapping(IO & IO,MachOYAML::FatHeader & FatHeader)12693e71193SChris Bieneman void MappingTraits<MachOYAML::FatHeader>::mapping(
12793e71193SChris Bieneman IO &IO, MachOYAML::FatHeader &FatHeader) {
12893e71193SChris Bieneman IO.mapRequired("magic", FatHeader.magic);
12993e71193SChris Bieneman IO.mapRequired("nfat_arch", FatHeader.nfat_arch);
13093e71193SChris Bieneman }
13193e71193SChris Bieneman
mapping(IO & IO,MachOYAML::FatArch & FatArch)13293e71193SChris Bieneman void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO,
13393e71193SChris Bieneman MachOYAML::FatArch &FatArch) {
13493e71193SChris Bieneman IO.mapRequired("cputype", FatArch.cputype);
13593e71193SChris Bieneman IO.mapRequired("cpusubtype", FatArch.cpusubtype);
13693e71193SChris Bieneman IO.mapRequired("offset", FatArch.offset);
13793e71193SChris Bieneman IO.mapRequired("size", FatArch.size);
13893e71193SChris Bieneman IO.mapRequired("align", FatArch.align);
13993e71193SChris Bieneman IO.mapOptional("reserved", FatArch.reserved,
14093e71193SChris Bieneman static_cast<llvm::yaml::Hex32>(0));
14193e71193SChris Bieneman }
14293e71193SChris Bieneman
mapping(IO & IO,MachOYAML::UniversalBinary & UniversalBinary)14393e71193SChris Bieneman void MappingTraits<MachOYAML::UniversalBinary>::mapping(
14493e71193SChris Bieneman IO &IO, MachOYAML::UniversalBinary &UniversalBinary) {
14593e71193SChris Bieneman if (!IO.getContext()) {
14693e71193SChris Bieneman IO.setContext(&UniversalBinary);
14793e71193SChris Bieneman IO.mapTag("!fat-mach-o", true);
14893e71193SChris Bieneman }
14993e71193SChris Bieneman IO.mapRequired("FatHeader", UniversalBinary.Header);
15093e71193SChris Bieneman IO.mapRequired("FatArchs", UniversalBinary.FatArchs);
15193e71193SChris Bieneman IO.mapRequired("Slices", UniversalBinary.Slices);
15293e71193SChris Bieneman
15393e71193SChris Bieneman if (IO.getContext() == &UniversalBinary)
15493e71193SChris Bieneman IO.setContext(nullptr);
15593e71193SChris Bieneman }
15693e71193SChris Bieneman
mapping(IO & IO,MachOYAML::LinkEditData & LinkEditData)157524243d6SChris Bieneman void MappingTraits<MachOYAML::LinkEditData>::mapping(
158524243d6SChris Bieneman IO &IO, MachOYAML::LinkEditData &LinkEditData) {
159e8e7555bSChris Bieneman IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes);
160524243d6SChris Bieneman IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);
161659b35a5SChris Bieneman IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);
16244474c48SChris Bieneman IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);
16328082ab0SEugene Zelenko if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting())
16468527754SChris Bieneman IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);
16507bb3c84SChris Bieneman IO.mapOptional("NameList", LinkEditData.NameList);
16607bb3c84SChris Bieneman IO.mapOptional("StringTable", LinkEditData.StringTable);
167b83a4222SVincent Lee IO.mapOptional("IndirectSymbols", LinkEditData.IndirectSymbols);
168*a6e1b3c5SKeith Smiley IO.mapOptional("FunctionStarts", LinkEditData.FunctionStarts);
169e8e7555bSChris Bieneman }
170e8e7555bSChris Bieneman
mapping(IO & IO,MachOYAML::RebaseOpcode & RebaseOpcode)171524243d6SChris Bieneman void MappingTraits<MachOYAML::RebaseOpcode>::mapping(
172524243d6SChris Bieneman IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) {
173e8e7555bSChris Bieneman IO.mapRequired("Opcode", RebaseOpcode.Opcode);
174e8e7555bSChris Bieneman IO.mapRequired("Imm", RebaseOpcode.Imm);
175e8e7555bSChris Bieneman IO.mapOptional("ExtraData", RebaseOpcode.ExtraData);
176e8e7555bSChris Bieneman }
177e8e7555bSChris Bieneman
mapping(IO & IO,MachOYAML::BindOpcode & BindOpcode)178524243d6SChris Bieneman void MappingTraits<MachOYAML::BindOpcode>::mapping(
179524243d6SChris Bieneman IO &IO, MachOYAML::BindOpcode &BindOpcode) {
180524243d6SChris Bieneman IO.mapRequired("Opcode", BindOpcode.Opcode);
181524243d6SChris Bieneman IO.mapRequired("Imm", BindOpcode.Imm);
182524243d6SChris Bieneman IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData);
183524243d6SChris Bieneman IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData);
184524243d6SChris Bieneman IO.mapOptional("Symbol", BindOpcode.Symbol);
185524243d6SChris Bieneman }
186524243d6SChris Bieneman
mapping(IO & IO,MachOYAML::ExportEntry & ExportEntry)18768527754SChris Bieneman void MappingTraits<MachOYAML::ExportEntry>::mapping(
18868527754SChris Bieneman IO &IO, MachOYAML::ExportEntry &ExportEntry) {
18968527754SChris Bieneman IO.mapRequired("TerminalSize", ExportEntry.TerminalSize);
19068527754SChris Bieneman IO.mapOptional("NodeOffset", ExportEntry.NodeOffset);
19168527754SChris Bieneman IO.mapOptional("Name", ExportEntry.Name);
19268527754SChris Bieneman IO.mapOptional("Flags", ExportEntry.Flags);
19368527754SChris Bieneman IO.mapOptional("Address", ExportEntry.Address);
19468527754SChris Bieneman IO.mapOptional("Other", ExportEntry.Other);
19568527754SChris Bieneman IO.mapOptional("ImportName", ExportEntry.ImportName);
19668527754SChris Bieneman IO.mapOptional("Children", ExportEntry.Children);
19768527754SChris Bieneman }
19868527754SChris Bieneman
mapping(IO & IO,MachOYAML::NListEntry & NListEntry)19907bb3c84SChris Bieneman void MappingTraits<MachOYAML::NListEntry>::mapping(
20007bb3c84SChris Bieneman IO &IO, MachOYAML::NListEntry &NListEntry) {
20107bb3c84SChris Bieneman IO.mapRequired("n_strx", NListEntry.n_strx);
20207bb3c84SChris Bieneman IO.mapRequired("n_type", NListEntry.n_type);
20307bb3c84SChris Bieneman IO.mapRequired("n_sect", NListEntry.n_sect);
20407bb3c84SChris Bieneman IO.mapRequired("n_desc", NListEntry.n_desc);
20507bb3c84SChris Bieneman IO.mapRequired("n_value", NListEntry.n_value);
20607bb3c84SChris Bieneman }
20707bb3c84SChris Bieneman
2089f243e9aSChris Bieneman template <typename StructType>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)2099f243e9aSChris Bieneman void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {}
2109f243e9aSChris Bieneman
2119f243e9aSChris Bieneman template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)2129f243e9aSChris Bieneman void mapLoadCommandData<MachO::segment_command>(
2139f243e9aSChris Bieneman IO &IO, MachOYAML::LoadCommand &LoadCommand) {
2149f243e9aSChris Bieneman IO.mapOptional("Sections", LoadCommand.Sections);
2159f243e9aSChris Bieneman }
2169f243e9aSChris Bieneman
2179f243e9aSChris Bieneman template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)2189f243e9aSChris Bieneman void mapLoadCommandData<MachO::segment_command_64>(
2199f243e9aSChris Bieneman IO &IO, MachOYAML::LoadCommand &LoadCommand) {
2209f243e9aSChris Bieneman IO.mapOptional("Sections", LoadCommand.Sections);
2219f243e9aSChris Bieneman }
2229f243e9aSChris Bieneman
2239f243e9aSChris Bieneman template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)2249f243e9aSChris Bieneman void mapLoadCommandData<MachO::dylib_command>(
2259f243e9aSChris Bieneman IO &IO, MachOYAML::LoadCommand &LoadCommand) {
226c0da287cSFangrui Song IO.mapOptional("Content", LoadCommand.Content);
2279f243e9aSChris Bieneman }
2289f243e9aSChris Bieneman
2299f243e9aSChris Bieneman template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)23068527754SChris Bieneman void mapLoadCommandData<MachO::rpath_command>(
23168527754SChris Bieneman IO &IO, MachOYAML::LoadCommand &LoadCommand) {
232c0da287cSFangrui Song IO.mapOptional("Content", LoadCommand.Content);
23368527754SChris Bieneman }
23468527754SChris Bieneman
23568527754SChris Bieneman template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)2369f243e9aSChris Bieneman void mapLoadCommandData<MachO::dylinker_command>(
2379f243e9aSChris Bieneman IO &IO, MachOYAML::LoadCommand &LoadCommand) {
238c0da287cSFangrui Song IO.mapOptional("Content", LoadCommand.Content);
2399f243e9aSChris Bieneman }
2409f243e9aSChris Bieneman
2415b54a42cSSteven Wu template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)242d6704e5eSDaniel Rodríguez Troitiño void mapLoadCommandData<MachO::sub_framework_command>(
243d6704e5eSDaniel Rodríguez Troitiño IO &IO, MachOYAML::LoadCommand &LoadCommand) {
244d6704e5eSDaniel Rodríguez Troitiño IO.mapOptional("Content", LoadCommand.Content);
245d6704e5eSDaniel Rodríguez Troitiño }
246d6704e5eSDaniel Rodríguez Troitiño
247d6704e5eSDaniel Rodríguez Troitiño template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)248d6704e5eSDaniel Rodríguez Troitiño void mapLoadCommandData<MachO::sub_umbrella_command>(
249d6704e5eSDaniel Rodríguez Troitiño IO &IO, MachOYAML::LoadCommand &LoadCommand) {
250d6704e5eSDaniel Rodríguez Troitiño IO.mapOptional("Content", LoadCommand.Content);
251d6704e5eSDaniel Rodríguez Troitiño }
252d6704e5eSDaniel Rodríguez Troitiño
253d6704e5eSDaniel Rodríguez Troitiño template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)254d6704e5eSDaniel Rodríguez Troitiño void mapLoadCommandData<MachO::sub_client_command>(
255d6704e5eSDaniel Rodríguez Troitiño IO &IO, MachOYAML::LoadCommand &LoadCommand) {
256d6704e5eSDaniel Rodríguez Troitiño IO.mapOptional("Content", LoadCommand.Content);
257d6704e5eSDaniel Rodríguez Troitiño }
258d6704e5eSDaniel Rodríguez Troitiño
259d6704e5eSDaniel Rodríguez Troitiño template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)260d6704e5eSDaniel Rodríguez Troitiño void mapLoadCommandData<MachO::sub_library_command>(
261d6704e5eSDaniel Rodríguez Troitiño IO &IO, MachOYAML::LoadCommand &LoadCommand) {
262d6704e5eSDaniel Rodríguez Troitiño IO.mapOptional("Content", LoadCommand.Content);
263d6704e5eSDaniel Rodríguez Troitiño }
264d6704e5eSDaniel Rodríguez Troitiño
265d6704e5eSDaniel Rodríguez Troitiño template <>
mapLoadCommandData(IO & IO,MachOYAML::LoadCommand & LoadCommand)2665b54a42cSSteven Wu void mapLoadCommandData<MachO::build_version_command>(
2675b54a42cSSteven Wu IO &IO, MachOYAML::LoadCommand &LoadCommand) {
2685b54a42cSSteven Wu IO.mapOptional("Tools", LoadCommand.Tools);
2695b54a42cSSteven Wu }
2705b54a42cSSteven Wu
mapping(IO & IO,MachOYAML::LoadCommand & LoadCommand)2713f2eb836SChris Bieneman void MappingTraits<MachOYAML::LoadCommand>::mapping(
2723f2eb836SChris Bieneman IO &IO, MachOYAML::LoadCommand &LoadCommand) {
273606f178aSChris Bieneman MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>(
274606f178aSChris Bieneman LoadCommand.Data.load_command_data.cmd);
275606f178aSChris Bieneman IO.mapRequired("cmd", TempCmd);
276606f178aSChris Bieneman LoadCommand.Data.load_command_data.cmd = TempCmd;
2773f2eb836SChris Bieneman IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);
2783f2eb836SChris Bieneman
2793f2eb836SChris Bieneman #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
2803f2eb836SChris Bieneman case MachO::LCName: \
2813f2eb836SChris Bieneman MappingTraits<MachO::LCStruct>::mapping(IO, \
2823f2eb836SChris Bieneman LoadCommand.Data.LCStruct##_data); \
2839f243e9aSChris Bieneman mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \
2843f2eb836SChris Bieneman break;
2853f2eb836SChris Bieneman
2863f2eb836SChris Bieneman switch (LoadCommand.Data.load_command_data.cmd) {
287264b5d9eSZachary Turner #include "llvm/BinaryFormat/MachO.def"
2883f2eb836SChris Bieneman }
2899f243e9aSChris Bieneman IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes);
2909f243e9aSChris Bieneman IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull);
2913f2eb836SChris Bieneman }
2923f2eb836SChris Bieneman
mapping(IO & IO,MachO::dyld_info_command & LoadCommand)2933f2eb836SChris Bieneman void MappingTraits<MachO::dyld_info_command>::mapping(
2943f2eb836SChris Bieneman IO &IO, MachO::dyld_info_command &LoadCommand) {
2953f2eb836SChris Bieneman IO.mapRequired("rebase_off", LoadCommand.rebase_off);
2963f2eb836SChris Bieneman IO.mapRequired("rebase_size", LoadCommand.rebase_size);
2972de17d49SChris Bieneman IO.mapRequired("bind_off", LoadCommand.bind_off);
2982de17d49SChris Bieneman IO.mapRequired("bind_size", LoadCommand.bind_size);
2993f2eb836SChris Bieneman IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);
3003f2eb836SChris Bieneman IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);
3012de17d49SChris Bieneman IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);
3022de17d49SChris Bieneman IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);
3033f2eb836SChris Bieneman IO.mapRequired("export_off", LoadCommand.export_off);
3043f2eb836SChris Bieneman IO.mapRequired("export_size", LoadCommand.export_size);
3053f2eb836SChris Bieneman }
3063f2eb836SChris Bieneman
mapping(IO & IO,MachOYAML::Relocation & Relocation)307c19c3293SAlexander Shaposhnikov void MappingTraits<MachOYAML::Relocation>::mapping(
308c19c3293SAlexander Shaposhnikov IO &IO, MachOYAML::Relocation &Relocation) {
309c19c3293SAlexander Shaposhnikov IO.mapRequired("address", Relocation.address);
310c19c3293SAlexander Shaposhnikov IO.mapRequired("symbolnum", Relocation.symbolnum);
311c19c3293SAlexander Shaposhnikov IO.mapRequired("pcrel", Relocation.is_pcrel);
312c19c3293SAlexander Shaposhnikov IO.mapRequired("length", Relocation.length);
313c19c3293SAlexander Shaposhnikov IO.mapRequired("extern", Relocation.is_extern);
314c19c3293SAlexander Shaposhnikov IO.mapRequired("type", Relocation.type);
315c19c3293SAlexander Shaposhnikov IO.mapRequired("scattered", Relocation.is_scattered);
316c19c3293SAlexander Shaposhnikov IO.mapRequired("value", Relocation.value);
317c19c3293SAlexander Shaposhnikov }
318c19c3293SAlexander Shaposhnikov
mapping(IO & IO,MachOYAML::Section & Section)3192de17d49SChris Bieneman void MappingTraits<MachOYAML::Section>::mapping(IO &IO,
3202de17d49SChris Bieneman MachOYAML::Section &Section) {
3212de17d49SChris Bieneman IO.mapRequired("sectname", Section.sectname);
3222de17d49SChris Bieneman IO.mapRequired("segname", Section.segname);
3232de17d49SChris Bieneman IO.mapRequired("addr", Section.addr);
3242de17d49SChris Bieneman IO.mapRequired("size", Section.size);
3252de17d49SChris Bieneman IO.mapRequired("offset", Section.offset);
3262de17d49SChris Bieneman IO.mapRequired("align", Section.align);
3272de17d49SChris Bieneman IO.mapRequired("reloff", Section.reloff);
3282de17d49SChris Bieneman IO.mapRequired("nreloc", Section.nreloc);
3292de17d49SChris Bieneman IO.mapRequired("flags", Section.flags);
3302de17d49SChris Bieneman IO.mapRequired("reserved1", Section.reserved1);
3312de17d49SChris Bieneman IO.mapRequired("reserved2", Section.reserved2);
3322de17d49SChris Bieneman IO.mapOptional("reserved3", Section.reserved3);
33352237749SSeiya Nuta IO.mapOptional("content", Section.content);
334c19c3293SAlexander Shaposhnikov IO.mapOptional("relocations", Section.relocations);
33552237749SSeiya Nuta }
33652237749SSeiya Nuta
3376487ffafSGeorgii Rymar std::string
validate(IO & IO,MachOYAML::Section & Section)33852237749SSeiya Nuta MappingTraits<MachOYAML::Section>::validate(IO &IO,
33952237749SSeiya Nuta MachOYAML::Section &Section) {
34052237749SSeiya Nuta if (Section.content && Section.size < Section.content->binary_size())
34152237749SSeiya Nuta return "Section size must be greater than or equal to the content size";
3426487ffafSGeorgii Rymar return "";
3432de17d49SChris Bieneman }
3442de17d49SChris Bieneman
mapping(IO & IO,MachO::build_tool_version & tool)3455b54a42cSSteven Wu void MappingTraits<MachO::build_tool_version>::mapping(
3465b54a42cSSteven Wu IO &IO, MachO::build_tool_version &tool) {
3475b54a42cSSteven Wu IO.mapRequired("tool", tool.tool);
3485b54a42cSSteven Wu IO.mapRequired("version", tool.version);
3495b54a42cSSteven Wu }
3505b54a42cSSteven Wu
mapping(IO & IO,MachO::dylib & DylibStruct)3513f2eb836SChris Bieneman void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {
3523f2eb836SChris Bieneman IO.mapRequired("name", DylibStruct.name);
3533f2eb836SChris Bieneman IO.mapRequired("timestamp", DylibStruct.timestamp);
3543f2eb836SChris Bieneman IO.mapRequired("current_version", DylibStruct.current_version);
3553f2eb836SChris Bieneman IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);
3563f2eb836SChris Bieneman }
3573f2eb836SChris Bieneman
mapping(IO & IO,MachO::dylib_command & LoadCommand)3583f2eb836SChris Bieneman void MappingTraits<MachO::dylib_command>::mapping(
3593f2eb836SChris Bieneman IO &IO, MachO::dylib_command &LoadCommand) {
3603f2eb836SChris Bieneman IO.mapRequired("dylib", LoadCommand.dylib);
3613f2eb836SChris Bieneman }
3623f2eb836SChris Bieneman
mapping(IO & IO,MachO::dylinker_command & LoadCommand)3633f2eb836SChris Bieneman void MappingTraits<MachO::dylinker_command>::mapping(
3643f2eb836SChris Bieneman IO &IO, MachO::dylinker_command &LoadCommand) {
3653f2eb836SChris Bieneman IO.mapRequired("name", LoadCommand.name);
3663f2eb836SChris Bieneman }
3673f2eb836SChris Bieneman
mapping(IO & IO,MachO::dysymtab_command & LoadCommand)3683f2eb836SChris Bieneman void MappingTraits<MachO::dysymtab_command>::mapping(
3693f2eb836SChris Bieneman IO &IO, MachO::dysymtab_command &LoadCommand) {
3703f2eb836SChris Bieneman IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);
3713f2eb836SChris Bieneman IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);
3723f2eb836SChris Bieneman IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);
3733f2eb836SChris Bieneman IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);
3743f2eb836SChris Bieneman IO.mapRequired("iundefsym", LoadCommand.iundefsym);
3753f2eb836SChris Bieneman IO.mapRequired("nundefsym", LoadCommand.nundefsym);
3763f2eb836SChris Bieneman IO.mapRequired("tocoff", LoadCommand.tocoff);
3773f2eb836SChris Bieneman IO.mapRequired("ntoc", LoadCommand.ntoc);
3783f2eb836SChris Bieneman IO.mapRequired("modtaboff", LoadCommand.modtaboff);
3793f2eb836SChris Bieneman IO.mapRequired("nmodtab", LoadCommand.nmodtab);
3803f2eb836SChris Bieneman IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);
3813f2eb836SChris Bieneman IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);
3823f2eb836SChris Bieneman IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);
3833f2eb836SChris Bieneman IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);
3843f2eb836SChris Bieneman IO.mapRequired("extreloff", LoadCommand.extreloff);
3853f2eb836SChris Bieneman IO.mapRequired("nextrel", LoadCommand.nextrel);
3863f2eb836SChris Bieneman IO.mapRequired("locreloff", LoadCommand.locreloff);
3873f2eb836SChris Bieneman IO.mapRequired("nlocrel", LoadCommand.nlocrel);
3883f2eb836SChris Bieneman }
3893f2eb836SChris Bieneman
mapping(IO & IO,MachO::encryption_info_command & LoadCommand)3903f2eb836SChris Bieneman void MappingTraits<MachO::encryption_info_command>::mapping(
3913f2eb836SChris Bieneman IO &IO, MachO::encryption_info_command &LoadCommand) {
3923f2eb836SChris Bieneman IO.mapRequired("cryptoff", LoadCommand.cryptoff);
3933f2eb836SChris Bieneman IO.mapRequired("cryptsize", LoadCommand.cryptsize);
3943f2eb836SChris Bieneman IO.mapRequired("cryptid", LoadCommand.cryptid);
3953f2eb836SChris Bieneman }
3963f2eb836SChris Bieneman
mapping(IO & IO,MachO::encryption_info_command_64 & LoadCommand)3973f2eb836SChris Bieneman void MappingTraits<MachO::encryption_info_command_64>::mapping(
3983f2eb836SChris Bieneman IO &IO, MachO::encryption_info_command_64 &LoadCommand) {
3993f2eb836SChris Bieneman IO.mapRequired("cryptoff", LoadCommand.cryptoff);
4003f2eb836SChris Bieneman IO.mapRequired("cryptsize", LoadCommand.cryptsize);
4013f2eb836SChris Bieneman IO.mapRequired("cryptid", LoadCommand.cryptid);
4023f2eb836SChris Bieneman IO.mapRequired("pad", LoadCommand.pad);
4033f2eb836SChris Bieneman }
4043f2eb836SChris Bieneman
mapping(IO & IO,MachO::entry_point_command & LoadCommand)4053f2eb836SChris Bieneman void MappingTraits<MachO::entry_point_command>::mapping(
4063f2eb836SChris Bieneman IO &IO, MachO::entry_point_command &LoadCommand) {
4073f2eb836SChris Bieneman IO.mapRequired("entryoff", LoadCommand.entryoff);
4083f2eb836SChris Bieneman IO.mapRequired("stacksize", LoadCommand.stacksize);
4093f2eb836SChris Bieneman }
4103f2eb836SChris Bieneman
mapping(IO & IO,MachO::fvmfile_command & LoadCommand)4113f2eb836SChris Bieneman void MappingTraits<MachO::fvmfile_command>::mapping(
4123f2eb836SChris Bieneman IO &IO, MachO::fvmfile_command &LoadCommand) {
4133f2eb836SChris Bieneman IO.mapRequired("name", LoadCommand.name);
4143f2eb836SChris Bieneman IO.mapRequired("header_addr", LoadCommand.header_addr);
4153f2eb836SChris Bieneman }
4163f2eb836SChris Bieneman
mapping(IO & IO,MachO::fvmlib & FVMLib)4173f2eb836SChris Bieneman void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {
4183f2eb836SChris Bieneman IO.mapRequired("name", FVMLib.name);
4193f2eb836SChris Bieneman IO.mapRequired("minor_version", FVMLib.minor_version);
4203f2eb836SChris Bieneman IO.mapRequired("header_addr", FVMLib.header_addr);
4213f2eb836SChris Bieneman }
4223f2eb836SChris Bieneman
mapping(IO & IO,MachO::fvmlib_command & LoadCommand)4233f2eb836SChris Bieneman void MappingTraits<MachO::fvmlib_command>::mapping(
4243f2eb836SChris Bieneman IO &IO, MachO::fvmlib_command &LoadCommand) {
4253f2eb836SChris Bieneman IO.mapRequired("fvmlib", LoadCommand.fvmlib);
4263f2eb836SChris Bieneman }
4273f2eb836SChris Bieneman
mapping(IO & IO,MachO::ident_command & LoadCommand)4283f2eb836SChris Bieneman void MappingTraits<MachO::ident_command>::mapping(
4293f2eb836SChris Bieneman IO &IO, MachO::ident_command &LoadCommand) {}
4303f2eb836SChris Bieneman
mapping(IO & IO,MachO::linkedit_data_command & LoadCommand)4313f2eb836SChris Bieneman void MappingTraits<MachO::linkedit_data_command>::mapping(
4323f2eb836SChris Bieneman IO &IO, MachO::linkedit_data_command &LoadCommand) {
4333f2eb836SChris Bieneman IO.mapRequired("dataoff", LoadCommand.dataoff);
4343f2eb836SChris Bieneman IO.mapRequired("datasize", LoadCommand.datasize);
4353f2eb836SChris Bieneman }
4363f2eb836SChris Bieneman
mapping(IO & IO,MachO::linker_option_command & LoadCommand)4373f2eb836SChris Bieneman void MappingTraits<MachO::linker_option_command>::mapping(
4383f2eb836SChris Bieneman IO &IO, MachO::linker_option_command &LoadCommand) {
4393f2eb836SChris Bieneman IO.mapRequired("count", LoadCommand.count);
4403f2eb836SChris Bieneman }
4413f2eb836SChris Bieneman
mapping(IO & IO,MachO::prebind_cksum_command & LoadCommand)4423f2eb836SChris Bieneman void MappingTraits<MachO::prebind_cksum_command>::mapping(
4433f2eb836SChris Bieneman IO &IO, MachO::prebind_cksum_command &LoadCommand) {
4443f2eb836SChris Bieneman IO.mapRequired("cksum", LoadCommand.cksum);
4453f2eb836SChris Bieneman }
4463f2eb836SChris Bieneman
mapping(IO & IO,MachO::load_command & LoadCommand)4473f2eb836SChris Bieneman void MappingTraits<MachO::load_command>::mapping(
4483f2eb836SChris Bieneman IO &IO, MachO::load_command &LoadCommand) {}
4493f2eb836SChris Bieneman
mapping(IO & IO,MachO::prebound_dylib_command & LoadCommand)4503f2eb836SChris Bieneman void MappingTraits<MachO::prebound_dylib_command>::mapping(
4513f2eb836SChris Bieneman IO &IO, MachO::prebound_dylib_command &LoadCommand) {
4523f2eb836SChris Bieneman IO.mapRequired("name", LoadCommand.name);
4533f2eb836SChris Bieneman IO.mapRequired("nmodules", LoadCommand.nmodules);
4543f2eb836SChris Bieneman IO.mapRequired("linked_modules", LoadCommand.linked_modules);
4553f2eb836SChris Bieneman }
4563f2eb836SChris Bieneman
mapping(IO & IO,MachO::routines_command & LoadCommand)4573f2eb836SChris Bieneman void MappingTraits<MachO::routines_command>::mapping(
4583f2eb836SChris Bieneman IO &IO, MachO::routines_command &LoadCommand) {
4593f2eb836SChris Bieneman IO.mapRequired("init_address", LoadCommand.init_address);
4603f2eb836SChris Bieneman IO.mapRequired("init_module", LoadCommand.init_module);
4613f2eb836SChris Bieneman IO.mapRequired("reserved1", LoadCommand.reserved1);
4623f2eb836SChris Bieneman IO.mapRequired("reserved2", LoadCommand.reserved2);
4633f2eb836SChris Bieneman IO.mapRequired("reserved3", LoadCommand.reserved3);
4643f2eb836SChris Bieneman IO.mapRequired("reserved4", LoadCommand.reserved4);
4653f2eb836SChris Bieneman IO.mapRequired("reserved5", LoadCommand.reserved5);
4663f2eb836SChris Bieneman IO.mapRequired("reserved6", LoadCommand.reserved6);
4673f2eb836SChris Bieneman }
4683f2eb836SChris Bieneman
mapping(IO & IO,MachO::routines_command_64 & LoadCommand)4693f2eb836SChris Bieneman void MappingTraits<MachO::routines_command_64>::mapping(
4703f2eb836SChris Bieneman IO &IO, MachO::routines_command_64 &LoadCommand) {
4713f2eb836SChris Bieneman IO.mapRequired("init_address", LoadCommand.init_address);
4723f2eb836SChris Bieneman IO.mapRequired("init_module", LoadCommand.init_module);
4733f2eb836SChris Bieneman IO.mapRequired("reserved1", LoadCommand.reserved1);
4743f2eb836SChris Bieneman IO.mapRequired("reserved2", LoadCommand.reserved2);
4753f2eb836SChris Bieneman IO.mapRequired("reserved3", LoadCommand.reserved3);
4763f2eb836SChris Bieneman IO.mapRequired("reserved4", LoadCommand.reserved4);
4773f2eb836SChris Bieneman IO.mapRequired("reserved5", LoadCommand.reserved5);
4783f2eb836SChris Bieneman IO.mapRequired("reserved6", LoadCommand.reserved6);
4793f2eb836SChris Bieneman }
4803f2eb836SChris Bieneman
mapping(IO & IO,MachO::rpath_command & LoadCommand)4813f2eb836SChris Bieneman void MappingTraits<MachO::rpath_command>::mapping(
4823f2eb836SChris Bieneman IO &IO, MachO::rpath_command &LoadCommand) {
4833f2eb836SChris Bieneman IO.mapRequired("path", LoadCommand.path);
4843f2eb836SChris Bieneman }
4853f2eb836SChris Bieneman
mapping(IO & IO,MachO::section & Section)4863f2eb836SChris Bieneman void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) {
4873f2eb836SChris Bieneman IO.mapRequired("sectname", Section.sectname);
4883f2eb836SChris Bieneman IO.mapRequired("segname", Section.segname);
4893f2eb836SChris Bieneman IO.mapRequired("addr", Section.addr);
4903f2eb836SChris Bieneman IO.mapRequired("size", Section.size);
4913f2eb836SChris Bieneman IO.mapRequired("offset", Section.offset);
4923f2eb836SChris Bieneman IO.mapRequired("align", Section.align);
4933f2eb836SChris Bieneman IO.mapRequired("reloff", Section.reloff);
4943f2eb836SChris Bieneman IO.mapRequired("nreloc", Section.nreloc);
4953f2eb836SChris Bieneman IO.mapRequired("flags", Section.flags);
4963f2eb836SChris Bieneman IO.mapRequired("reserved1", Section.reserved1);
4973f2eb836SChris Bieneman IO.mapRequired("reserved2", Section.reserved2);
4983f2eb836SChris Bieneman }
4993f2eb836SChris Bieneman
mapping(IO & IO,MachO::section_64 & Section)5003f2eb836SChris Bieneman void MappingTraits<MachO::section_64>::mapping(IO &IO,
5013f2eb836SChris Bieneman MachO::section_64 &Section) {
5023f2eb836SChris Bieneman IO.mapRequired("sectname", Section.sectname);
5033f2eb836SChris Bieneman IO.mapRequired("segname", Section.segname);
5043f2eb836SChris Bieneman IO.mapRequired("addr", Section.addr);
5053f2eb836SChris Bieneman IO.mapRequired("size", Section.size);
5063f2eb836SChris Bieneman IO.mapRequired("offset", Section.offset);
5073f2eb836SChris Bieneman IO.mapRequired("align", Section.align);
5083f2eb836SChris Bieneman IO.mapRequired("reloff", Section.reloff);
5093f2eb836SChris Bieneman IO.mapRequired("nreloc", Section.nreloc);
5103f2eb836SChris Bieneman IO.mapRequired("flags", Section.flags);
5113f2eb836SChris Bieneman IO.mapRequired("reserved1", Section.reserved1);
5123f2eb836SChris Bieneman IO.mapRequired("reserved2", Section.reserved2);
5133f2eb836SChris Bieneman IO.mapRequired("reserved3", Section.reserved3);
5143f2eb836SChris Bieneman }
5153f2eb836SChris Bieneman
mapping(IO & IO,MachO::segment_command & LoadCommand)5163f2eb836SChris Bieneman void MappingTraits<MachO::segment_command>::mapping(
5173f2eb836SChris Bieneman IO &IO, MachO::segment_command &LoadCommand) {
5183f2eb836SChris Bieneman IO.mapRequired("segname", LoadCommand.segname);
5193f2eb836SChris Bieneman IO.mapRequired("vmaddr", LoadCommand.vmaddr);
5203f2eb836SChris Bieneman IO.mapRequired("vmsize", LoadCommand.vmsize);
5213f2eb836SChris Bieneman IO.mapRequired("fileoff", LoadCommand.fileoff);
5223f2eb836SChris Bieneman IO.mapRequired("filesize", LoadCommand.filesize);
5233f2eb836SChris Bieneman IO.mapRequired("maxprot", LoadCommand.maxprot);
5243f2eb836SChris Bieneman IO.mapRequired("initprot", LoadCommand.initprot);
5253f2eb836SChris Bieneman IO.mapRequired("nsects", LoadCommand.nsects);
5263f2eb836SChris Bieneman IO.mapRequired("flags", LoadCommand.flags);
5273f2eb836SChris Bieneman }
5283f2eb836SChris Bieneman
mapping(IO & IO,MachO::segment_command_64 & LoadCommand)5293f2eb836SChris Bieneman void MappingTraits<MachO::segment_command_64>::mapping(
5303f2eb836SChris Bieneman IO &IO, MachO::segment_command_64 &LoadCommand) {
5313f2eb836SChris Bieneman IO.mapRequired("segname", LoadCommand.segname);
5323f2eb836SChris Bieneman IO.mapRequired("vmaddr", LoadCommand.vmaddr);
5333f2eb836SChris Bieneman IO.mapRequired("vmsize", LoadCommand.vmsize);
5343f2eb836SChris Bieneman IO.mapRequired("fileoff", LoadCommand.fileoff);
5353f2eb836SChris Bieneman IO.mapRequired("filesize", LoadCommand.filesize);
5363f2eb836SChris Bieneman IO.mapRequired("maxprot", LoadCommand.maxprot);
5373f2eb836SChris Bieneman IO.mapRequired("initprot", LoadCommand.initprot);
5383f2eb836SChris Bieneman IO.mapRequired("nsects", LoadCommand.nsects);
5393f2eb836SChris Bieneman IO.mapRequired("flags", LoadCommand.flags);
5403f2eb836SChris Bieneman }
5413f2eb836SChris Bieneman
mapping(IO & IO,MachO::source_version_command & LoadCommand)5423f2eb836SChris Bieneman void MappingTraits<MachO::source_version_command>::mapping(
5433f2eb836SChris Bieneman IO &IO, MachO::source_version_command &LoadCommand) {
5443f2eb836SChris Bieneman IO.mapRequired("version", LoadCommand.version);
5453f2eb836SChris Bieneman }
5463f2eb836SChris Bieneman
mapping(IO & IO,MachO::sub_client_command & LoadCommand)5473f2eb836SChris Bieneman void MappingTraits<MachO::sub_client_command>::mapping(
5483f2eb836SChris Bieneman IO &IO, MachO::sub_client_command &LoadCommand) {
5493f2eb836SChris Bieneman IO.mapRequired("client", LoadCommand.client);
5503f2eb836SChris Bieneman }
5513f2eb836SChris Bieneman
mapping(IO & IO,MachO::sub_framework_command & LoadCommand)5523f2eb836SChris Bieneman void MappingTraits<MachO::sub_framework_command>::mapping(
5533f2eb836SChris Bieneman IO &IO, MachO::sub_framework_command &LoadCommand) {
5543f2eb836SChris Bieneman IO.mapRequired("umbrella", LoadCommand.umbrella);
5553f2eb836SChris Bieneman }
5563f2eb836SChris Bieneman
mapping(IO & IO,MachO::sub_library_command & LoadCommand)5573f2eb836SChris Bieneman void MappingTraits<MachO::sub_library_command>::mapping(
5583f2eb836SChris Bieneman IO &IO, MachO::sub_library_command &LoadCommand) {
5593f2eb836SChris Bieneman IO.mapRequired("sub_library", LoadCommand.sub_library);
5603f2eb836SChris Bieneman }
5613f2eb836SChris Bieneman
mapping(IO & IO,MachO::sub_umbrella_command & LoadCommand)5623f2eb836SChris Bieneman void MappingTraits<MachO::sub_umbrella_command>::mapping(
5633f2eb836SChris Bieneman IO &IO, MachO::sub_umbrella_command &LoadCommand) {
5643f2eb836SChris Bieneman IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);
5653f2eb836SChris Bieneman }
5663f2eb836SChris Bieneman
mapping(IO & IO,MachO::symseg_command & LoadCommand)5673f2eb836SChris Bieneman void MappingTraits<MachO::symseg_command>::mapping(
5683f2eb836SChris Bieneman IO &IO, MachO::symseg_command &LoadCommand) {
5693f2eb836SChris Bieneman IO.mapRequired("offset", LoadCommand.offset);
5703f2eb836SChris Bieneman IO.mapRequired("size", LoadCommand.size);
5713f2eb836SChris Bieneman }
5723f2eb836SChris Bieneman
mapping(IO & IO,MachO::symtab_command & LoadCommand)5733f2eb836SChris Bieneman void MappingTraits<MachO::symtab_command>::mapping(
5743f2eb836SChris Bieneman IO &IO, MachO::symtab_command &LoadCommand) {
5753f2eb836SChris Bieneman IO.mapRequired("symoff", LoadCommand.symoff);
5763f2eb836SChris Bieneman IO.mapRequired("nsyms", LoadCommand.nsyms);
5773f2eb836SChris Bieneman IO.mapRequired("stroff", LoadCommand.stroff);
5783f2eb836SChris Bieneman IO.mapRequired("strsize", LoadCommand.strsize);
5793f2eb836SChris Bieneman }
5803f2eb836SChris Bieneman
mapping(IO & IO,MachO::thread_command & LoadCommand)5813f2eb836SChris Bieneman void MappingTraits<MachO::thread_command>::mapping(
5823f2eb836SChris Bieneman IO &IO, MachO::thread_command &LoadCommand) {}
5833f2eb836SChris Bieneman
mapping(IO & IO,MachO::twolevel_hints_command & LoadCommand)5843f2eb836SChris Bieneman void MappingTraits<MachO::twolevel_hints_command>::mapping(
5853f2eb836SChris Bieneman IO &IO, MachO::twolevel_hints_command &LoadCommand) {
5863f2eb836SChris Bieneman IO.mapRequired("offset", LoadCommand.offset);
5873f2eb836SChris Bieneman IO.mapRequired("nhints", LoadCommand.nhints);
5883f2eb836SChris Bieneman }
5893f2eb836SChris Bieneman
mapping(IO & IO,MachO::uuid_command & LoadCommand)5903f2eb836SChris Bieneman void MappingTraits<MachO::uuid_command>::mapping(
5913f2eb836SChris Bieneman IO &IO, MachO::uuid_command &LoadCommand) {
5923f2eb836SChris Bieneman IO.mapRequired("uuid", LoadCommand.uuid);
5933f2eb836SChris Bieneman }
5943f2eb836SChris Bieneman
mapping(IO & IO,MachO::version_min_command & LoadCommand)5953f2eb836SChris Bieneman void MappingTraits<MachO::version_min_command>::mapping(
5963f2eb836SChris Bieneman IO &IO, MachO::version_min_command &LoadCommand) {
5973f2eb836SChris Bieneman IO.mapRequired("version", LoadCommand.version);
5983f2eb836SChris Bieneman IO.mapRequired("sdk", LoadCommand.sdk);
5998b5906eaSChris Bieneman }
6008b5906eaSChris Bieneman
mapping(IO & IO,MachO::note_command & LoadCommand)601a4579c41SKevin Enderby void MappingTraits<MachO::note_command>::mapping(
602a4579c41SKevin Enderby IO &IO, MachO::note_command &LoadCommand) {
603a4579c41SKevin Enderby IO.mapRequired("data_owner", LoadCommand.data_owner);
604a4579c41SKevin Enderby IO.mapRequired("offset", LoadCommand.offset);
605a4579c41SKevin Enderby IO.mapRequired("size", LoadCommand.size);
606a4579c41SKevin Enderby }
607a4579c41SKevin Enderby
mapping(IO & IO,MachO::build_version_command & LoadCommand)6085b54a42cSSteven Wu void MappingTraits<MachO::build_version_command>::mapping(
6095b54a42cSSteven Wu IO &IO, MachO::build_version_command &LoadCommand) {
6105b54a42cSSteven Wu IO.mapRequired("platform", LoadCommand.platform);
6115b54a42cSSteven Wu IO.mapRequired("minos", LoadCommand.minos);
6125b54a42cSSteven Wu IO.mapRequired("sdk", LoadCommand.sdk);
6135b54a42cSSteven Wu IO.mapRequired("ntools", LoadCommand.ntools);
6145b54a42cSSteven Wu }
6155b54a42cSSteven Wu
61628082ab0SEugene Zelenko } // end namespace yaml
6179062ab94SChris Bieneman
61828082ab0SEugene Zelenko } // end namespace llvm
619