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