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