| 1 | //===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===// |
| 2 | // |
| 3 | // 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file defines classes for handling the YAML representation of MachO. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "llvm/ObjectYAML/MachOYAML.h" |
| 14 | #include "llvm/ADT/StringRef.h" |
| 15 | #include "llvm/BinaryFormat/MachO.h" |
| 16 | #include "llvm/Support/YAMLTraits.h" |
| 17 | #include "llvm/Support/raw_ostream.h" |
| 18 | #include <cstdint> |
| 19 | #include <cstring> |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | MachOYAML::LoadCommand::~LoadCommand() = default; |
| 24 | |
| 25 | bool MachOYAML::LinkEditData::isEmpty() const { |
| 26 | return 0 == RebaseOpcodes.size() + BindOpcodes.size() + |
| 27 | WeakBindOpcodes.size() + LazyBindOpcodes.size() + |
| 28 | ExportTrie.Children.size() + NameList.size() + |
| 29 | StringTable.size() + FunctionStarts.size() + |
| 30 | ChainedFixups.size() + DataInCode.size(); |
| 31 | } |
| 32 | |
| 33 | namespace yaml { |
| 34 | |
| 35 | void ScalarTraits<char_16>::output(const char_16 &Val, void *, |
| 36 | raw_ostream &Out) { |
| 37 | auto Len = strnlen(string: &Val[0], maxlen: 16); |
| 38 | Out << StringRef(&Val[0], Len); |
| 39 | } |
| 40 | |
| 41 | StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) { |
| 42 | size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size(); |
| 43 | memcpy(dest: (void *)Val, src: Scalar.data(), n: CopySize); |
| 44 | |
| 45 | if (Scalar.size() < 16) { |
| 46 | memset(s: (void *)&Val[Scalar.size()], c: 0, n: 16 - Scalar.size()); |
| 47 | } |
| 48 | |
| 49 | return StringRef(); |
| 50 | } |
| 51 | |
| 52 | QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) { |
| 53 | return needsQuotes(S); |
| 54 | } |
| 55 | |
| 56 | void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) { |
| 57 | Out.write_uuid(UUID: Val); |
| 58 | } |
| 59 | |
| 60 | StringRef ScalarTraits<uuid_t>::input(StringRef Scalar, void *, uuid_t &Val) { |
| 61 | size_t OutIdx = 0; |
| 62 | for (size_t Idx = 0; Idx < Scalar.size(); ++Idx) { |
| 63 | if (Scalar[Idx] == '-' || OutIdx >= 16) |
| 64 | continue; |
| 65 | unsigned long long TempInt; |
| 66 | if (getAsUnsignedInteger(Str: Scalar.slice(Start: Idx, End: Idx + 2), Radix: 16, Result&: TempInt)) |
| 67 | return "invalid number" ; |
| 68 | if (TempInt > 0xFF) |
| 69 | return "out of range number" ; |
| 70 | Val[OutIdx] = static_cast<uint8_t>(TempInt); |
| 71 | ++Idx; // increment idx an extra time because we're consuming 2 chars |
| 72 | ++OutIdx; |
| 73 | } |
| 74 | return StringRef(); |
| 75 | } |
| 76 | |
| 77 | QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) { |
| 78 | return needsQuotes(S); |
| 79 | } |
| 80 | |
| 81 | void MappingTraits<MachOYAML::FileHeader>::( |
| 82 | IO &IO, MachOYAML::FileHeader &FileHdr) { |
| 83 | IO.mapRequired(Key: "magic" , Val&: FileHdr.magic); |
| 84 | IO.mapRequired(Key: "cputype" , Val&: FileHdr.cputype); |
| 85 | IO.mapRequired(Key: "cpusubtype" , Val&: FileHdr.cpusubtype); |
| 86 | IO.mapRequired(Key: "filetype" , Val&: FileHdr.filetype); |
| 87 | IO.mapRequired(Key: "ncmds" , Val&: FileHdr.ncmds); |
| 88 | IO.mapRequired(Key: "sizeofcmds" , Val&: FileHdr.sizeofcmds); |
| 89 | IO.mapRequired(Key: "flags" , Val&: FileHdr.flags); |
| 90 | if (FileHdr.magic == MachO::MH_MAGIC_64 || |
| 91 | FileHdr.magic == MachO::MH_CIGAM_64) |
| 92 | IO.mapRequired(Key: "reserved" , Val&: FileHdr.reserved); |
| 93 | } |
| 94 | |
| 95 | void MappingTraits<MachOYAML::Object>::mapping(IO &IO, |
| 96 | MachOYAML::Object &Object) { |
| 97 | // If the context isn't already set, tag the document as !mach-o. |
| 98 | // For Fat files there will be a different tag so they can be differentiated. |
| 99 | if (!IO.getContext()) { |
| 100 | IO.setContext(&Object); |
| 101 | } |
| 102 | IO.mapTag(Tag: "!mach-o" , Default: true); |
| 103 | IO.mapRequired(Key: "IsLittleEndian" , Val&: Object.IsLittleEndian); |
| 104 | Object.DWARF.IsLittleEndian = Object.IsLittleEndian; |
| 105 | |
| 106 | IO.mapRequired(Key: "FileHeader" , Val&: Object.Header); |
| 107 | Object.DWARF.Is64BitAddrSize = Object.Header.magic == MachO::MH_MAGIC_64 || |
| 108 | Object.Header.magic == MachO::MH_CIGAM_64; |
| 109 | IO.mapOptional(Key: "LoadCommands" , Val&: Object.LoadCommands); |
| 110 | |
| 111 | if (Object.RawLinkEditSegment || !IO.outputting()) |
| 112 | IO.mapOptional(Key: "__LINKEDIT" , Val&: Object.RawLinkEditSegment); |
| 113 | if(!Object.LinkEdit.isEmpty() || !IO.outputting()) |
| 114 | IO.mapOptional(Key: "LinkEditData" , Val&: Object.LinkEdit); |
| 115 | |
| 116 | if(!Object.DWARF.isEmpty() || !IO.outputting()) |
| 117 | IO.mapOptional(Key: "DWARF" , Val&: Object.DWARF); |
| 118 | |
| 119 | if (IO.getContext() == &Object) |
| 120 | IO.setContext(nullptr); |
| 121 | } |
| 122 | |
| 123 | void MappingTraits<MachOYAML::FatHeader>::( |
| 124 | IO &IO, MachOYAML::FatHeader &) { |
| 125 | IO.mapRequired(Key: "magic" , Val&: FatHeader.magic); |
| 126 | IO.mapRequired(Key: "nfat_arch" , Val&: FatHeader.nfat_arch); |
| 127 | } |
| 128 | |
| 129 | void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO, |
| 130 | MachOYAML::FatArch &FatArch) { |
| 131 | IO.mapRequired(Key: "cputype" , Val&: FatArch.cputype); |
| 132 | IO.mapRequired(Key: "cpusubtype" , Val&: FatArch.cpusubtype); |
| 133 | IO.mapRequired(Key: "offset" , Val&: FatArch.offset); |
| 134 | IO.mapRequired(Key: "size" , Val&: FatArch.size); |
| 135 | IO.mapRequired(Key: "align" , Val&: FatArch.align); |
| 136 | IO.mapOptional(Key: "reserved" , Val&: FatArch.reserved, |
| 137 | Default: static_cast<llvm::yaml::Hex32>(0)); |
| 138 | } |
| 139 | |
| 140 | void MappingTraits<MachOYAML::UniversalBinary>::mapping( |
| 141 | IO &IO, MachOYAML::UniversalBinary &UniversalBinary) { |
| 142 | if (!IO.getContext()) { |
| 143 | IO.setContext(&UniversalBinary); |
| 144 | IO.mapTag(Tag: "!fat-mach-o" , Default: true); |
| 145 | } |
| 146 | IO.mapRequired(Key: "FatHeader" , Val&: UniversalBinary.Header); |
| 147 | IO.mapRequired(Key: "FatArchs" , Val&: UniversalBinary.FatArchs); |
| 148 | IO.mapRequired(Key: "Slices" , Val&: UniversalBinary.Slices); |
| 149 | |
| 150 | if (IO.getContext() == &UniversalBinary) |
| 151 | IO.setContext(nullptr); |
| 152 | } |
| 153 | |
| 154 | void MappingTraits<MachOYAML::LinkEditData>::mapping( |
| 155 | IO &IO, MachOYAML::LinkEditData &LinkEditData) { |
| 156 | IO.mapOptional(Key: "RebaseOpcodes" , Val&: LinkEditData.RebaseOpcodes); |
| 157 | IO.mapOptional(Key: "BindOpcodes" , Val&: LinkEditData.BindOpcodes); |
| 158 | IO.mapOptional(Key: "WeakBindOpcodes" , Val&: LinkEditData.WeakBindOpcodes); |
| 159 | IO.mapOptional(Key: "LazyBindOpcodes" , Val&: LinkEditData.LazyBindOpcodes); |
| 160 | if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting()) |
| 161 | IO.mapOptional(Key: "ExportTrie" , Val&: LinkEditData.ExportTrie); |
| 162 | IO.mapOptional(Key: "NameList" , Val&: LinkEditData.NameList); |
| 163 | IO.mapOptional(Key: "StringTable" , Val&: LinkEditData.StringTable); |
| 164 | IO.mapOptional(Key: "IndirectSymbols" , Val&: LinkEditData.IndirectSymbols); |
| 165 | IO.mapOptional(Key: "FunctionStarts" , Val&: LinkEditData.FunctionStarts); |
| 166 | IO.mapOptional(Key: "ChainedFixups" , Val&: LinkEditData.ChainedFixups); |
| 167 | IO.mapOptional(Key: "DataInCode" , Val&: LinkEditData.DataInCode); |
| 168 | } |
| 169 | |
| 170 | void MappingTraits<MachOYAML::RebaseOpcode>::mapping( |
| 171 | IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) { |
| 172 | IO.mapRequired(Key: "Opcode" , Val&: RebaseOpcode.Opcode); |
| 173 | IO.mapRequired(Key: "Imm" , Val&: RebaseOpcode.Imm); |
| 174 | IO.mapOptional(Key: "ExtraData" , Val&: RebaseOpcode.ExtraData); |
| 175 | } |
| 176 | |
| 177 | void MappingTraits<MachOYAML::BindOpcode>::mapping( |
| 178 | IO &IO, MachOYAML::BindOpcode &BindOpcode) { |
| 179 | IO.mapRequired(Key: "Opcode" , Val&: BindOpcode.Opcode); |
| 180 | IO.mapRequired(Key: "Imm" , Val&: BindOpcode.Imm); |
| 181 | IO.mapOptional(Key: "ULEBExtraData" , Val&: BindOpcode.ULEBExtraData); |
| 182 | IO.mapOptional(Key: "SLEBExtraData" , Val&: BindOpcode.SLEBExtraData); |
| 183 | IO.mapOptional(Key: "Symbol" , Val&: BindOpcode.Symbol); |
| 184 | } |
| 185 | |
| 186 | void MappingTraits<MachOYAML::ExportEntry>::mapping( |
| 187 | IO &IO, MachOYAML::ExportEntry &ExportEntry) { |
| 188 | IO.mapRequired(Key: "TerminalSize" , Val&: ExportEntry.TerminalSize); |
| 189 | IO.mapOptional(Key: "NodeOffset" , Val&: ExportEntry.NodeOffset); |
| 190 | IO.mapOptional(Key: "Name" , Val&: ExportEntry.Name); |
| 191 | IO.mapOptional(Key: "Flags" , Val&: ExportEntry.Flags); |
| 192 | IO.mapOptional(Key: "Address" , Val&: ExportEntry.Address); |
| 193 | IO.mapOptional(Key: "Other" , Val&: ExportEntry.Other); |
| 194 | IO.mapOptional(Key: "ImportName" , Val&: ExportEntry.ImportName); |
| 195 | IO.mapOptional(Key: "Children" , Val&: ExportEntry.Children); |
| 196 | } |
| 197 | |
| 198 | void MappingTraits<MachOYAML::NListEntry>::mapping( |
| 199 | IO &IO, MachOYAML::NListEntry &NListEntry) { |
| 200 | IO.mapRequired(Key: "n_strx" , Val&: NListEntry.n_strx); |
| 201 | IO.mapRequired(Key: "n_type" , Val&: NListEntry.n_type); |
| 202 | IO.mapRequired(Key: "n_sect" , Val&: NListEntry.n_sect); |
| 203 | IO.mapRequired(Key: "n_desc" , Val&: NListEntry.n_desc); |
| 204 | IO.mapRequired(Key: "n_value" , Val&: NListEntry.n_value); |
| 205 | } |
| 206 | |
| 207 | void MappingTraits<MachOYAML::DataInCodeEntry>::mapping( |
| 208 | IO &IO, MachOYAML::DataInCodeEntry &DataInCodeEntry) { |
| 209 | IO.mapRequired(Key: "Offset" , Val&: DataInCodeEntry.Offset); |
| 210 | IO.mapRequired(Key: "Length" , Val&: DataInCodeEntry.Length); |
| 211 | IO.mapRequired(Key: "Kind" , Val&: DataInCodeEntry.Kind); |
| 212 | } |
| 213 | |
| 214 | template <typename StructType> |
| 215 | void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {} |
| 216 | |
| 217 | template <> |
| 218 | void mapLoadCommandData<MachO::segment_command>( |
| 219 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 220 | IO.mapOptional(Key: "Sections" , Val&: LoadCommand.Sections); |
| 221 | } |
| 222 | |
| 223 | template <> |
| 224 | void mapLoadCommandData<MachO::segment_command_64>( |
| 225 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 226 | IO.mapOptional(Key: "Sections" , Val&: LoadCommand.Sections); |
| 227 | } |
| 228 | |
| 229 | template <> |
| 230 | void mapLoadCommandData<MachO::dylib_command>( |
| 231 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 232 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 233 | } |
| 234 | |
| 235 | template <> |
| 236 | void mapLoadCommandData<MachO::rpath_command>( |
| 237 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 238 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 239 | } |
| 240 | |
| 241 | template <> |
| 242 | void mapLoadCommandData<MachO::dylinker_command>( |
| 243 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 244 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 245 | } |
| 246 | |
| 247 | template <> |
| 248 | void mapLoadCommandData<MachO::sub_framework_command>( |
| 249 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 250 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 251 | } |
| 252 | |
| 253 | template <> |
| 254 | void mapLoadCommandData<MachO::sub_umbrella_command>( |
| 255 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 256 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 257 | } |
| 258 | |
| 259 | template <> |
| 260 | void mapLoadCommandData<MachO::sub_client_command>( |
| 261 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 262 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 263 | } |
| 264 | |
| 265 | template <> |
| 266 | void mapLoadCommandData<MachO::sub_library_command>( |
| 267 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 268 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 269 | } |
| 270 | |
| 271 | template <> |
| 272 | void mapLoadCommandData<MachO::build_version_command>( |
| 273 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 274 | IO.mapOptional(Key: "Tools" , Val&: LoadCommand.Tools); |
| 275 | } |
| 276 | |
| 277 | template <> |
| 278 | void mapLoadCommandData<MachO::target_triple_command>( |
| 279 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 280 | IO.mapOptional(Key: "Content" , Val&: LoadCommand.Content); |
| 281 | } |
| 282 | |
| 283 | void MappingTraits<MachOYAML::LoadCommand>::mapping( |
| 284 | IO &IO, MachOYAML::LoadCommand &LoadCommand) { |
| 285 | MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>( |
| 286 | LoadCommand.Data.load_command_data.cmd); |
| 287 | IO.mapRequired(Key: "cmd" , Val&: TempCmd); |
| 288 | LoadCommand.Data.load_command_data.cmd = TempCmd; |
| 289 | IO.mapRequired(Key: "cmdsize" , Val&: LoadCommand.Data.load_command_data.cmdsize); |
| 290 | |
| 291 | #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ |
| 292 | case MachO::LCName: \ |
| 293 | MappingTraits<MachO::LCStruct>::mapping(IO, \ |
| 294 | LoadCommand.Data.LCStruct##_data); \ |
| 295 | mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \ |
| 296 | break; |
| 297 | |
| 298 | switch (LoadCommand.Data.load_command_data.cmd) { |
| 299 | #include "llvm/BinaryFormat/MachO.def" |
| 300 | } |
| 301 | IO.mapOptional(Key: "PayloadBytes" , Val&: LoadCommand.PayloadBytes); |
| 302 | IO.mapOptional(Key: "ZeroPadBytes" , Val&: LoadCommand.ZeroPadBytes, Default: (uint64_t)0ull); |
| 303 | } |
| 304 | |
| 305 | void MappingTraits<MachO::dyld_info_command>::mapping( |
| 306 | IO &IO, MachO::dyld_info_command &LoadCommand) { |
| 307 | IO.mapRequired(Key: "rebase_off" , Val&: LoadCommand.rebase_off); |
| 308 | IO.mapRequired(Key: "rebase_size" , Val&: LoadCommand.rebase_size); |
| 309 | IO.mapRequired(Key: "bind_off" , Val&: LoadCommand.bind_off); |
| 310 | IO.mapRequired(Key: "bind_size" , Val&: LoadCommand.bind_size); |
| 311 | IO.mapRequired(Key: "weak_bind_off" , Val&: LoadCommand.weak_bind_off); |
| 312 | IO.mapRequired(Key: "weak_bind_size" , Val&: LoadCommand.weak_bind_size); |
| 313 | IO.mapRequired(Key: "lazy_bind_off" , Val&: LoadCommand.lazy_bind_off); |
| 314 | IO.mapRequired(Key: "lazy_bind_size" , Val&: LoadCommand.lazy_bind_size); |
| 315 | IO.mapRequired(Key: "export_off" , Val&: LoadCommand.export_off); |
| 316 | IO.mapRequired(Key: "export_size" , Val&: LoadCommand.export_size); |
| 317 | } |
| 318 | |
| 319 | void MappingTraits<MachOYAML::Relocation>::mapping( |
| 320 | IO &IO, MachOYAML::Relocation &Relocation) { |
| 321 | IO.mapRequired(Key: "address" , Val&: Relocation.address); |
| 322 | IO.mapRequired(Key: "symbolnum" , Val&: Relocation.symbolnum); |
| 323 | IO.mapRequired(Key: "pcrel" , Val&: Relocation.is_pcrel); |
| 324 | IO.mapRequired(Key: "length" , Val&: Relocation.length); |
| 325 | IO.mapRequired(Key: "extern" , Val&: Relocation.is_extern); |
| 326 | IO.mapRequired(Key: "type" , Val&: Relocation.type); |
| 327 | IO.mapRequired(Key: "scattered" , Val&: Relocation.is_scattered); |
| 328 | IO.mapRequired(Key: "value" , Val&: Relocation.value); |
| 329 | } |
| 330 | |
| 331 | void MappingTraits<MachOYAML::Section>::mapping(IO &IO, |
| 332 | MachOYAML::Section &Section) { |
| 333 | IO.mapRequired(Key: "sectname" , Val&: Section.sectname); |
| 334 | IO.mapRequired(Key: "segname" , Val&: Section.segname); |
| 335 | IO.mapRequired(Key: "addr" , Val&: Section.addr); |
| 336 | IO.mapRequired(Key: "size" , Val&: Section.size); |
| 337 | IO.mapRequired(Key: "offset" , Val&: Section.offset); |
| 338 | IO.mapRequired(Key: "align" , Val&: Section.align); |
| 339 | IO.mapRequired(Key: "reloff" , Val&: Section.reloff); |
| 340 | IO.mapRequired(Key: "nreloc" , Val&: Section.nreloc); |
| 341 | IO.mapRequired(Key: "flags" , Val&: Section.flags); |
| 342 | IO.mapRequired(Key: "reserved1" , Val&: Section.reserved1); |
| 343 | IO.mapRequired(Key: "reserved2" , Val&: Section.reserved2); |
| 344 | IO.mapOptional(Key: "reserved3" , Val&: Section.reserved3); |
| 345 | IO.mapOptional(Key: "content" , Val&: Section.content); |
| 346 | IO.mapOptional(Key: "relocations" , Val&: Section.relocations); |
| 347 | } |
| 348 | |
| 349 | std::string |
| 350 | MappingTraits<MachOYAML::Section>::validate(IO &IO, |
| 351 | MachOYAML::Section &Section) { |
| 352 | // Can't check the `size`, as it's required and may be left uninitialized by |
| 353 | // previous error. |
| 354 | if (!IO.error() && Section.content && |
| 355 | Section.size < Section.content->binary_size()) |
| 356 | return "Section size must be greater than or equal to the content size" ; |
| 357 | return "" ; |
| 358 | } |
| 359 | |
| 360 | void MappingTraits<MachO::build_tool_version>::mapping( |
| 361 | IO &IO, MachO::build_tool_version &tool) { |
| 362 | IO.mapRequired(Key: "tool" , Val&: tool.tool); |
| 363 | IO.mapRequired(Key: "version" , Val&: tool.version); |
| 364 | } |
| 365 | |
| 366 | void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) { |
| 367 | IO.mapRequired(Key: "name" , Val&: DylibStruct.name); |
| 368 | IO.mapRequired(Key: "timestamp" , Val&: DylibStruct.timestamp); |
| 369 | IO.mapRequired(Key: "current_version" , Val&: DylibStruct.current_version); |
| 370 | IO.mapRequired(Key: "compatibility_version" , Val&: DylibStruct.compatibility_version); |
| 371 | } |
| 372 | |
| 373 | void MappingTraits<MachO::dylib_command>::mapping( |
| 374 | IO &IO, MachO::dylib_command &LoadCommand) { |
| 375 | IO.mapRequired(Key: "dylib" , Val&: LoadCommand.dylib); |
| 376 | } |
| 377 | |
| 378 | void MappingTraits<MachO::dylinker_command>::mapping( |
| 379 | IO &IO, MachO::dylinker_command &LoadCommand) { |
| 380 | IO.mapRequired(Key: "name" , Val&: LoadCommand.name); |
| 381 | } |
| 382 | |
| 383 | void MappingTraits<MachO::dysymtab_command>::mapping( |
| 384 | IO &IO, MachO::dysymtab_command &LoadCommand) { |
| 385 | IO.mapRequired(Key: "ilocalsym" , Val&: LoadCommand.ilocalsym); |
| 386 | IO.mapRequired(Key: "nlocalsym" , Val&: LoadCommand.nlocalsym); |
| 387 | IO.mapRequired(Key: "iextdefsym" , Val&: LoadCommand.iextdefsym); |
| 388 | IO.mapRequired(Key: "nextdefsym" , Val&: LoadCommand.nextdefsym); |
| 389 | IO.mapRequired(Key: "iundefsym" , Val&: LoadCommand.iundefsym); |
| 390 | IO.mapRequired(Key: "nundefsym" , Val&: LoadCommand.nundefsym); |
| 391 | IO.mapRequired(Key: "tocoff" , Val&: LoadCommand.tocoff); |
| 392 | IO.mapRequired(Key: "ntoc" , Val&: LoadCommand.ntoc); |
| 393 | IO.mapRequired(Key: "modtaboff" , Val&: LoadCommand.modtaboff); |
| 394 | IO.mapRequired(Key: "nmodtab" , Val&: LoadCommand.nmodtab); |
| 395 | IO.mapRequired(Key: "extrefsymoff" , Val&: LoadCommand.extrefsymoff); |
| 396 | IO.mapRequired(Key: "nextrefsyms" , Val&: LoadCommand.nextrefsyms); |
| 397 | IO.mapRequired(Key: "indirectsymoff" , Val&: LoadCommand.indirectsymoff); |
| 398 | IO.mapRequired(Key: "nindirectsyms" , Val&: LoadCommand.nindirectsyms); |
| 399 | IO.mapRequired(Key: "extreloff" , Val&: LoadCommand.extreloff); |
| 400 | IO.mapRequired(Key: "nextrel" , Val&: LoadCommand.nextrel); |
| 401 | IO.mapRequired(Key: "locreloff" , Val&: LoadCommand.locreloff); |
| 402 | IO.mapRequired(Key: "nlocrel" , Val&: LoadCommand.nlocrel); |
| 403 | } |
| 404 | |
| 405 | void MappingTraits<MachO::encryption_info_command>::mapping( |
| 406 | IO &IO, MachO::encryption_info_command &LoadCommand) { |
| 407 | IO.mapRequired(Key: "cryptoff" , Val&: LoadCommand.cryptoff); |
| 408 | IO.mapRequired(Key: "cryptsize" , Val&: LoadCommand.cryptsize); |
| 409 | IO.mapRequired(Key: "cryptid" , Val&: LoadCommand.cryptid); |
| 410 | } |
| 411 | |
| 412 | void MappingTraits<MachO::encryption_info_command_64>::mapping( |
| 413 | IO &IO, MachO::encryption_info_command_64 &LoadCommand) { |
| 414 | IO.mapRequired(Key: "cryptoff" , Val&: LoadCommand.cryptoff); |
| 415 | IO.mapRequired(Key: "cryptsize" , Val&: LoadCommand.cryptsize); |
| 416 | IO.mapRequired(Key: "cryptid" , Val&: LoadCommand.cryptid); |
| 417 | IO.mapRequired(Key: "pad" , Val&: LoadCommand.pad); |
| 418 | } |
| 419 | |
| 420 | void MappingTraits<MachO::entry_point_command>::mapping( |
| 421 | IO &IO, MachO::entry_point_command &LoadCommand) { |
| 422 | IO.mapRequired(Key: "entryoff" , Val&: LoadCommand.entryoff); |
| 423 | IO.mapRequired(Key: "stacksize" , Val&: LoadCommand.stacksize); |
| 424 | } |
| 425 | |
| 426 | void MappingTraits<MachO::fvmfile_command>::mapping( |
| 427 | IO &IO, MachO::fvmfile_command &LoadCommand) { |
| 428 | IO.mapRequired(Key: "name" , Val&: LoadCommand.name); |
| 429 | IO.mapRequired(Key: "header_addr" , Val&: LoadCommand.header_addr); |
| 430 | } |
| 431 | |
| 432 | void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) { |
| 433 | IO.mapRequired(Key: "name" , Val&: FVMLib.name); |
| 434 | IO.mapRequired(Key: "minor_version" , Val&: FVMLib.minor_version); |
| 435 | IO.mapRequired(Key: "header_addr" , Val&: FVMLib.header_addr); |
| 436 | } |
| 437 | |
| 438 | void MappingTraits<MachO::fvmlib_command>::mapping( |
| 439 | IO &IO, MachO::fvmlib_command &LoadCommand) { |
| 440 | IO.mapRequired(Key: "fvmlib" , Val&: LoadCommand.fvmlib); |
| 441 | } |
| 442 | |
| 443 | void MappingTraits<MachO::ident_command>::mapping( |
| 444 | IO &IO, MachO::ident_command &LoadCommand) {} |
| 445 | |
| 446 | void MappingTraits<MachO::linkedit_data_command>::mapping( |
| 447 | IO &IO, MachO::linkedit_data_command &LoadCommand) { |
| 448 | IO.mapRequired(Key: "dataoff" , Val&: LoadCommand.dataoff); |
| 449 | IO.mapRequired(Key: "datasize" , Val&: LoadCommand.datasize); |
| 450 | } |
| 451 | |
| 452 | void MappingTraits<MachO::linker_option_command>::mapping( |
| 453 | IO &IO, MachO::linker_option_command &LoadCommand) { |
| 454 | IO.mapRequired(Key: "count" , Val&: LoadCommand.count); |
| 455 | } |
| 456 | |
| 457 | void MappingTraits<MachO::prebind_cksum_command>::mapping( |
| 458 | IO &IO, MachO::prebind_cksum_command &LoadCommand) { |
| 459 | IO.mapRequired(Key: "cksum" , Val&: LoadCommand.cksum); |
| 460 | } |
| 461 | |
| 462 | void MappingTraits<MachO::load_command>::mapping( |
| 463 | IO &IO, MachO::load_command &LoadCommand) {} |
| 464 | |
| 465 | void MappingTraits<MachO::prebound_dylib_command>::mapping( |
| 466 | IO &IO, MachO::prebound_dylib_command &LoadCommand) { |
| 467 | IO.mapRequired(Key: "name" , Val&: LoadCommand.name); |
| 468 | IO.mapRequired(Key: "nmodules" , Val&: LoadCommand.nmodules); |
| 469 | IO.mapRequired(Key: "linked_modules" , Val&: LoadCommand.linked_modules); |
| 470 | } |
| 471 | |
| 472 | void MappingTraits<MachO::routines_command>::mapping( |
| 473 | IO &IO, MachO::routines_command &LoadCommand) { |
| 474 | IO.mapRequired(Key: "init_address" , Val&: LoadCommand.init_address); |
| 475 | IO.mapRequired(Key: "init_module" , Val&: LoadCommand.init_module); |
| 476 | IO.mapRequired(Key: "reserved1" , Val&: LoadCommand.reserved1); |
| 477 | IO.mapRequired(Key: "reserved2" , Val&: LoadCommand.reserved2); |
| 478 | IO.mapRequired(Key: "reserved3" , Val&: LoadCommand.reserved3); |
| 479 | IO.mapRequired(Key: "reserved4" , Val&: LoadCommand.reserved4); |
| 480 | IO.mapRequired(Key: "reserved5" , Val&: LoadCommand.reserved5); |
| 481 | IO.mapRequired(Key: "reserved6" , Val&: LoadCommand.reserved6); |
| 482 | } |
| 483 | |
| 484 | void MappingTraits<MachO::routines_command_64>::mapping( |
| 485 | IO &IO, MachO::routines_command_64 &LoadCommand) { |
| 486 | IO.mapRequired(Key: "init_address" , Val&: LoadCommand.init_address); |
| 487 | IO.mapRequired(Key: "init_module" , Val&: LoadCommand.init_module); |
| 488 | IO.mapRequired(Key: "reserved1" , Val&: LoadCommand.reserved1); |
| 489 | IO.mapRequired(Key: "reserved2" , Val&: LoadCommand.reserved2); |
| 490 | IO.mapRequired(Key: "reserved3" , Val&: LoadCommand.reserved3); |
| 491 | IO.mapRequired(Key: "reserved4" , Val&: LoadCommand.reserved4); |
| 492 | IO.mapRequired(Key: "reserved5" , Val&: LoadCommand.reserved5); |
| 493 | IO.mapRequired(Key: "reserved6" , Val&: LoadCommand.reserved6); |
| 494 | } |
| 495 | |
| 496 | void MappingTraits<MachO::rpath_command>::mapping( |
| 497 | IO &IO, MachO::rpath_command &LoadCommand) { |
| 498 | IO.mapRequired(Key: "path" , Val&: LoadCommand.path); |
| 499 | } |
| 500 | |
| 501 | void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) { |
| 502 | IO.mapRequired(Key: "sectname" , Val&: Section.sectname); |
| 503 | IO.mapRequired(Key: "segname" , Val&: Section.segname); |
| 504 | IO.mapRequired(Key: "addr" , Val&: Section.addr); |
| 505 | IO.mapRequired(Key: "size" , Val&: Section.size); |
| 506 | IO.mapRequired(Key: "offset" , Val&: Section.offset); |
| 507 | IO.mapRequired(Key: "align" , Val&: Section.align); |
| 508 | IO.mapRequired(Key: "reloff" , Val&: Section.reloff); |
| 509 | IO.mapRequired(Key: "nreloc" , Val&: Section.nreloc); |
| 510 | IO.mapRequired(Key: "flags" , Val&: Section.flags); |
| 511 | IO.mapRequired(Key: "reserved1" , Val&: Section.reserved1); |
| 512 | IO.mapRequired(Key: "reserved2" , Val&: Section.reserved2); |
| 513 | } |
| 514 | |
| 515 | void MappingTraits<MachO::section_64>::mapping(IO &IO, |
| 516 | MachO::section_64 &Section) { |
| 517 | IO.mapRequired(Key: "sectname" , Val&: Section.sectname); |
| 518 | IO.mapRequired(Key: "segname" , Val&: Section.segname); |
| 519 | IO.mapRequired(Key: "addr" , Val&: Section.addr); |
| 520 | IO.mapRequired(Key: "size" , Val&: Section.size); |
| 521 | IO.mapRequired(Key: "offset" , Val&: Section.offset); |
| 522 | IO.mapRequired(Key: "align" , Val&: Section.align); |
| 523 | IO.mapRequired(Key: "reloff" , Val&: Section.reloff); |
| 524 | IO.mapRequired(Key: "nreloc" , Val&: Section.nreloc); |
| 525 | IO.mapRequired(Key: "flags" , Val&: Section.flags); |
| 526 | IO.mapRequired(Key: "reserved1" , Val&: Section.reserved1); |
| 527 | IO.mapRequired(Key: "reserved2" , Val&: Section.reserved2); |
| 528 | IO.mapRequired(Key: "reserved3" , Val&: Section.reserved3); |
| 529 | } |
| 530 | |
| 531 | void MappingTraits<MachO::segment_command>::mapping( |
| 532 | IO &IO, MachO::segment_command &LoadCommand) { |
| 533 | IO.mapRequired(Key: "segname" , Val&: LoadCommand.segname); |
| 534 | IO.mapRequired(Key: "vmaddr" , Val&: LoadCommand.vmaddr); |
| 535 | IO.mapRequired(Key: "vmsize" , Val&: LoadCommand.vmsize); |
| 536 | IO.mapRequired(Key: "fileoff" , Val&: LoadCommand.fileoff); |
| 537 | IO.mapRequired(Key: "filesize" , Val&: LoadCommand.filesize); |
| 538 | IO.mapRequired(Key: "maxprot" , Val&: LoadCommand.maxprot); |
| 539 | IO.mapRequired(Key: "initprot" , Val&: LoadCommand.initprot); |
| 540 | IO.mapRequired(Key: "nsects" , Val&: LoadCommand.nsects); |
| 541 | IO.mapRequired(Key: "flags" , Val&: LoadCommand.flags); |
| 542 | } |
| 543 | |
| 544 | void MappingTraits<MachO::segment_command_64>::mapping( |
| 545 | IO &IO, MachO::segment_command_64 &LoadCommand) { |
| 546 | IO.mapRequired(Key: "segname" , Val&: LoadCommand.segname); |
| 547 | IO.mapRequired(Key: "vmaddr" , Val&: LoadCommand.vmaddr); |
| 548 | IO.mapRequired(Key: "vmsize" , Val&: LoadCommand.vmsize); |
| 549 | IO.mapRequired(Key: "fileoff" , Val&: LoadCommand.fileoff); |
| 550 | IO.mapRequired(Key: "filesize" , Val&: LoadCommand.filesize); |
| 551 | IO.mapRequired(Key: "maxprot" , Val&: LoadCommand.maxprot); |
| 552 | IO.mapRequired(Key: "initprot" , Val&: LoadCommand.initprot); |
| 553 | IO.mapRequired(Key: "nsects" , Val&: LoadCommand.nsects); |
| 554 | IO.mapRequired(Key: "flags" , Val&: LoadCommand.flags); |
| 555 | } |
| 556 | |
| 557 | void MappingTraits<MachO::source_version_command>::mapping( |
| 558 | IO &IO, MachO::source_version_command &LoadCommand) { |
| 559 | IO.mapRequired(Key: "version" , Val&: LoadCommand.version); |
| 560 | } |
| 561 | |
| 562 | void MappingTraits<MachO::sub_client_command>::mapping( |
| 563 | IO &IO, MachO::sub_client_command &LoadCommand) { |
| 564 | IO.mapRequired(Key: "client" , Val&: LoadCommand.client); |
| 565 | } |
| 566 | |
| 567 | void MappingTraits<MachO::sub_framework_command>::mapping( |
| 568 | IO &IO, MachO::sub_framework_command &LoadCommand) { |
| 569 | IO.mapRequired(Key: "umbrella" , Val&: LoadCommand.umbrella); |
| 570 | } |
| 571 | |
| 572 | void MappingTraits<MachO::sub_library_command>::mapping( |
| 573 | IO &IO, MachO::sub_library_command &LoadCommand) { |
| 574 | IO.mapRequired(Key: "sub_library" , Val&: LoadCommand.sub_library); |
| 575 | } |
| 576 | |
| 577 | void MappingTraits<MachO::sub_umbrella_command>::mapping( |
| 578 | IO &IO, MachO::sub_umbrella_command &LoadCommand) { |
| 579 | IO.mapRequired(Key: "sub_umbrella" , Val&: LoadCommand.sub_umbrella); |
| 580 | } |
| 581 | |
| 582 | void MappingTraits<MachO::symseg_command>::mapping( |
| 583 | IO &IO, MachO::symseg_command &LoadCommand) { |
| 584 | IO.mapRequired(Key: "offset" , Val&: LoadCommand.offset); |
| 585 | IO.mapRequired(Key: "size" , Val&: LoadCommand.size); |
| 586 | } |
| 587 | |
| 588 | void MappingTraits<MachO::symtab_command>::mapping( |
| 589 | IO &IO, MachO::symtab_command &LoadCommand) { |
| 590 | IO.mapRequired(Key: "symoff" , Val&: LoadCommand.symoff); |
| 591 | IO.mapRequired(Key: "nsyms" , Val&: LoadCommand.nsyms); |
| 592 | IO.mapRequired(Key: "stroff" , Val&: LoadCommand.stroff); |
| 593 | IO.mapRequired(Key: "strsize" , Val&: LoadCommand.strsize); |
| 594 | } |
| 595 | |
| 596 | void MappingTraits<MachO::thread_command>::mapping( |
| 597 | IO &IO, MachO::thread_command &LoadCommand) {} |
| 598 | |
| 599 | void MappingTraits<MachO::twolevel_hints_command>::mapping( |
| 600 | IO &IO, MachO::twolevel_hints_command &LoadCommand) { |
| 601 | IO.mapRequired(Key: "offset" , Val&: LoadCommand.offset); |
| 602 | IO.mapRequired(Key: "nhints" , Val&: LoadCommand.nhints); |
| 603 | } |
| 604 | |
| 605 | void MappingTraits<MachO::uuid_command>::mapping( |
| 606 | IO &IO, MachO::uuid_command &LoadCommand) { |
| 607 | IO.mapRequired(Key: "uuid" , Val&: LoadCommand.uuid); |
| 608 | } |
| 609 | |
| 610 | void MappingTraits<MachO::version_min_command>::mapping( |
| 611 | IO &IO, MachO::version_min_command &LoadCommand) { |
| 612 | IO.mapRequired(Key: "version" , Val&: LoadCommand.version); |
| 613 | IO.mapRequired(Key: "sdk" , Val&: LoadCommand.sdk); |
| 614 | } |
| 615 | |
| 616 | void MappingTraits<MachO::note_command>::mapping( |
| 617 | IO &IO, MachO::note_command &LoadCommand) { |
| 618 | IO.mapRequired(Key: "data_owner" , Val&: LoadCommand.data_owner); |
| 619 | IO.mapRequired(Key: "offset" , Val&: LoadCommand.offset); |
| 620 | IO.mapRequired(Key: "size" , Val&: LoadCommand.size); |
| 621 | } |
| 622 | |
| 623 | void MappingTraits<MachO::build_version_command>::mapping( |
| 624 | IO &IO, MachO::build_version_command &LoadCommand) { |
| 625 | IO.mapRequired(Key: "platform" , Val&: LoadCommand.platform); |
| 626 | IO.mapRequired(Key: "minos" , Val&: LoadCommand.minos); |
| 627 | IO.mapRequired(Key: "sdk" , Val&: LoadCommand.sdk); |
| 628 | IO.mapRequired(Key: "ntools" , Val&: LoadCommand.ntools); |
| 629 | } |
| 630 | |
| 631 | void MappingTraits<MachO::target_triple_command>::mapping( |
| 632 | IO &IO, MachO::target_triple_command &LoadCommand) { |
| 633 | IO.mapRequired(Key: "triple" , Val&: LoadCommand.triple); |
| 634 | } |
| 635 | |
| 636 | void MappingTraits<MachO::fileset_entry_command>::mapping( |
| 637 | IO &IO, MachO::fileset_entry_command &LoadCommand) { |
| 638 | IO.mapRequired(Key: "vmaddr" , Val&: LoadCommand.vmaddr); |
| 639 | IO.mapRequired(Key: "fileoff" , Val&: LoadCommand.fileoff); |
| 640 | IO.mapRequired(Key: "id" , Val&: LoadCommand.entry_id.offset); |
| 641 | IO.mapOptional(Key: "reserved" , Val&: LoadCommand.reserved); |
| 642 | } |
| 643 | |
| 644 | } // end namespace yaml |
| 645 | |
| 646 | } // end namespace llvm |
| 647 | |