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