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