Path: blob/main/contrib/llvm-project/llvm/lib/ObjectYAML/MachOYAML.cpp
35234 views
//===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines classes for handling the YAML representation of MachO.9//10//===----------------------------------------------------------------------===//1112#include "llvm/ObjectYAML/MachOYAML.h"13#include "llvm/ADT/StringRef.h"14#include "llvm/BinaryFormat/MachO.h"15#include "llvm/Support/Format.h"16#include "llvm/Support/SystemZ/zOSSupport.h"17#include "llvm/Support/YAMLTraits.h"18#include "llvm/Support/raw_ostream.h"19#include "llvm/TargetParser/Host.h"20#include <cinttypes>21#include <cstdint>22#include <cstring>2324namespace llvm {2526MachOYAML::LoadCommand::~LoadCommand() = default;2728bool MachOYAML::LinkEditData::isEmpty() const {29return 0 == RebaseOpcodes.size() + BindOpcodes.size() +30WeakBindOpcodes.size() + LazyBindOpcodes.size() +31ExportTrie.Children.size() + NameList.size() +32StringTable.size() + FunctionStarts.size() +33ChainedFixups.size() + DataInCode.size();34}3536namespace yaml {3738void ScalarTraits<char_16>::output(const char_16 &Val, void *,39raw_ostream &Out) {40auto Len = strnlen(&Val[0], 16);41Out << StringRef(&Val[0], Len);42}4344StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) {45size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size();46memcpy((void *)Val, Scalar.data(), CopySize);4748if (Scalar.size() < 16) {49memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size());50}5152return StringRef();53}5455QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) {56return needsQuotes(S);57}5859void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) {60Out.write_uuid(Val);61}6263StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) {64size_t OutIdx = 0;65for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) {66if (Scalar[Idx] == '-' || OutIdx >= 16)67continue;68unsigned long long TempInt;69if (getAsUnsignedInteger(Scalar.slice(Idx, Idx + 2), 16, TempInt))70return "invalid number";71if (TempInt > 0xFF)72return "out of range number";73Val[OutIdx] = static_cast<uint8_t>(TempInt);74++Idx; // increment idx an extra time because we're consuming 2 chars75++OutIdx;76}77return StringRef();78}7980QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) {81return needsQuotes(S);82}8384void MappingTraits<MachOYAML::FileHeader>::mapping(85IO &IO, MachOYAML::FileHeader &FileHdr) {86IO.mapRequired("magic", FileHdr.magic);87IO.mapRequired("cputype", FileHdr.cputype);88IO.mapRequired("cpusubtype", FileHdr.cpusubtype);89IO.mapRequired("filetype", FileHdr.filetype);90IO.mapRequired("ncmds", FileHdr.ncmds);91IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);92IO.mapRequired("flags", FileHdr.flags);93if (FileHdr.magic == MachO::MH_MAGIC_64 ||94FileHdr.magic == MachO::MH_CIGAM_64)95IO.mapRequired("reserved", FileHdr.reserved);96}9798void MappingTraits<MachOYAML::Object>::mapping(IO &IO,99MachOYAML::Object &Object) {100// If the context isn't already set, tag the document as !mach-o.101// For Fat files there will be a different tag so they can be differentiated.102if (!IO.getContext()) {103IO.setContext(&Object);104}105IO.mapTag("!mach-o", true);106IO.mapOptional("IsLittleEndian", Object.IsLittleEndian,107sys::IsLittleEndianHost);108Object.DWARF.IsLittleEndian = Object.IsLittleEndian;109110IO.mapRequired("FileHeader", Object.Header);111Object.DWARF.Is64BitAddrSize = Object.Header.magic == MachO::MH_MAGIC_64 ||112Object.Header.magic == MachO::MH_CIGAM_64;113IO.mapOptional("LoadCommands", Object.LoadCommands);114115if (Object.RawLinkEditSegment || !IO.outputting())116IO.mapOptional("__LINKEDIT", Object.RawLinkEditSegment);117if(!Object.LinkEdit.isEmpty() || !IO.outputting())118IO.mapOptional("LinkEditData", Object.LinkEdit);119120if(!Object.DWARF.isEmpty() || !IO.outputting())121IO.mapOptional("DWARF", Object.DWARF);122123if (IO.getContext() == &Object)124IO.setContext(nullptr);125}126127void MappingTraits<MachOYAML::FatHeader>::mapping(128IO &IO, MachOYAML::FatHeader &FatHeader) {129IO.mapRequired("magic", FatHeader.magic);130IO.mapRequired("nfat_arch", FatHeader.nfat_arch);131}132133void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO,134MachOYAML::FatArch &FatArch) {135IO.mapRequired("cputype", FatArch.cputype);136IO.mapRequired("cpusubtype", FatArch.cpusubtype);137IO.mapRequired("offset", FatArch.offset);138IO.mapRequired("size", FatArch.size);139IO.mapRequired("align", FatArch.align);140IO.mapOptional("reserved", FatArch.reserved,141static_cast<llvm::yaml::Hex32>(0));142}143144void MappingTraits<MachOYAML::UniversalBinary>::mapping(145IO &IO, MachOYAML::UniversalBinary &UniversalBinary) {146if (!IO.getContext()) {147IO.setContext(&UniversalBinary);148IO.mapTag("!fat-mach-o", true);149}150IO.mapRequired("FatHeader", UniversalBinary.Header);151IO.mapRequired("FatArchs", UniversalBinary.FatArchs);152IO.mapRequired("Slices", UniversalBinary.Slices);153154if (IO.getContext() == &UniversalBinary)155IO.setContext(nullptr);156}157158void MappingTraits<MachOYAML::LinkEditData>::mapping(159IO &IO, MachOYAML::LinkEditData &LinkEditData) {160IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes);161IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes);162IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes);163IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes);164if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting())165IO.mapOptional("ExportTrie", LinkEditData.ExportTrie);166IO.mapOptional("NameList", LinkEditData.NameList);167IO.mapOptional("StringTable", LinkEditData.StringTable);168IO.mapOptional("IndirectSymbols", LinkEditData.IndirectSymbols);169IO.mapOptional("FunctionStarts", LinkEditData.FunctionStarts);170IO.mapOptional("ChainedFixups", LinkEditData.ChainedFixups);171IO.mapOptional("DataInCode", LinkEditData.DataInCode);172}173174void MappingTraits<MachOYAML::RebaseOpcode>::mapping(175IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) {176IO.mapRequired("Opcode", RebaseOpcode.Opcode);177IO.mapRequired("Imm", RebaseOpcode.Imm);178IO.mapOptional("ExtraData", RebaseOpcode.ExtraData);179}180181void MappingTraits<MachOYAML::BindOpcode>::mapping(182IO &IO, MachOYAML::BindOpcode &BindOpcode) {183IO.mapRequired("Opcode", BindOpcode.Opcode);184IO.mapRequired("Imm", BindOpcode.Imm);185IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData);186IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData);187IO.mapOptional("Symbol", BindOpcode.Symbol);188}189190void MappingTraits<MachOYAML::ExportEntry>::mapping(191IO &IO, MachOYAML::ExportEntry &ExportEntry) {192IO.mapRequired("TerminalSize", ExportEntry.TerminalSize);193IO.mapOptional("NodeOffset", ExportEntry.NodeOffset);194IO.mapOptional("Name", ExportEntry.Name);195IO.mapOptional("Flags", ExportEntry.Flags);196IO.mapOptional("Address", ExportEntry.Address);197IO.mapOptional("Other", ExportEntry.Other);198IO.mapOptional("ImportName", ExportEntry.ImportName);199IO.mapOptional("Children", ExportEntry.Children);200}201202void MappingTraits<MachOYAML::NListEntry>::mapping(203IO &IO, MachOYAML::NListEntry &NListEntry) {204IO.mapRequired("n_strx", NListEntry.n_strx);205IO.mapRequired("n_type", NListEntry.n_type);206IO.mapRequired("n_sect", NListEntry.n_sect);207IO.mapRequired("n_desc", NListEntry.n_desc);208IO.mapRequired("n_value", NListEntry.n_value);209}210211void MappingTraits<MachOYAML::DataInCodeEntry>::mapping(212IO &IO, MachOYAML::DataInCodeEntry &DataInCodeEntry) {213IO.mapRequired("Offset", DataInCodeEntry.Offset);214IO.mapRequired("Length", DataInCodeEntry.Length);215IO.mapRequired("Kind", DataInCodeEntry.Kind);216}217218template <typename StructType>219void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {}220221template <>222void mapLoadCommandData<MachO::segment_command>(223IO &IO, MachOYAML::LoadCommand &LoadCommand) {224IO.mapOptional("Sections", LoadCommand.Sections);225}226227template <>228void mapLoadCommandData<MachO::segment_command_64>(229IO &IO, MachOYAML::LoadCommand &LoadCommand) {230IO.mapOptional("Sections", LoadCommand.Sections);231}232233template <>234void mapLoadCommandData<MachO::dylib_command>(235IO &IO, MachOYAML::LoadCommand &LoadCommand) {236IO.mapOptional("Content", LoadCommand.Content);237}238239template <>240void mapLoadCommandData<MachO::rpath_command>(241IO &IO, MachOYAML::LoadCommand &LoadCommand) {242IO.mapOptional("Content", LoadCommand.Content);243}244245template <>246void mapLoadCommandData<MachO::dylinker_command>(247IO &IO, MachOYAML::LoadCommand &LoadCommand) {248IO.mapOptional("Content", LoadCommand.Content);249}250251template <>252void mapLoadCommandData<MachO::sub_framework_command>(253IO &IO, MachOYAML::LoadCommand &LoadCommand) {254IO.mapOptional("Content", LoadCommand.Content);255}256257template <>258void mapLoadCommandData<MachO::sub_umbrella_command>(259IO &IO, MachOYAML::LoadCommand &LoadCommand) {260IO.mapOptional("Content", LoadCommand.Content);261}262263template <>264void mapLoadCommandData<MachO::sub_client_command>(265IO &IO, MachOYAML::LoadCommand &LoadCommand) {266IO.mapOptional("Content", LoadCommand.Content);267}268269template <>270void mapLoadCommandData<MachO::sub_library_command>(271IO &IO, MachOYAML::LoadCommand &LoadCommand) {272IO.mapOptional("Content", LoadCommand.Content);273}274275template <>276void mapLoadCommandData<MachO::build_version_command>(277IO &IO, MachOYAML::LoadCommand &LoadCommand) {278IO.mapOptional("Tools", LoadCommand.Tools);279}280281void MappingTraits<MachOYAML::LoadCommand>::mapping(282IO &IO, MachOYAML::LoadCommand &LoadCommand) {283MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>(284LoadCommand.Data.load_command_data.cmd);285IO.mapRequired("cmd", TempCmd);286LoadCommand.Data.load_command_data.cmd = TempCmd;287IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize);288289#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \290case MachO::LCName: \291MappingTraits<MachO::LCStruct>::mapping(IO, \292LoadCommand.Data.LCStruct##_data); \293mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \294break;295296switch (LoadCommand.Data.load_command_data.cmd) {297#include "llvm/BinaryFormat/MachO.def"298}299IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes);300IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull);301}302303void MappingTraits<MachO::dyld_info_command>::mapping(304IO &IO, MachO::dyld_info_command &LoadCommand) {305IO.mapRequired("rebase_off", LoadCommand.rebase_off);306IO.mapRequired("rebase_size", LoadCommand.rebase_size);307IO.mapRequired("bind_off", LoadCommand.bind_off);308IO.mapRequired("bind_size", LoadCommand.bind_size);309IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off);310IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size);311IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off);312IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size);313IO.mapRequired("export_off", LoadCommand.export_off);314IO.mapRequired("export_size", LoadCommand.export_size);315}316317void MappingTraits<MachOYAML::Relocation>::mapping(318IO &IO, MachOYAML::Relocation &Relocation) {319IO.mapRequired("address", Relocation.address);320IO.mapRequired("symbolnum", Relocation.symbolnum);321IO.mapRequired("pcrel", Relocation.is_pcrel);322IO.mapRequired("length", Relocation.length);323IO.mapRequired("extern", Relocation.is_extern);324IO.mapRequired("type", Relocation.type);325IO.mapRequired("scattered", Relocation.is_scattered);326IO.mapRequired("value", Relocation.value);327}328329void MappingTraits<MachOYAML::Section>::mapping(IO &IO,330MachOYAML::Section &Section) {331IO.mapRequired("sectname", Section.sectname);332IO.mapRequired("segname", Section.segname);333IO.mapRequired("addr", Section.addr);334IO.mapRequired("size", Section.size);335IO.mapRequired("offset", Section.offset);336IO.mapRequired("align", Section.align);337IO.mapRequired("reloff", Section.reloff);338IO.mapRequired("nreloc", Section.nreloc);339IO.mapRequired("flags", Section.flags);340IO.mapRequired("reserved1", Section.reserved1);341IO.mapRequired("reserved2", Section.reserved2);342IO.mapOptional("reserved3", Section.reserved3);343IO.mapOptional("content", Section.content);344IO.mapOptional("relocations", Section.relocations);345}346347std::string348MappingTraits<MachOYAML::Section>::validate(IO &IO,349MachOYAML::Section &Section) {350if (Section.content && Section.size < Section.content->binary_size())351return "Section size must be greater than or equal to the content size";352return "";353}354355void MappingTraits<MachO::build_tool_version>::mapping(356IO &IO, MachO::build_tool_version &tool) {357IO.mapRequired("tool", tool.tool);358IO.mapRequired("version", tool.version);359}360361void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) {362IO.mapRequired("name", DylibStruct.name);363IO.mapRequired("timestamp", DylibStruct.timestamp);364IO.mapRequired("current_version", DylibStruct.current_version);365IO.mapRequired("compatibility_version", DylibStruct.compatibility_version);366}367368void MappingTraits<MachO::dylib_command>::mapping(369IO &IO, MachO::dylib_command &LoadCommand) {370IO.mapRequired("dylib", LoadCommand.dylib);371}372373void MappingTraits<MachO::dylinker_command>::mapping(374IO &IO, MachO::dylinker_command &LoadCommand) {375IO.mapRequired("name", LoadCommand.name);376}377378void MappingTraits<MachO::dysymtab_command>::mapping(379IO &IO, MachO::dysymtab_command &LoadCommand) {380IO.mapRequired("ilocalsym", LoadCommand.ilocalsym);381IO.mapRequired("nlocalsym", LoadCommand.nlocalsym);382IO.mapRequired("iextdefsym", LoadCommand.iextdefsym);383IO.mapRequired("nextdefsym", LoadCommand.nextdefsym);384IO.mapRequired("iundefsym", LoadCommand.iundefsym);385IO.mapRequired("nundefsym", LoadCommand.nundefsym);386IO.mapRequired("tocoff", LoadCommand.tocoff);387IO.mapRequired("ntoc", LoadCommand.ntoc);388IO.mapRequired("modtaboff", LoadCommand.modtaboff);389IO.mapRequired("nmodtab", LoadCommand.nmodtab);390IO.mapRequired("extrefsymoff", LoadCommand.extrefsymoff);391IO.mapRequired("nextrefsyms", LoadCommand.nextrefsyms);392IO.mapRequired("indirectsymoff", LoadCommand.indirectsymoff);393IO.mapRequired("nindirectsyms", LoadCommand.nindirectsyms);394IO.mapRequired("extreloff", LoadCommand.extreloff);395IO.mapRequired("nextrel", LoadCommand.nextrel);396IO.mapRequired("locreloff", LoadCommand.locreloff);397IO.mapRequired("nlocrel", LoadCommand.nlocrel);398}399400void MappingTraits<MachO::encryption_info_command>::mapping(401IO &IO, MachO::encryption_info_command &LoadCommand) {402IO.mapRequired("cryptoff", LoadCommand.cryptoff);403IO.mapRequired("cryptsize", LoadCommand.cryptsize);404IO.mapRequired("cryptid", LoadCommand.cryptid);405}406407void MappingTraits<MachO::encryption_info_command_64>::mapping(408IO &IO, MachO::encryption_info_command_64 &LoadCommand) {409IO.mapRequired("cryptoff", LoadCommand.cryptoff);410IO.mapRequired("cryptsize", LoadCommand.cryptsize);411IO.mapRequired("cryptid", LoadCommand.cryptid);412IO.mapRequired("pad", LoadCommand.pad);413}414415void MappingTraits<MachO::entry_point_command>::mapping(416IO &IO, MachO::entry_point_command &LoadCommand) {417IO.mapRequired("entryoff", LoadCommand.entryoff);418IO.mapRequired("stacksize", LoadCommand.stacksize);419}420421void MappingTraits<MachO::fvmfile_command>::mapping(422IO &IO, MachO::fvmfile_command &LoadCommand) {423IO.mapRequired("name", LoadCommand.name);424IO.mapRequired("header_addr", LoadCommand.header_addr);425}426427void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) {428IO.mapRequired("name", FVMLib.name);429IO.mapRequired("minor_version", FVMLib.minor_version);430IO.mapRequired("header_addr", FVMLib.header_addr);431}432433void MappingTraits<MachO::fvmlib_command>::mapping(434IO &IO, MachO::fvmlib_command &LoadCommand) {435IO.mapRequired("fvmlib", LoadCommand.fvmlib);436}437438void MappingTraits<MachO::ident_command>::mapping(439IO &IO, MachO::ident_command &LoadCommand) {}440441void MappingTraits<MachO::linkedit_data_command>::mapping(442IO &IO, MachO::linkedit_data_command &LoadCommand) {443IO.mapRequired("dataoff", LoadCommand.dataoff);444IO.mapRequired("datasize", LoadCommand.datasize);445}446447void MappingTraits<MachO::linker_option_command>::mapping(448IO &IO, MachO::linker_option_command &LoadCommand) {449IO.mapRequired("count", LoadCommand.count);450}451452void MappingTraits<MachO::prebind_cksum_command>::mapping(453IO &IO, MachO::prebind_cksum_command &LoadCommand) {454IO.mapRequired("cksum", LoadCommand.cksum);455}456457void MappingTraits<MachO::load_command>::mapping(458IO &IO, MachO::load_command &LoadCommand) {}459460void MappingTraits<MachO::prebound_dylib_command>::mapping(461IO &IO, MachO::prebound_dylib_command &LoadCommand) {462IO.mapRequired("name", LoadCommand.name);463IO.mapRequired("nmodules", LoadCommand.nmodules);464IO.mapRequired("linked_modules", LoadCommand.linked_modules);465}466467void MappingTraits<MachO::routines_command>::mapping(468IO &IO, MachO::routines_command &LoadCommand) {469IO.mapRequired("init_address", LoadCommand.init_address);470IO.mapRequired("init_module", LoadCommand.init_module);471IO.mapRequired("reserved1", LoadCommand.reserved1);472IO.mapRequired("reserved2", LoadCommand.reserved2);473IO.mapRequired("reserved3", LoadCommand.reserved3);474IO.mapRequired("reserved4", LoadCommand.reserved4);475IO.mapRequired("reserved5", LoadCommand.reserved5);476IO.mapRequired("reserved6", LoadCommand.reserved6);477}478479void MappingTraits<MachO::routines_command_64>::mapping(480IO &IO, MachO::routines_command_64 &LoadCommand) {481IO.mapRequired("init_address", LoadCommand.init_address);482IO.mapRequired("init_module", LoadCommand.init_module);483IO.mapRequired("reserved1", LoadCommand.reserved1);484IO.mapRequired("reserved2", LoadCommand.reserved2);485IO.mapRequired("reserved3", LoadCommand.reserved3);486IO.mapRequired("reserved4", LoadCommand.reserved4);487IO.mapRequired("reserved5", LoadCommand.reserved5);488IO.mapRequired("reserved6", LoadCommand.reserved6);489}490491void MappingTraits<MachO::rpath_command>::mapping(492IO &IO, MachO::rpath_command &LoadCommand) {493IO.mapRequired("path", LoadCommand.path);494}495496void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) {497IO.mapRequired("sectname", Section.sectname);498IO.mapRequired("segname", Section.segname);499IO.mapRequired("addr", Section.addr);500IO.mapRequired("size", Section.size);501IO.mapRequired("offset", Section.offset);502IO.mapRequired("align", Section.align);503IO.mapRequired("reloff", Section.reloff);504IO.mapRequired("nreloc", Section.nreloc);505IO.mapRequired("flags", Section.flags);506IO.mapRequired("reserved1", Section.reserved1);507IO.mapRequired("reserved2", Section.reserved2);508}509510void MappingTraits<MachO::section_64>::mapping(IO &IO,511MachO::section_64 &Section) {512IO.mapRequired("sectname", Section.sectname);513IO.mapRequired("segname", Section.segname);514IO.mapRequired("addr", Section.addr);515IO.mapRequired("size", Section.size);516IO.mapRequired("offset", Section.offset);517IO.mapRequired("align", Section.align);518IO.mapRequired("reloff", Section.reloff);519IO.mapRequired("nreloc", Section.nreloc);520IO.mapRequired("flags", Section.flags);521IO.mapRequired("reserved1", Section.reserved1);522IO.mapRequired("reserved2", Section.reserved2);523IO.mapRequired("reserved3", Section.reserved3);524}525526void MappingTraits<MachO::segment_command>::mapping(527IO &IO, MachO::segment_command &LoadCommand) {528IO.mapRequired("segname", LoadCommand.segname);529IO.mapRequired("vmaddr", LoadCommand.vmaddr);530IO.mapRequired("vmsize", LoadCommand.vmsize);531IO.mapRequired("fileoff", LoadCommand.fileoff);532IO.mapRequired("filesize", LoadCommand.filesize);533IO.mapRequired("maxprot", LoadCommand.maxprot);534IO.mapRequired("initprot", LoadCommand.initprot);535IO.mapRequired("nsects", LoadCommand.nsects);536IO.mapRequired("flags", LoadCommand.flags);537}538539void MappingTraits<MachO::segment_command_64>::mapping(540IO &IO, MachO::segment_command_64 &LoadCommand) {541IO.mapRequired("segname", LoadCommand.segname);542IO.mapRequired("vmaddr", LoadCommand.vmaddr);543IO.mapRequired("vmsize", LoadCommand.vmsize);544IO.mapRequired("fileoff", LoadCommand.fileoff);545IO.mapRequired("filesize", LoadCommand.filesize);546IO.mapRequired("maxprot", LoadCommand.maxprot);547IO.mapRequired("initprot", LoadCommand.initprot);548IO.mapRequired("nsects", LoadCommand.nsects);549IO.mapRequired("flags", LoadCommand.flags);550}551552void MappingTraits<MachO::source_version_command>::mapping(553IO &IO, MachO::source_version_command &LoadCommand) {554IO.mapRequired("version", LoadCommand.version);555}556557void MappingTraits<MachO::sub_client_command>::mapping(558IO &IO, MachO::sub_client_command &LoadCommand) {559IO.mapRequired("client", LoadCommand.client);560}561562void MappingTraits<MachO::sub_framework_command>::mapping(563IO &IO, MachO::sub_framework_command &LoadCommand) {564IO.mapRequired("umbrella", LoadCommand.umbrella);565}566567void MappingTraits<MachO::sub_library_command>::mapping(568IO &IO, MachO::sub_library_command &LoadCommand) {569IO.mapRequired("sub_library", LoadCommand.sub_library);570}571572void MappingTraits<MachO::sub_umbrella_command>::mapping(573IO &IO, MachO::sub_umbrella_command &LoadCommand) {574IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella);575}576577void MappingTraits<MachO::symseg_command>::mapping(578IO &IO, MachO::symseg_command &LoadCommand) {579IO.mapRequired("offset", LoadCommand.offset);580IO.mapRequired("size", LoadCommand.size);581}582583void MappingTraits<MachO::symtab_command>::mapping(584IO &IO, MachO::symtab_command &LoadCommand) {585IO.mapRequired("symoff", LoadCommand.symoff);586IO.mapRequired("nsyms", LoadCommand.nsyms);587IO.mapRequired("stroff", LoadCommand.stroff);588IO.mapRequired("strsize", LoadCommand.strsize);589}590591void MappingTraits<MachO::thread_command>::mapping(592IO &IO, MachO::thread_command &LoadCommand) {}593594void MappingTraits<MachO::twolevel_hints_command>::mapping(595IO &IO, MachO::twolevel_hints_command &LoadCommand) {596IO.mapRequired("offset", LoadCommand.offset);597IO.mapRequired("nhints", LoadCommand.nhints);598}599600void MappingTraits<MachO::uuid_command>::mapping(601IO &IO, MachO::uuid_command &LoadCommand) {602IO.mapRequired("uuid", LoadCommand.uuid);603}604605void MappingTraits<MachO::version_min_command>::mapping(606IO &IO, MachO::version_min_command &LoadCommand) {607IO.mapRequired("version", LoadCommand.version);608IO.mapRequired("sdk", LoadCommand.sdk);609}610611void MappingTraits<MachO::note_command>::mapping(612IO &IO, MachO::note_command &LoadCommand) {613IO.mapRequired("data_owner", LoadCommand.data_owner);614IO.mapRequired("offset", LoadCommand.offset);615IO.mapRequired("size", LoadCommand.size);616}617618void MappingTraits<MachO::build_version_command>::mapping(619IO &IO, MachO::build_version_command &LoadCommand) {620IO.mapRequired("platform", LoadCommand.platform);621IO.mapRequired("minos", LoadCommand.minos);622IO.mapRequired("sdk", LoadCommand.sdk);623IO.mapRequired("ntools", LoadCommand.ntools);624}625626void MappingTraits<MachO::fileset_entry_command>::mapping(627IO &IO, MachO::fileset_entry_command &LoadCommand) {628IO.mapRequired("vmaddr", LoadCommand.vmaddr);629IO.mapRequired("fileoff", LoadCommand.fileoff);630IO.mapRequired("id", LoadCommand.entry_id.offset);631IO.mapOptional("reserved", LoadCommand.reserved);632}633634} // end namespace yaml635636} // end namespace llvm637638639