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/ADT/StringRef.h" 16 #include "llvm/BinaryFormat/MachO.h" 17 #include "llvm/Support/Format.h" 18 #include "llvm/Support/Host.h" 19 #include "llvm/Support/YAMLTraits.h" 20 #include "llvm/Support/raw_ostream.h" 21 #include <cinttypes> 22 #include <cstdint> 23 #include <cstring> 24 25 namespace llvm { 26 27 MachOYAML::LoadCommand::~LoadCommand() = default; 28 29 bool MachOYAML::LinkEditData::isEmpty() const { 30 return 0 == 31 RebaseOpcodes.size() + BindOpcodes.size() + WeakBindOpcodes.size() + 32 LazyBindOpcodes.size() + ExportTrie.Children.size() + 33 NameList.size() + StringTable.size(); 34 } 35 36 namespace yaml { 37 38 void ScalarTraits<char_16>::output(const char_16 &Val, void *, 39 raw_ostream &Out) { 40 auto Len = strnlen(&Val[0], 16); 41 Out << StringRef(&Val[0], Len); 42 } 43 44 StringRef ScalarTraits<char_16>::input(StringRef Scalar, void *, char_16 &Val) { 45 size_t CopySize = 16 >= Scalar.size() ? 16 : Scalar.size(); 46 memcpy((void *)Val, Scalar.data(), CopySize); 47 48 if (Scalar.size() < 16) { 49 memset((void *)&Val[Scalar.size()], 0, 16 - Scalar.size()); 50 } 51 52 return StringRef(); 53 } 54 55 QuotingType ScalarTraits<char_16>::mustQuote(StringRef S) { 56 return needsQuotes(S); 57 } 58 59 void ScalarTraits<uuid_t>::output(const uuid_t &Val, void *, raw_ostream &Out) { 60 Out.write_uuid(Val); 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 QuotingType ScalarTraits<uuid_t>::mustQuote(StringRef S) { 81 return needsQuotes(S); 82 } 83 84 void MappingTraits<MachOYAML::FileHeader>::mapping( 85 IO &IO, MachOYAML::FileHeader &FileHdr) { 86 IO.mapRequired("magic", FileHdr.magic); 87 IO.mapRequired("cputype", FileHdr.cputype); 88 IO.mapRequired("cpusubtype", FileHdr.cpusubtype); 89 IO.mapRequired("filetype", FileHdr.filetype); 90 IO.mapRequired("ncmds", FileHdr.ncmds); 91 IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds); 92 IO.mapRequired("flags", FileHdr.flags); 93 if (FileHdr.magic == MachO::MH_MAGIC_64 || 94 FileHdr.magic == MachO::MH_CIGAM_64) 95 IO.mapRequired("reserved", FileHdr.reserved); 96 } 97 98 void MappingTraits<MachOYAML::Object>::mapping(IO &IO, 99 MachOYAML::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. 102 if (!IO.getContext()) { 103 IO.setContext(&Object); 104 } 105 IO.mapTag("!mach-o", true); 106 IO.mapOptional("IsLittleEndian", Object.IsLittleEndian, 107 sys::IsLittleEndianHost); 108 Object.DWARF.IsLittleEndian = Object.IsLittleEndian; 109 110 IO.mapRequired("FileHeader", Object.Header); 111 IO.mapOptional("LoadCommands", Object.LoadCommands); 112 if(!Object.LinkEdit.isEmpty() || !IO.outputting()) 113 IO.mapOptional("LinkEditData", Object.LinkEdit); 114 115 if(!Object.DWARF.isEmpty() || !IO.outputting()) 116 IO.mapOptional("DWARF", Object.DWARF); 117 118 if (IO.getContext() == &Object) 119 IO.setContext(nullptr); 120 } 121 122 void MappingTraits<MachOYAML::FatHeader>::mapping( 123 IO &IO, MachOYAML::FatHeader &FatHeader) { 124 IO.mapRequired("magic", FatHeader.magic); 125 IO.mapRequired("nfat_arch", FatHeader.nfat_arch); 126 } 127 128 void MappingTraits<MachOYAML::FatArch>::mapping(IO &IO, 129 MachOYAML::FatArch &FatArch) { 130 IO.mapRequired("cputype", FatArch.cputype); 131 IO.mapRequired("cpusubtype", FatArch.cpusubtype); 132 IO.mapRequired("offset", FatArch.offset); 133 IO.mapRequired("size", FatArch.size); 134 IO.mapRequired("align", FatArch.align); 135 IO.mapOptional("reserved", FatArch.reserved, 136 static_cast<llvm::yaml::Hex32>(0)); 137 } 138 139 void MappingTraits<MachOYAML::UniversalBinary>::mapping( 140 IO &IO, MachOYAML::UniversalBinary &UniversalBinary) { 141 if (!IO.getContext()) { 142 IO.setContext(&UniversalBinary); 143 IO.mapTag("!fat-mach-o", true); 144 } 145 IO.mapRequired("FatHeader", UniversalBinary.Header); 146 IO.mapRequired("FatArchs", UniversalBinary.FatArchs); 147 IO.mapRequired("Slices", UniversalBinary.Slices); 148 149 if (IO.getContext() == &UniversalBinary) 150 IO.setContext(nullptr); 151 } 152 153 void MappingTraits<MachOYAML::LinkEditData>::mapping( 154 IO &IO, MachOYAML::LinkEditData &LinkEditData) { 155 IO.mapOptional("RebaseOpcodes", LinkEditData.RebaseOpcodes); 156 IO.mapOptional("BindOpcodes", LinkEditData.BindOpcodes); 157 IO.mapOptional("WeakBindOpcodes", LinkEditData.WeakBindOpcodes); 158 IO.mapOptional("LazyBindOpcodes", LinkEditData.LazyBindOpcodes); 159 if (!LinkEditData.ExportTrie.Children.empty() || !IO.outputting()) 160 IO.mapOptional("ExportTrie", LinkEditData.ExportTrie); 161 IO.mapOptional("NameList", LinkEditData.NameList); 162 IO.mapOptional("StringTable", LinkEditData.StringTable); 163 } 164 165 void MappingTraits<MachOYAML::RebaseOpcode>::mapping( 166 IO &IO, MachOYAML::RebaseOpcode &RebaseOpcode) { 167 IO.mapRequired("Opcode", RebaseOpcode.Opcode); 168 IO.mapRequired("Imm", RebaseOpcode.Imm); 169 IO.mapOptional("ExtraData", RebaseOpcode.ExtraData); 170 } 171 172 void MappingTraits<MachOYAML::BindOpcode>::mapping( 173 IO &IO, MachOYAML::BindOpcode &BindOpcode) { 174 IO.mapRequired("Opcode", BindOpcode.Opcode); 175 IO.mapRequired("Imm", BindOpcode.Imm); 176 IO.mapOptional("ULEBExtraData", BindOpcode.ULEBExtraData); 177 IO.mapOptional("SLEBExtraData", BindOpcode.SLEBExtraData); 178 IO.mapOptional("Symbol", BindOpcode.Symbol); 179 } 180 181 void MappingTraits<MachOYAML::ExportEntry>::mapping( 182 IO &IO, MachOYAML::ExportEntry &ExportEntry) { 183 IO.mapRequired("TerminalSize", ExportEntry.TerminalSize); 184 IO.mapOptional("NodeOffset", ExportEntry.NodeOffset); 185 IO.mapOptional("Name", ExportEntry.Name); 186 IO.mapOptional("Flags", ExportEntry.Flags); 187 IO.mapOptional("Address", ExportEntry.Address); 188 IO.mapOptional("Other", ExportEntry.Other); 189 IO.mapOptional("ImportName", ExportEntry.ImportName); 190 IO.mapOptional("Children", ExportEntry.Children); 191 } 192 193 void MappingTraits<MachOYAML::NListEntry>::mapping( 194 IO &IO, MachOYAML::NListEntry &NListEntry) { 195 IO.mapRequired("n_strx", NListEntry.n_strx); 196 IO.mapRequired("n_type", NListEntry.n_type); 197 IO.mapRequired("n_sect", NListEntry.n_sect); 198 IO.mapRequired("n_desc", NListEntry.n_desc); 199 IO.mapRequired("n_value", NListEntry.n_value); 200 } 201 202 template <typename StructType> 203 void mapLoadCommandData(IO &IO, MachOYAML::LoadCommand &LoadCommand) {} 204 205 template <> 206 void mapLoadCommandData<MachO::segment_command>( 207 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 208 IO.mapOptional("Sections", LoadCommand.Sections); 209 } 210 211 template <> 212 void mapLoadCommandData<MachO::segment_command_64>( 213 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 214 IO.mapOptional("Sections", LoadCommand.Sections); 215 } 216 217 template <> 218 void mapLoadCommandData<MachO::dylib_command>( 219 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 220 IO.mapOptional("PayloadString", LoadCommand.PayloadString); 221 } 222 223 template <> 224 void mapLoadCommandData<MachO::rpath_command>( 225 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 226 IO.mapOptional("PayloadString", LoadCommand.PayloadString); 227 } 228 229 template <> 230 void mapLoadCommandData<MachO::dylinker_command>( 231 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 232 IO.mapOptional("PayloadString", LoadCommand.PayloadString); 233 } 234 235 template <> 236 void mapLoadCommandData<MachO::build_version_command>( 237 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 238 IO.mapOptional("Tools", LoadCommand.Tools); 239 } 240 241 void MappingTraits<MachOYAML::LoadCommand>::mapping( 242 IO &IO, MachOYAML::LoadCommand &LoadCommand) { 243 MachO::LoadCommandType TempCmd = static_cast<MachO::LoadCommandType>( 244 LoadCommand.Data.load_command_data.cmd); 245 IO.mapRequired("cmd", TempCmd); 246 LoadCommand.Data.load_command_data.cmd = TempCmd; 247 IO.mapRequired("cmdsize", LoadCommand.Data.load_command_data.cmdsize); 248 249 #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \ 250 case MachO::LCName: \ 251 MappingTraits<MachO::LCStruct>::mapping(IO, \ 252 LoadCommand.Data.LCStruct##_data); \ 253 mapLoadCommandData<MachO::LCStruct>(IO, LoadCommand); \ 254 break; 255 256 switch (LoadCommand.Data.load_command_data.cmd) { 257 #include "llvm/BinaryFormat/MachO.def" 258 } 259 IO.mapOptional("PayloadBytes", LoadCommand.PayloadBytes); 260 IO.mapOptional("ZeroPadBytes", LoadCommand.ZeroPadBytes, (uint64_t)0ull); 261 } 262 263 void MappingTraits<MachO::dyld_info_command>::mapping( 264 IO &IO, MachO::dyld_info_command &LoadCommand) { 265 IO.mapRequired("rebase_off", LoadCommand.rebase_off); 266 IO.mapRequired("rebase_size", LoadCommand.rebase_size); 267 IO.mapRequired("bind_off", LoadCommand.bind_off); 268 IO.mapRequired("bind_size", LoadCommand.bind_size); 269 IO.mapRequired("weak_bind_off", LoadCommand.weak_bind_off); 270 IO.mapRequired("weak_bind_size", LoadCommand.weak_bind_size); 271 IO.mapRequired("lazy_bind_off", LoadCommand.lazy_bind_off); 272 IO.mapRequired("lazy_bind_size", LoadCommand.lazy_bind_size); 273 IO.mapRequired("export_off", LoadCommand.export_off); 274 IO.mapRequired("export_size", LoadCommand.export_size); 275 } 276 277 void MappingTraits<MachOYAML::Section>::mapping(IO &IO, 278 MachOYAML::Section &Section) { 279 IO.mapRequired("sectname", Section.sectname); 280 IO.mapRequired("segname", Section.segname); 281 IO.mapRequired("addr", Section.addr); 282 IO.mapRequired("size", Section.size); 283 IO.mapRequired("offset", Section.offset); 284 IO.mapRequired("align", Section.align); 285 IO.mapRequired("reloff", Section.reloff); 286 IO.mapRequired("nreloc", Section.nreloc); 287 IO.mapRequired("flags", Section.flags); 288 IO.mapRequired("reserved1", Section.reserved1); 289 IO.mapRequired("reserved2", Section.reserved2); 290 IO.mapOptional("reserved3", Section.reserved3); 291 } 292 293 void MappingTraits<MachO::build_tool_version>::mapping( 294 IO &IO, MachO::build_tool_version &tool) { 295 IO.mapRequired("tool", tool.tool); 296 IO.mapRequired("version", tool.version); 297 } 298 299 void MappingTraits<MachO::dylib>::mapping(IO &IO, MachO::dylib &DylibStruct) { 300 IO.mapRequired("name", DylibStruct.name); 301 IO.mapRequired("timestamp", DylibStruct.timestamp); 302 IO.mapRequired("current_version", DylibStruct.current_version); 303 IO.mapRequired("compatibility_version", DylibStruct.compatibility_version); 304 } 305 306 void MappingTraits<MachO::dylib_command>::mapping( 307 IO &IO, MachO::dylib_command &LoadCommand) { 308 IO.mapRequired("dylib", LoadCommand.dylib); 309 } 310 311 void MappingTraits<MachO::dylinker_command>::mapping( 312 IO &IO, MachO::dylinker_command &LoadCommand) { 313 IO.mapRequired("name", LoadCommand.name); 314 } 315 316 void MappingTraits<MachO::dysymtab_command>::mapping( 317 IO &IO, MachO::dysymtab_command &LoadCommand) { 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 IO.mapRequired("cryptoff", LoadCommand.cryptoff); 341 IO.mapRequired("cryptsize", LoadCommand.cryptsize); 342 IO.mapRequired("cryptid", LoadCommand.cryptid); 343 } 344 345 void MappingTraits<MachO::encryption_info_command_64>::mapping( 346 IO &IO, MachO::encryption_info_command_64 &LoadCommand) { 347 IO.mapRequired("cryptoff", LoadCommand.cryptoff); 348 IO.mapRequired("cryptsize", LoadCommand.cryptsize); 349 IO.mapRequired("cryptid", LoadCommand.cryptid); 350 IO.mapRequired("pad", LoadCommand.pad); 351 } 352 353 void MappingTraits<MachO::entry_point_command>::mapping( 354 IO &IO, MachO::entry_point_command &LoadCommand) { 355 IO.mapRequired("entryoff", LoadCommand.entryoff); 356 IO.mapRequired("stacksize", LoadCommand.stacksize); 357 } 358 359 void MappingTraits<MachO::fvmfile_command>::mapping( 360 IO &IO, MachO::fvmfile_command &LoadCommand) { 361 IO.mapRequired("name", LoadCommand.name); 362 IO.mapRequired("header_addr", LoadCommand.header_addr); 363 } 364 365 void MappingTraits<MachO::fvmlib>::mapping(IO &IO, MachO::fvmlib &FVMLib) { 366 IO.mapRequired("name", FVMLib.name); 367 IO.mapRequired("minor_version", FVMLib.minor_version); 368 IO.mapRequired("header_addr", FVMLib.header_addr); 369 } 370 371 void MappingTraits<MachO::fvmlib_command>::mapping( 372 IO &IO, MachO::fvmlib_command &LoadCommand) { 373 IO.mapRequired("fvmlib", LoadCommand.fvmlib); 374 } 375 376 void MappingTraits<MachO::ident_command>::mapping( 377 IO &IO, MachO::ident_command &LoadCommand) {} 378 379 void MappingTraits<MachO::linkedit_data_command>::mapping( 380 IO &IO, MachO::linkedit_data_command &LoadCommand) { 381 IO.mapRequired("dataoff", LoadCommand.dataoff); 382 IO.mapRequired("datasize", LoadCommand.datasize); 383 } 384 385 void MappingTraits<MachO::linker_option_command>::mapping( 386 IO &IO, MachO::linker_option_command &LoadCommand) { 387 IO.mapRequired("count", LoadCommand.count); 388 } 389 390 void MappingTraits<MachO::prebind_cksum_command>::mapping( 391 IO &IO, MachO::prebind_cksum_command &LoadCommand) { 392 IO.mapRequired("cksum", LoadCommand.cksum); 393 } 394 395 void MappingTraits<MachO::load_command>::mapping( 396 IO &IO, MachO::load_command &LoadCommand) {} 397 398 void MappingTraits<MachO::prebound_dylib_command>::mapping( 399 IO &IO, MachO::prebound_dylib_command &LoadCommand) { 400 IO.mapRequired("name", LoadCommand.name); 401 IO.mapRequired("nmodules", LoadCommand.nmodules); 402 IO.mapRequired("linked_modules", LoadCommand.linked_modules); 403 } 404 405 void MappingTraits<MachO::routines_command>::mapping( 406 IO &IO, MachO::routines_command &LoadCommand) { 407 IO.mapRequired("init_address", LoadCommand.init_address); 408 IO.mapRequired("init_module", LoadCommand.init_module); 409 IO.mapRequired("reserved1", LoadCommand.reserved1); 410 IO.mapRequired("reserved2", LoadCommand.reserved2); 411 IO.mapRequired("reserved3", LoadCommand.reserved3); 412 IO.mapRequired("reserved4", LoadCommand.reserved4); 413 IO.mapRequired("reserved5", LoadCommand.reserved5); 414 IO.mapRequired("reserved6", LoadCommand.reserved6); 415 } 416 417 void MappingTraits<MachO::routines_command_64>::mapping( 418 IO &IO, MachO::routines_command_64 &LoadCommand) { 419 IO.mapRequired("init_address", LoadCommand.init_address); 420 IO.mapRequired("init_module", LoadCommand.init_module); 421 IO.mapRequired("reserved1", LoadCommand.reserved1); 422 IO.mapRequired("reserved2", LoadCommand.reserved2); 423 IO.mapRequired("reserved3", LoadCommand.reserved3); 424 IO.mapRequired("reserved4", LoadCommand.reserved4); 425 IO.mapRequired("reserved5", LoadCommand.reserved5); 426 IO.mapRequired("reserved6", LoadCommand.reserved6); 427 } 428 429 void MappingTraits<MachO::rpath_command>::mapping( 430 IO &IO, MachO::rpath_command &LoadCommand) { 431 IO.mapRequired("path", LoadCommand.path); 432 } 433 434 void MappingTraits<MachO::section>::mapping(IO &IO, MachO::section &Section) { 435 IO.mapRequired("sectname", Section.sectname); 436 IO.mapRequired("segname", Section.segname); 437 IO.mapRequired("addr", Section.addr); 438 IO.mapRequired("size", Section.size); 439 IO.mapRequired("offset", Section.offset); 440 IO.mapRequired("align", Section.align); 441 IO.mapRequired("reloff", Section.reloff); 442 IO.mapRequired("nreloc", Section.nreloc); 443 IO.mapRequired("flags", Section.flags); 444 IO.mapRequired("reserved1", Section.reserved1); 445 IO.mapRequired("reserved2", Section.reserved2); 446 } 447 448 void MappingTraits<MachO::section_64>::mapping(IO &IO, 449 MachO::section_64 &Section) { 450 IO.mapRequired("sectname", Section.sectname); 451 IO.mapRequired("segname", Section.segname); 452 IO.mapRequired("addr", Section.addr); 453 IO.mapRequired("size", Section.size); 454 IO.mapRequired("offset", Section.offset); 455 IO.mapRequired("align", Section.align); 456 IO.mapRequired("reloff", Section.reloff); 457 IO.mapRequired("nreloc", Section.nreloc); 458 IO.mapRequired("flags", Section.flags); 459 IO.mapRequired("reserved1", Section.reserved1); 460 IO.mapRequired("reserved2", Section.reserved2); 461 IO.mapRequired("reserved3", Section.reserved3); 462 } 463 464 void MappingTraits<MachO::segment_command>::mapping( 465 IO &IO, MachO::segment_command &LoadCommand) { 466 IO.mapRequired("segname", LoadCommand.segname); 467 IO.mapRequired("vmaddr", LoadCommand.vmaddr); 468 IO.mapRequired("vmsize", LoadCommand.vmsize); 469 IO.mapRequired("fileoff", LoadCommand.fileoff); 470 IO.mapRequired("filesize", LoadCommand.filesize); 471 IO.mapRequired("maxprot", LoadCommand.maxprot); 472 IO.mapRequired("initprot", LoadCommand.initprot); 473 IO.mapRequired("nsects", LoadCommand.nsects); 474 IO.mapRequired("flags", LoadCommand.flags); 475 } 476 477 void MappingTraits<MachO::segment_command_64>::mapping( 478 IO &IO, MachO::segment_command_64 &LoadCommand) { 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::source_version_command>::mapping( 491 IO &IO, MachO::source_version_command &LoadCommand) { 492 IO.mapRequired("version", LoadCommand.version); 493 } 494 495 void MappingTraits<MachO::sub_client_command>::mapping( 496 IO &IO, MachO::sub_client_command &LoadCommand) { 497 IO.mapRequired("client", LoadCommand.client); 498 } 499 500 void MappingTraits<MachO::sub_framework_command>::mapping( 501 IO &IO, MachO::sub_framework_command &LoadCommand) { 502 IO.mapRequired("umbrella", LoadCommand.umbrella); 503 } 504 505 void MappingTraits<MachO::sub_library_command>::mapping( 506 IO &IO, MachO::sub_library_command &LoadCommand) { 507 IO.mapRequired("sub_library", LoadCommand.sub_library); 508 } 509 510 void MappingTraits<MachO::sub_umbrella_command>::mapping( 511 IO &IO, MachO::sub_umbrella_command &LoadCommand) { 512 IO.mapRequired("sub_umbrella", LoadCommand.sub_umbrella); 513 } 514 515 void MappingTraits<MachO::symseg_command>::mapping( 516 IO &IO, MachO::symseg_command &LoadCommand) { 517 IO.mapRequired("offset", LoadCommand.offset); 518 IO.mapRequired("size", LoadCommand.size); 519 } 520 521 void MappingTraits<MachO::symtab_command>::mapping( 522 IO &IO, MachO::symtab_command &LoadCommand) { 523 IO.mapRequired("symoff", LoadCommand.symoff); 524 IO.mapRequired("nsyms", LoadCommand.nsyms); 525 IO.mapRequired("stroff", LoadCommand.stroff); 526 IO.mapRequired("strsize", LoadCommand.strsize); 527 } 528 529 void MappingTraits<MachO::thread_command>::mapping( 530 IO &IO, MachO::thread_command &LoadCommand) {} 531 532 void MappingTraits<MachO::twolevel_hints_command>::mapping( 533 IO &IO, MachO::twolevel_hints_command &LoadCommand) { 534 IO.mapRequired("offset", LoadCommand.offset); 535 IO.mapRequired("nhints", LoadCommand.nhints); 536 } 537 538 void MappingTraits<MachO::uuid_command>::mapping( 539 IO &IO, MachO::uuid_command &LoadCommand) { 540 IO.mapRequired("uuid", LoadCommand.uuid); 541 } 542 543 void MappingTraits<MachO::version_min_command>::mapping( 544 IO &IO, MachO::version_min_command &LoadCommand) { 545 IO.mapRequired("version", LoadCommand.version); 546 IO.mapRequired("sdk", LoadCommand.sdk); 547 } 548 549 void MappingTraits<MachO::note_command>::mapping( 550 IO &IO, MachO::note_command &LoadCommand) { 551 IO.mapRequired("data_owner", LoadCommand.data_owner); 552 IO.mapRequired("offset", LoadCommand.offset); 553 IO.mapRequired("size", LoadCommand.size); 554 } 555 556 void MappingTraits<MachO::build_version_command>::mapping( 557 IO &IO, MachO::build_version_command &LoadCommand) { 558 IO.mapRequired("platform", LoadCommand.platform); 559 IO.mapRequired("minos", LoadCommand.minos); 560 IO.mapRequired("sdk", LoadCommand.sdk); 561 IO.mapRequired("ntools", LoadCommand.ntools); 562 } 563 564 } // end namespace yaml 565 566 } // end namespace llvm 567