Lines Matching +full:tlv +full:- +full:layout
1 //===-- MachODump.cpp - Object file dumping utility for llvm --------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the MachO-specific dumper for llvm-objdump.
11 //===----------------------------------------------------------------------===//
16 #include "llvm-objdump.h"
17 #include "llvm-c/Disassembler.h"
111 FunctionStartsType = StringSwitch<FunctionStartsMode>(A->getValue()) in parseMachOOptions()
138 TT = MachOObj->getArchTriple(McpuDefault); in GetTarget()
143 // We've inferred a 32-bit ARM target from the object file. All MachO CPUs in GetTarget()
161 WithColor::error(errs(), "llvm-objdump") << "unable to get target for '"; in GetTarget()
166 errs() << "', see --version and --triple.\n"; in GetTarget()
175 reportError(ATypeOrErr.takeError(), A.getObject()->getFileName()); in operator ()()
179 reportError(BTypeOrErr.takeError(), B.getObject()->getFileName()); in operator ()()
290 const StringRef FileName = MachOObj->getFileName(); in getSectionsAndSymbols()
291 for (const SymbolRef &Symbol : MachOObj->symbols()) { in getSectionsAndSymbols()
297 append_range(Sections, MachOObj->sections()); in getSectionsAndSymbols()
300 for (const auto &Command : MachOObj->load_commands()) { in getSectionsAndSymbols()
305 MachOObj->getLinkeditDataLoadCommand(Command); in getSectionsAndSymbols()
307 MachOObj->ReadULEB128s(LLC.dataoff, FoundFns); in getSectionsAndSymbols()
309 MachO::segment_command SLC = MachOObj->getSegmentLoadCommand(Command); in getSectionsAndSymbols()
316 MachO::segment_command_64 SLC = MachOObj->getSegment64LoadCommand(Command); in getSectionsAndSymbols()
337 DTI->second.getLength(Length); in DumpAndSkipDataInCode()
339 DTI->second.getKind(Kind); in DumpAndSkipDataInCode()
342 (PC == (DTI->first + Length - 1)) && (Length & 1)) in DumpAndSkipDataInCode()
356 const StringRef FileName = O->getFileName(); in printRelocationTargetName()
357 if (O->isRelocationScattered(RE)) { in printRelocationTargetName()
358 uint32_t Val = O->getPlainRelocationSymbolNum(RE); in printRelocationTargetName()
360 for (const SymbolRef &Symbol : O->symbols()) { in printRelocationTargetName()
374 StringRef NameOrErr = unwrapOrError(Section.getName(), O->getFileName()); in printRelocationTargetName()
384 bool isExtern = O->getPlainRelocationExternal(RE); in printRelocationTargetName()
385 uint64_t Val = O->getPlainRelocationSymbolNum(RE); in printRelocationTargetName()
387 if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND && in printRelocationTargetName()
388 (O->getArch() == Triple::aarch64 || O->getArch() == Triple::aarch64_be)) { in printRelocationTargetName()
394 symbol_iterator SI = O->symbol_begin(); in printRelocationTargetName()
396 S = unwrapOrError(SI->getName(), FileName); in printRelocationTargetName()
398 section_iterator SI = O->section_begin(); in printRelocationTargetName()
399 // Adjust for the fact that sections are 1-indexed. in printRelocationTargetName()
404 uint32_t I = Val - 1; in printRelocationTargetName()
405 while (I != 0 && SI != O->section_end()) { in printRelocationTargetName()
406 --I; in printRelocationTargetName()
409 if (SI == O->section_end()) { in printRelocationTargetName()
412 if (Expected<StringRef> NameOrErr = SI->getName()) in printRelocationTargetName()
426 MachO::any_relocation_info RE = Obj->getRelocation(Rel); in getMachORelocationValueString()
428 unsigned Arch = Obj->getArch(); in getMachORelocationValueString()
432 unsigned Type = Obj->getAnyRelocationType(RE); in getMachORelocationValueString()
433 bool IsPCRel = Obj->getAnyRelocationPCRel(RE); in getMachORelocationValueString()
436 // These require decoding the relocation type, which is triple-specific. in getMachORelocationValueString()
451 Obj->moveRelocationNext(RelNext); in getMachORelocationValueString()
452 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext); in getMachORelocationValueString()
457 unsigned RType = Obj->getAnyRelocationType(RENext); in getMachORelocationValueString()
459 reportError(Obj->getFileName(), "Expected X86_64_RELOC_UNSIGNED after " in getMachORelocationValueString()
465 Fmt << "-"; in getMachORelocationValueString()
471 Fmt << "@TLV"; in getMachORelocationValueString()
477 Fmt << "-1"; in getMachORelocationValueString()
481 Fmt << "-2"; in getMachORelocationValueString()
485 Fmt << "-4"; in getMachORelocationValueString()
500 Obj->moveRelocationNext(RelNext); in getMachORelocationValueString()
501 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext); in getMachORelocationValueString()
505 unsigned RType = Obj->getAnyRelocationType(RENext); in getMachORelocationValueString()
508 reportError(Obj->getFileName(), "Expected GENERIC_RELOC_PAIR after " in getMachORelocationValueString()
512 Fmt << "-"; in getMachORelocationValueString()
522 Obj->moveRelocationNext(RelNext); in getMachORelocationValueString()
523 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext); in getMachORelocationValueString()
527 unsigned RType = Obj->getAnyRelocationType(RENext); in getMachORelocationValueString()
529 reportError(Obj->getFileName(), "Expected GENERIC_RELOC_PAIR after " in getMachORelocationValueString()
533 Fmt << "-"; in getMachORelocationValueString()
539 Fmt << "@TLV"; in getMachORelocationValueString()
547 } else { // ARM-specific relocations in getMachORelocationValueString()
553 bool isUpper = (Obj->getAnyRelocationLength(RE) & 0x1) == 1; in getMachORelocationValueString()
562 Obj->moveRelocationNext(RelNext); in getMachORelocationValueString()
563 MachO::any_relocation_info RENext = Obj->getRelocation(RelNext); in getMachORelocationValueString()
567 unsigned RType = Obj->getAnyRelocationType(RENext); in getMachORelocationValueString()
569 reportError(Obj->getFileName(), "Expected ARM_RELOC_PAIR after " in getMachORelocationValueString()
578 // symbol/section pointer of the follow-on relocation. in getMachORelocationValueString()
580 Fmt << "-"; in getMachORelocationValueString()
603 MachO::dysymtab_command Dysymtab = O->getDysymtabLoadCommand(); in PrintIndirectSymbolTable()
612 uint32_t cputype = O->getHeader().cputype; in PrintIndirectSymbolTable()
626 MachO::dysymtab_command Dysymtab = O->getDysymtabLoadCommand(); in PrintIndirectSymbolTable()
627 uint32_t indirect_symbol = O->getIndirectSymbolTableEntry(Dysymtab, n + j); in PrintIndirectSymbolTable()
643 MachO::symtab_command Symtab = O->getSymtabLoadCommand(); in PrintIndirectSymbolTable()
645 symbol_iterator Sym = O->getSymbolByIndex(indirect_symbol); in PrintIndirectSymbolTable()
647 outs() << unwrapOrError(Symbol.getName(), O->getFileName()); in PrintIndirectSymbolTable()
657 for (const auto &Load : O->load_commands()) { in PrintIndirectSymbols()
659 MachO::segment_command_64 Seg = O->getSegment64LoadCommand(Load); in PrintIndirectSymbols()
661 MachO::section_64 Sec = O->getSection64(Load, J); in PrintIndirectSymbols()
687 MachO::segment_command Seg = O->getSegmentLoadCommand(Load); in PrintIndirectSymbols()
689 MachO::section Sec = O->getSection(Load, J); in PrintIndirectSymbols()
720 "VANILLA ", "PAIR ", "SECTDIF ", "PBLAPTR ", "LOCSDIF ", "TLV ", in PrintRType()
726 "SIGNED1 ", "SIGNED2 ", "SIGNED4 ", "TLV ", " 10 (?) ", " 11 (?) ", in PrintRType()
741 outs() << format("%-7u", r_type) << " "; in PrintRType()
759 outs() << format("%-7u ", r_type); in PrintRType()
804 const MachO::symtab_command Symtab = O->getSymtabLoadCommand(); in PrintRelocationEntries()
810 const DataRefImpl Rel = Reloc->getRawDataRefImpl(); in PrintRelocationEntries()
811 const MachO::any_relocation_info RE = O->getRelocation(Rel); in PrintRelocationEntries()
812 const unsigned r_type = O->getAnyRelocationType(RE); in PrintRelocationEntries()
813 const bool r_scattered = O->isRelocationScattered(RE); in PrintRelocationEntries()
814 const unsigned r_pcrel = O->getAnyRelocationPCRel(RE); in PrintRelocationEntries()
815 const unsigned r_length = O->getAnyRelocationLength(RE); in PrintRelocationEntries()
816 const unsigned r_address = O->getAnyRelocationAddress(RE); in PrintRelocationEntries()
818 O->getPlainRelocationExternal(RE)); in PrintRelocationEntries()
820 O->getScatteredRelocationValue(RE) : 0); in PrintRelocationEntries()
822 O->getPlainRelocationSymbolNum(RE)); in PrintRelocationEntries()
879 outs() << format("%08x %1d %-2d n/a %-7d 1 0x%08x\n", in PrintRelocationEntries()
911 SymbolRef Symbol = *O->getSymbolByIndex(r_symbolnum); in PrintRelocationEntries()
915 name = SymNameNext->data(); in PrintRelocationEntries()
940 // in this case, r_symbolnum is actually a 1-based section number in PrintRelocationEntries()
941 uint32_t nsects = O->section_end()->getRawDataRefImpl().d.a; in PrintRelocationEntries()
944 DRI.d.a = r_symbolnum-1; in PrintRelocationEntries()
945 StringRef SegName = O->getSectionFinalSegmentName(DRI); in PrintRelocationEntries()
946 if (Expected<StringRef> NameOrErr = O->getSectionName(DRI)) in PrintRelocationEntries()
966 outs() << format("%08x %1d %-2d %1d %-7d 0 %d\n", in PrintRelocationEntries()
975 const uint64_t cputype = O->getHeader().cputype; in PrintRelocations()
976 const MachO::dysymtab_command Dysymtab = O->getDysymtabLoadCommand(); in PrintRelocations()
982 PrintRelocationEntries(O, O->extrel_begin(), O->extrel_end(), cputype, in PrintRelocations()
990 PrintRelocationEntries(O, O->locrel_begin(), O->locrel_end(), cputype, in PrintRelocations()
993 for (const auto &Load : O->load_commands()) { in PrintRelocations()
995 const MachO::segment_command_64 Seg = O->getSegment64LoadCommand(Load); in PrintRelocations()
997 const MachO::section_64 Sec = O->getSection64(Load, J); in PrintRelocations()
1001 const StringRef SegName = O->getSectionFinalSegmentName(DRI); in PrintRelocations()
1002 if (Expected<StringRef> NameOrErr = O->getSectionName(DRI)) in PrintRelocations()
1010 PrintRelocationEntries(O, O->section_rel_begin(DRI), in PrintRelocations()
1011 O->section_rel_end(DRI), cputype, verbose); in PrintRelocations()
1015 const MachO::segment_command Seg = O->getSegmentLoadCommand(Load); in PrintRelocations()
1017 const MachO::section Sec = O->getSection(Load, J); in PrintRelocations()
1021 const StringRef SegName = O->getSectionFinalSegmentName(DRI); in PrintRelocations()
1022 if (Expected<StringRef> NameOrErr = O->getSectionName(DRI)) in PrintRelocations()
1030 PrintRelocationEntries(O, O->section_rel_begin(DRI), in PrintRelocations()
1031 O->section_rel_end(DRI), cputype, verbose); in PrintRelocations()
1040 for (const MachOObjectFile::LoadCommandInfo &Command : O->load_commands()) { in PrintFunctionStarts()
1042 MachO::segment_command SLC = O->getSegmentLoadCommand(Command); in PrintFunctionStarts()
1048 MachO::segment_command_64 SLC = O->getSegment64LoadCommand(Command); in PrintFunctionStarts()
1057 for (const MachOObjectFile::LoadCommandInfo &LC : O->load_commands()) { in PrintFunctionStarts()
1060 O->getLinkeditDataLoadCommand(LC); in PrintFunctionStarts()
1061 O->ReadULEB128s(FunctionStartsLC.dataoff, FunctionStarts); in PrintFunctionStarts()
1069 for (SymbolRef Sym : O->symbols()) { in PrintFunctionStarts()
1083 outs() << It->second << "\n"; in PrintFunctionStarts()
1085 if (O->is64Bit()) in PrintFunctionStarts()
1093 outs() << " " << It->second; in PrintFunctionStarts()
1103 MachO::linkedit_data_command DIC = O->getDataInCodeLoadCommand(); in PrintDataInCodeTable()
1107 for (dice_iterator DI = O->begin_dices(), DE = O->end_dices(); DI != DE; in PrintDataInCodeTable()
1110 DI->getOffset(Offset); in PrintDataInCodeTable()
1113 DI->getLength(Length); in PrintDataInCodeTable()
1116 DI->getKind(Kind); in PrintDataInCodeTable()
1145 MachO::linkedit_data_command LohLC = O->getLinkOptHintsLoadCommand(); in PrintLinkOptHints()
1146 const char *loh = O->getData().substr(LohLC.dataoff, 1).data(); in PrintLinkOptHints()
1203 for (const MachOObjectFile::LoadCommandInfo &Command : O->load_commands()) { in GetSegmentNames()
1205 MachO::segment_command SLC = O->getSegmentLoadCommand(Command); in GetSegmentNames()
1208 MachO::segment_command_64 SLC = O->getSegment64LoadCommand(Command); in GetSegmentNames()
1268 if ((Segment.Header.pointer_format - 1) < in PrintChainedFixupsSegment()
1270 outs() << " (" << PointerFormats[Segment.Header.pointer_format - 1] << ")"; in PrintChainedFixupsSegment()
1280 // FIXME: Support DYLD_CHAINED_PTR_START_MULTI (32-bit only) in PrintChainedFixupsSegment()
1311 unwrapOrError(O->getChainedFixupsHeader(), O->getFileName()); in PrintChainedFixups()
1318 unwrapOrError(O->getChainedFixupsSegments(), O->getFileName()); in PrintChainedFixups()
1340 unwrapOrError(O->getDyldChainedFixupTargets(), O->getFileName()); in PrintChainedFixups()
1342 uint32_t ImportsFormat = ChainedFixupHeader->imports_format; in PrintChainedFixups()
1355 const size_t PointerWidth = 2 + O->getBytesInAddress() * 2; in PrintDyldInfo()
1360 for (const object::MachOChainedFixupEntry &Entry : O->fixupTable(Err)) { in PrintDyldInfo()
1380 for (const object::MachOChainedFixupEntry &Entry : O->fixupTable(Err)) { in PrintDyldInfo()
1383 << left_justify(utohexstr(Entry.address()), AddressWidth - 2) << ' ' in PrintDyldInfo()
1387 << "0x" << left_justify(utohexstr(Entry.addend()), AddendWidth - 2) in PrintDyldInfo()
1401 reportError(std::move(Err), O->getFileName()); in PrintDyldInfo()
1403 // TODO: Print opcode-based fixups if the object uses those. in PrintDyldInfo()
1408 for (const auto &Load : O->load_commands()) { in PrintDylibs()
1416 MachO::dylib_command dl = O->getDylibIDLoadCommand(Load); in PrintDylibs()
1464 for (const auto &Command : O->load_commands()) { in printRpaths()
1466 auto Rpath = O->getRpathCommand(Command); in printRpaths()
1478 const StringRef FileName = O->getFileName(); in CreateSymbolAddressMap()
1479 for (const SymbolRef &Symbol : O->symbols()) { in CreateSymbolAddressMap()
1498 StringRef name = AddrMap->lookup(value); in GuessSymbolName()
1517 if (O->is64Bit()) in DumpCstringSection()
1537 outs() << " (-Infinity)\n"; in DumpLiteral4()
1539 outs() << " (non-signaling Not-a-Number)\n"; in DumpLiteral4()
1541 outs() << " (signaling Not-a-Number)\n"; in DumpLiteral4()
1550 if (O->is64Bit()) in DumpLiteral4Section()
1557 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpLiteral4Section()
1561 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpLiteral4Section()
1571 Hi = (O->isLittleEndian()) ? l1 : l0; in DumpLiteral8()
1572 Lo = (O->isLittleEndian()) ? l0 : l1; in DumpLiteral8()
1581 outs() << " (-Infinity)\n"; in DumpLiteral8()
1583 outs() << " (non-signaling Not-a-Number)\n"; in DumpLiteral8()
1585 outs() << " (signaling Not-a-Number)\n"; in DumpLiteral8()
1594 if (O->is64Bit()) in DumpLiteral8Section()
1601 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpLiteral8Section()
1606 if (O->isLittleEndian() != sys::IsLittleEndianHost) { in DumpLiteral8Section()
1626 if (O->is64Bit()) in DumpLiteral16Section()
1636 if (O->isLittleEndian() != sys::IsLittleEndianHost) { in DumpLiteral16Section()
1651 // Collect the literal sections in this Mach-O file. in DumpLiteralPointerSection()
1653 for (const SectionRef &Section : O->sections()) { in DumpLiteralPointerSection()
1656 if (O->is64Bit()) { in DumpLiteralPointerSection()
1657 const MachO::section_64 Sec = O->getSection64(Ref); in DumpLiteralPointerSection()
1660 const MachO::section Sec = O->getSection(Ref); in DumpLiteralPointerSection()
1671 uint32_t lp_size = O->is64Bit() ? 8 : 4; in DumpLiteralPointerSection()
1680 RE = O->getRelocation(Rel); in DumpLiteralPointerSection()
1681 isExtern = O->getPlainRelocationExternal(RE); in DumpLiteralPointerSection()
1693 if (O->is64Bit()) in DumpLiteralPointerSection()
1699 if (O->is64Bit()) { in DumpLiteralPointerSection()
1701 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpLiteralPointerSection()
1706 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpLiteralPointerSection()
1716 symbol_iterator RelocSym = Reloc->second; in DumpLiteralPointerSection()
1717 StringRef SymName = unwrapOrError(RelocSym->getName(), O->getFileName()); in DumpLiteralPointerSection()
1731 uint64_t SectAddress = Sect->getAddress(); in DumpLiteralPointerSection()
1732 uint64_t SectSize = Sect->getSize(); in DumpLiteralPointerSection()
1735 Expected<StringRef> SectNameOrErr = Sect->getName(); in DumpLiteralPointerSection()
1741 DataRefImpl Ref = Sect->getRawDataRefImpl(); in DumpLiteralPointerSection()
1742 StringRef SegmentName = O->getSectionFinalSegmentName(Ref); in DumpLiteralPointerSection()
1746 if (O->is64Bit()) { in DumpLiteralPointerSection()
1747 const MachO::section_64 Sec = O->getSection64(Ref); in DumpLiteralPointerSection()
1750 const MachO::section Sec = O->getSection(Ref); in DumpLiteralPointerSection()
1754 StringRef BytesStr = unwrapOrError(Sect->getContents(), O->getFileName()); in DumpLiteralPointerSection()
1760 for (uint64_t i = lp - SectAddress; i < SectSize && Contents[i] != '\0'; in DumpLiteralPointerSection()
1768 memcpy(&f, Contents + (lp - SectAddress), sizeof(float)); in DumpLiteralPointerSection()
1770 memcpy(&l, Contents + (lp - SectAddress), sizeof(uint32_t)); in DumpLiteralPointerSection()
1771 if (O->isLittleEndian() != sys::IsLittleEndianHost) { in DumpLiteralPointerSection()
1779 memcpy(&d, Contents + (lp - SectAddress), sizeof(double)); in DumpLiteralPointerSection()
1781 memcpy(&l0, Contents + (lp - SectAddress), sizeof(uint32_t)); in DumpLiteralPointerSection()
1782 memcpy(&l1, Contents + (lp - SectAddress) + sizeof(uint32_t), in DumpLiteralPointerSection()
1784 if (O->isLittleEndian() != sys::IsLittleEndianHost) { in DumpLiteralPointerSection()
1794 memcpy(&l0, Contents + (lp - SectAddress), sizeof(uint32_t)); in DumpLiteralPointerSection()
1795 memcpy(&l1, Contents + (lp - SectAddress) + sizeof(uint32_t), in DumpLiteralPointerSection()
1797 memcpy(&l2, Contents + (lp - SectAddress) + 2 * sizeof(uint32_t), in DumpLiteralPointerSection()
1799 memcpy(&l3, Contents + (lp - SectAddress) + 3 * sizeof(uint32_t), in DumpLiteralPointerSection()
1801 if (O->isLittleEndian() != sys::IsLittleEndianHost) { in DumpLiteralPointerSection()
1821 stride = (O->is64Bit()) ? sizeof(uint64_t) : sizeof(uint32_t); in DumpInitTermPointerSection()
1830 RE = O->getRelocation(Rel); in DumpInitTermPointerSection()
1831 isExtern = O->getPlainRelocationExternal(RE); in DumpInitTermPointerSection()
1843 if (O->is64Bit()) { in DumpInitTermPointerSection()
1847 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpInitTermPointerSection()
1855 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpInitTermPointerSection()
1866 symbol_iterator RelocSym = Reloc->second; in DumpInitTermPointerSection()
1867 outs() << " " << unwrapOrError(RelocSym->getName(), O->getFileName()); in DumpInitTermPointerSection()
1880 uint32_t cputype = O->getHeader().cputype; in DumpRawSectionContents()
1884 if (O->is64Bit()) in DumpRawSectionContents()
1897 if (O->is64Bit()) in DumpRawSectionContents()
1906 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpRawSectionContents()
1943 for (const SectionRef &Section : O->sections()) { in DumpSectionContents()
1955 StringRef SegName = O->getSectionFinalSegmentName(Ref); in DumpSectionContents()
1960 if (O->is64Bit()) { in DumpSectionContents()
1961 const MachO::section_64 Sec = O->getSection64(Ref); in DumpSectionContents()
1965 const MachO::section Sec = O->getSection(Ref); in DumpSectionContents()
1971 unwrapOrError(Section.getContents(), O->getFileName()); in DumpSectionContents()
2041 for (const SectionRef &Section : O->sections()) { in DumpInfoPlistSectionContents()
2050 StringRef SegName = O->getSectionFinalSegmentName(Ref); in DumpInfoPlistSectionContents()
2055 unwrapOrError(Section.getContents(), O->getFileName()); in DumpInfoPlistSectionContents()
2063 // checkMachOAndArchFlags() checks to see if the ObjectFile is a Mach-O file
2065 // check to make sure this Mach-O file is one of those architectures or all
2078 if (MachO->is64Bit()) { in checkMachOAndArchFlags()
2079 H_64 = MachO->MachOObjectFile::getHeader64(); in checkMachOAndArchFlags()
2083 H = MachO->MachOObjectFile::getHeader(); in checkMachOAndArchFlags()
2089 WithColor::error(errs(), "llvm-objdump") in checkMachOAndArchFlags()
2098 // ProcessMachO() is passed a single opened Mach-O file, which may be an
2107 // If we are doing some processing here on the Mach-O file print the header in ProcessMachO()
2137 // produce a good error message as to where the Mach-O file comes from in in ProcessMachO()
2140 if (Error Err = MachOOF->checkSymbolTable()) in ProcessMachO()
2144 for (const SectionRef &Section : MachOOF->sections()) { in ProcessMachO()
2153 StringRef SegName = MachOOF->getSectionFinalSegmentName(Ref); in ProcessMachO()
2159 if (MachOOF->getHeader().filetype == MachO::MH_KEXT_BUNDLE && in ProcessMachO()
2160 MachOOF->getHeader().cputype == MachO::CPU_TYPE_ARM64) in ProcessMachO()
2192 D->printSymbolTable(ArchiveName, ArchitectureName); in ProcessMachO()
2221 DICtx->dump(outs(), DumpOpts); in ProcessMachO()
2352 if (UB->getMagic() == MachO::FAT_MAGIC) in printMachOUniversalHeaders()
2354 else // UB->getMagic() == MachO::FAT_MAGIC_64 in printMachOUniversalHeaders()
2359 uint32_t nfat_arch = UB->getNumberOfObjects(); in printMachOUniversalHeaders()
2360 StringRef Buf = UB->getData(); in printMachOUniversalHeaders()
2364 outs() << "nfat_arch " << UB->getNumberOfObjects(); in printMachOUniversalHeaders()
2377 for (uint32_t j = 0; i != 0 && j <= i - 1; j++) { in printMachOUniversalHeaders()
2430 // FIXME: this first dash, "-", is for (Mode & S_IFMT) == S_IFREG. in printArchiveChild()
2432 outs() << "-"; in printArchiveChild()
2433 outs() << ((Mode & sys::fs::owner_read) ? "r" : "-"); in printArchiveChild()
2434 outs() << ((Mode & sys::fs::owner_write) ? "w" : "-"); in printArchiveChild()
2435 outs() << ((Mode & sys::fs::owner_exe) ? "x" : "-"); in printArchiveChild()
2436 outs() << ((Mode & sys::fs::group_read) ? "r" : "-"); in printArchiveChild()
2437 outs() << ((Mode & sys::fs::group_write) ? "w" : "-"); in printArchiveChild()
2438 outs() << ((Mode & sys::fs::group_exe) ? "x" : "-"); in printArchiveChild()
2439 outs() << ((Mode & sys::fs::others_read) ? "r" : "-"); in printArchiveChild()
2440 outs() << ((Mode & sys::fs::others_write) ? "w" : "-"); in printArchiveChild()
2441 outs() << ((Mode & sys::fs::others_exe) ? "x" : "-"); in printArchiveChild()
2446 outs() << format("%3d/%-3d %5" PRId64 " ", in printArchiveChild()
2460 << "\" contains non-decimal chars) "; in printArchiveChild()
2496 for (const auto &C : A->children(Err, false)) in printArchiveHeaders()
2505 // Check for -arch all and verifiy the -arch flags are valid. in ValidateArchFlags()
2511 WithColor::error(errs(), "llvm-objdump") in ValidateArchFlags()
2513 "'for the -arch option\n"; in ValidateArchFlags()
2521 // ParseInputMachO() parses the named Mach-O file in Filename and handles the
2522 // -arch flags selecting just those slices as specified by them and also parses
2523 // archive files. Then for each individual Mach-O file ProcessMachO() is
2546 unsigned I = -1; in parseInputMachO()
2547 for (auto &C : A->children(Err)) { in parseInputMachO()
2558 ProcessMachO(Filename, O, O->getFileName()); in parseInputMachO()
2575 WithColor::error(errs(), "llvm-objdump") in parseInputMachO()
2577 << "object is not a Mach-O file type.\n"; in parseInputMachO()
2587 auto Filename = UB->getFileName(); in parseInputMachO()
2598 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), in parseInputMachO()
2599 E = UB->end_objects(); in parseInputMachO()
2601 if (ArchFlags[i] == I->getArchFlagName()) { in parseInputMachO()
2604 I->getAsObjectFile(); in parseInputMachO()
2607 ArchitectureName = I->getArchFlagName(); in parseInputMachO()
2617 I->getAsArchive()) { in parseInputMachO()
2627 unsigned I = -1; in parseInputMachO()
2628 for (auto &C : A->children(Err)) { in parseInputMachO()
2640 ProcessMachO(Filename, O, O->getFileName(), ArchitectureName); in parseInputMachO()
2647 "Mach-O universal file for architecture " + in parseInputMachO()
2648 StringRef(I->getArchFlagName()) + in parseInputMachO()
2649 " is not a Mach-O file or an archive file"); in parseInputMachO()
2654 WithColor::error(errs(), "llvm-objdump") in parseInputMachO()
2665 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), in parseInputMachO()
2666 E = UB->end_objects(); in parseInputMachO()
2669 I->getArchFlagName()) { in parseInputMachO()
2670 Expected<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile(); in parseInputMachO()
2681 I->getAsArchive()) { in parseInputMachO()
2688 unsigned I = -1; in parseInputMachO()
2689 for (auto &C : A->children(Err)) { in parseInputMachO()
2700 ProcessMachO(Filename, O, O->getFileName()); in parseInputMachO()
2706 reportError(Filename, "Mach-O universal file for architecture " + in parseInputMachO()
2707 StringRef(I->getArchFlagName()) + in parseInputMachO()
2708 " is not a Mach-O file or an archive file"); in parseInputMachO()
2716 bool moreThanOneArch = UB->getNumberOfObjects() > 1; in parseInputMachO()
2717 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), in parseInputMachO()
2718 E = UB->end_objects(); in parseInputMachO()
2720 Expected<std::unique_ptr<ObjectFile>> ObjOrErr = I->getAsObjectFile(); in parseInputMachO()
2723 ArchitectureName = I->getArchFlagName(); in parseInputMachO()
2731 } else if (Expected<std::unique_ptr<Archive>> AOrErr = I->getAsArchive()) { in parseInputMachO()
2741 unsigned I = -1; in parseInputMachO()
2742 for (auto &C : A->children(Err)) { in parseInputMachO()
2754 ProcessMachO(Filename, MachOOF, MachOOF->getFileName(), in parseInputMachO()
2762 reportError(Filename, "Mach-O universal file for architecture " + in parseInputMachO()
2763 StringRef(I->getArchFlagName()) + in parseInputMachO()
2764 " is not a Mach-O file or an archive file"); in parseInputMachO()
2800 // op_info->Value and is at Offset past the start of the instruction and has a
2802 // LLVMOpInfo1 struct defined in the header "llvm-c/Disassembler.h" as symbol
2811 uint64_t value = op_info->Value; in SymbolizerGetOpInfo()
2815 op_info->Value = value; in SymbolizerGetOpInfo()
2820 if (TagType != 1 || !info->verbose) in SymbolizerGetOpInfo()
2823 unsigned int Arch = info->O->getArch(); in SymbolizerGetOpInfo()
2827 if (info->O->getHeader().filetype != MachO::MH_OBJECT) { in SymbolizerGetOpInfo()
2836 uint32_t sect_addr = info->S.getAddress(); in SymbolizerGetOpInfo()
2837 uint32_t sect_offset = (Pc + Offset) - sect_addr; in SymbolizerGetOpInfo()
2845 for (const RelocationRef &Reloc : info->S.relocations()) { in SymbolizerGetOpInfo()
2849 RE = info->O->getRelocation(Rel); in SymbolizerGetOpInfo()
2850 r_type = info->O->getAnyRelocationType(RE); in SymbolizerGetOpInfo()
2851 r_scattered = info->O->isRelocationScattered(RE); in SymbolizerGetOpInfo()
2853 r_value = info->O->getScatteredRelocationValue(RE); in SymbolizerGetOpInfo()
2857 info->O->moveRelocationNext(RelNext); in SymbolizerGetOpInfo()
2859 RENext = info->O->getRelocation(RelNext); in SymbolizerGetOpInfo()
2860 if (info->O->isRelocationScattered(RENext)) in SymbolizerGetOpInfo()
2861 pair_r_value = info->O->getScatteredRelocationValue(RENext); in SymbolizerGetOpInfo()
2866 isExtern = info->O->getPlainRelocationExternal(RE); in SymbolizerGetOpInfo()
2877 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
2878 op_info->AddSymbol.Name = in SymbolizerGetOpInfo()
2879 unwrapOrError(Symbol.getName(), info->O->getFileName()).data(); in SymbolizerGetOpInfo()
2881 // the offset from the symbol, and value is already set in op_info->Value. in SymbolizerGetOpInfo()
2886 const char *add = GuessSymbolName(r_value, info->AddrMap); in SymbolizerGetOpInfo()
2887 const char *sub = GuessSymbolName(pair_r_value, info->AddrMap); in SymbolizerGetOpInfo()
2888 uint32_t offset = value - (r_value - pair_r_value); in SymbolizerGetOpInfo()
2889 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
2891 op_info->AddSymbol.Name = add; in SymbolizerGetOpInfo()
2893 op_info->AddSymbol.Value = r_value; in SymbolizerGetOpInfo()
2894 op_info->SubtractSymbol.Present = 1; in SymbolizerGetOpInfo()
2896 op_info->SubtractSymbol.Name = sub; in SymbolizerGetOpInfo()
2898 op_info->SubtractSymbol.Value = pair_r_value; in SymbolizerGetOpInfo()
2899 op_info->Value = offset; in SymbolizerGetOpInfo()
2910 if (info->O->getHeader().filetype != MachO::MH_OBJECT) { in SymbolizerGetOpInfo()
2917 for (const RelocationRef &Reloc : info->O->external_relocations()) { in SymbolizerGetOpInfo()
2921 RE = info->O->getRelocation(Rel); in SymbolizerGetOpInfo()
2923 isExtern = info->O->getPlainRelocationExternal(RE); in SymbolizerGetOpInfo()
2936 if (info->O->getAnyRelocationPCRel(RE)) in SymbolizerGetOpInfo()
2937 op_info->Value -= Pc + InstSize; in SymbolizerGetOpInfo()
2939 unwrapOrError(Symbol.getName(), info->O->getFileName()).data(); in SymbolizerGetOpInfo()
2940 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
2941 op_info->AddSymbol.Name = name; in SymbolizerGetOpInfo()
2948 uint64_t sect_addr = info->S.getAddress(); in SymbolizerGetOpInfo()
2949 uint64_t sect_offset = (Pc + Offset) - sect_addr; in SymbolizerGetOpInfo()
2955 for (const RelocationRef &Reloc : info->S.relocations()) { in SymbolizerGetOpInfo()
2959 RE = info->O->getRelocation(Rel); in SymbolizerGetOpInfo()
2961 isExtern = info->O->getPlainRelocationExternal(RE); in SymbolizerGetOpInfo()
2974 if (info->O->getAnyRelocationPCRel(RE)) in SymbolizerGetOpInfo()
2975 op_info->Value -= Pc + InstSize; in SymbolizerGetOpInfo()
2977 unwrapOrError(Symbol.getName(), info->O->getFileName()).data(); in SymbolizerGetOpInfo()
2978 unsigned Type = info->O->getAnyRelocationType(RE); in SymbolizerGetOpInfo()
2981 info->O->moveRelocationNext(RelNext); in SymbolizerGetOpInfo()
2982 MachO::any_relocation_info RENext = info->O->getRelocation(RelNext); in SymbolizerGetOpInfo()
2983 unsigned TypeNext = info->O->getAnyRelocationType(RENext); in SymbolizerGetOpInfo()
2984 bool isExternNext = info->O->getPlainRelocationExternal(RENext); in SymbolizerGetOpInfo()
2985 unsigned SymbolNum = info->O->getPlainRelocationSymbolNum(RENext); in SymbolizerGetOpInfo()
2987 op_info->SubtractSymbol.Present = 1; in SymbolizerGetOpInfo()
2988 op_info->SubtractSymbol.Name = name; in SymbolizerGetOpInfo()
2989 symbol_iterator RelocSymNext = info->O->getSymbolByIndex(SymbolNum); in SymbolizerGetOpInfo()
2991 name = unwrapOrError(Symbol.getName(), info->O->getFileName()).data(); in SymbolizerGetOpInfo()
2994 // TODO: add the VariantKinds to op_info->VariantKind for relocation types in SymbolizerGetOpInfo()
2996 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
2997 op_info->AddSymbol.Name = name; in SymbolizerGetOpInfo()
3005 if (info->O->getHeader().filetype != MachO::MH_OBJECT) { in SymbolizerGetOpInfo()
3014 uint32_t sect_addr = info->S.getAddress(); in SymbolizerGetOpInfo()
3015 uint32_t sect_offset = (Pc + Offset) - sect_addr; in SymbolizerGetOpInfo()
3023 find_if(info->S.relocations(), [&](const RelocationRef &Reloc) { in SymbolizerGetOpInfo()
3028 if (Reloc == info->S.relocations().end()) in SymbolizerGetOpInfo()
3031 Rel = Reloc->getRawDataRefImpl(); in SymbolizerGetOpInfo()
3032 RE = info->O->getRelocation(Rel); in SymbolizerGetOpInfo()
3033 r_length = info->O->getAnyRelocationLength(RE); in SymbolizerGetOpInfo()
3034 r_scattered = info->O->isRelocationScattered(RE); in SymbolizerGetOpInfo()
3036 r_value = info->O->getScatteredRelocationValue(RE); in SymbolizerGetOpInfo()
3037 r_type = info->O->getScatteredRelocationType(RE); in SymbolizerGetOpInfo()
3039 r_type = info->O->getAnyRelocationType(RE); in SymbolizerGetOpInfo()
3040 isExtern = info->O->getPlainRelocationExternal(RE); in SymbolizerGetOpInfo()
3042 symbol_iterator RelocSym = Reloc->getSymbol(); in SymbolizerGetOpInfo()
3051 info->O->moveRelocationNext(RelNext); in SymbolizerGetOpInfo()
3053 RENext = info->O->getRelocation(RelNext); in SymbolizerGetOpInfo()
3054 other_half = info->O->getAnyRelocationAddress(RENext) & 0xffff; in SymbolizerGetOpInfo()
3055 if (info->O->isRelocationScattered(RENext)) in SymbolizerGetOpInfo()
3056 pair_r_value = info->O->getScatteredRelocationValue(RENext); in SymbolizerGetOpInfo()
3061 unwrapOrError(Symbol.getName(), info->O->getFileName()).data(); in SymbolizerGetOpInfo()
3062 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
3063 op_info->AddSymbol.Name = name; in SymbolizerGetOpInfo()
3067 op_info->Value = value << 16 | other_half; in SymbolizerGetOpInfo()
3068 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16; in SymbolizerGetOpInfo()
3070 op_info->Value = other_half << 16 | value; in SymbolizerGetOpInfo()
3071 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_LO16; in SymbolizerGetOpInfo()
3097 offset = value - r_value; in SymbolizerGetOpInfo()
3103 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16; in SymbolizerGetOpInfo()
3105 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_LO16; in SymbolizerGetOpInfo()
3106 const char *add = GuessSymbolName(r_value, info->AddrMap); in SymbolizerGetOpInfo()
3107 const char *sub = GuessSymbolName(pair_r_value, info->AddrMap); in SymbolizerGetOpInfo()
3108 int32_t offset = value - (r_value - pair_r_value); in SymbolizerGetOpInfo()
3109 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
3111 op_info->AddSymbol.Name = add; in SymbolizerGetOpInfo()
3113 op_info->AddSymbol.Value = r_value; in SymbolizerGetOpInfo()
3114 op_info->SubtractSymbol.Present = 1; in SymbolizerGetOpInfo()
3116 op_info->SubtractSymbol.Name = sub; in SymbolizerGetOpInfo()
3118 op_info->SubtractSymbol.Value = pair_r_value; in SymbolizerGetOpInfo()
3119 op_info->Value = offset; in SymbolizerGetOpInfo()
3123 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
3124 op_info->Value = offset; in SymbolizerGetOpInfo()
3127 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16; in SymbolizerGetOpInfo()
3129 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_LO16; in SymbolizerGetOpInfo()
3131 const char *add = GuessSymbolName(value, info->AddrMap); in SymbolizerGetOpInfo()
3133 op_info->AddSymbol.Name = add; in SymbolizerGetOpInfo()
3136 op_info->AddSymbol.Value = value; in SymbolizerGetOpInfo()
3142 if (info->O->getHeader().filetype != MachO::MH_OBJECT) { in SymbolizerGetOpInfo()
3151 uint64_t sect_addr = info->S.getAddress(); in SymbolizerGetOpInfo()
3152 uint64_t sect_offset = (Pc + Offset) - sect_addr; in SymbolizerGetOpInfo()
3154 find_if(info->S.relocations(), [&](const RelocationRef &Reloc) { in SymbolizerGetOpInfo()
3159 if (Reloc == info->S.relocations().end()) in SymbolizerGetOpInfo()
3162 DataRefImpl Rel = Reloc->getRawDataRefImpl(); in SymbolizerGetOpInfo()
3163 MachO::any_relocation_info RE = info->O->getRelocation(Rel); in SymbolizerGetOpInfo()
3164 uint32_t r_type = info->O->getAnyRelocationType(RE); in SymbolizerGetOpInfo()
3167 info->O->moveRelocationNext(RelNext); in SymbolizerGetOpInfo()
3168 MachO::any_relocation_info RENext = info->O->getRelocation(RelNext); in SymbolizerGetOpInfo()
3170 value = info->O->getPlainRelocationSymbolNum(RENext); in SymbolizerGetOpInfo()
3171 op_info->Value = value; in SymbolizerGetOpInfo()
3175 if (!info->O->getPlainRelocationExternal(RE)) in SymbolizerGetOpInfo()
3178 unwrapOrError(Reloc->getSymbol()->getName(), info->O->getFileName()) in SymbolizerGetOpInfo()
3180 op_info->AddSymbol.Present = 1; in SymbolizerGetOpInfo()
3181 op_info->AddSymbol.Name = name; in SymbolizerGetOpInfo()
3186 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_PAGE; in SymbolizerGetOpInfo()
3190 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_PAGEOFF; in SymbolizerGetOpInfo()
3194 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_GOTPAGE; in SymbolizerGetOpInfo()
3198 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF; in SymbolizerGetOpInfo()
3201 /* @tvlppage is not implemented in llvm-mc */ in SymbolizerGetOpInfo()
3202 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_TLVP; in SymbolizerGetOpInfo()
3205 /* @tvlppageoff is not implemented in llvm-mc */ in SymbolizerGetOpInfo()
3206 op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_TLVOFF; in SymbolizerGetOpInfo()
3210 op_info->VariantKind = LLVMDisassembler_VariantKind_None; in SymbolizerGetOpInfo()
3223 for (const auto &Load : info->O->load_commands()) { in GuessCstringPointer()
3225 MachO::segment_command_64 Seg = info->O->getSegment64LoadCommand(Load); in GuessCstringPointer()
3227 MachO::section_64 Sec = info->O->getSection64(Load, J); in GuessCstringPointer()
3232 uint64_t sect_offset = ReferenceValue - Sec.addr; in GuessCstringPointer()
3234 StringRef MachOContents = info->O->getData(); in GuessCstringPointer()
3246 MachO::segment_command Seg = info->O->getSegmentLoadCommand(Load); in GuessCstringPointer()
3248 MachO::section Sec = info->O->getSection(Load, J); in GuessCstringPointer()
3253 uint64_t sect_offset = ReferenceValue - Sec.addr; in GuessCstringPointer()
3255 StringRef MachOContents = info->O->getData(); in GuessCstringPointer()
3273 // an address of a symbol stub or a lazy or non-lazy pointer to associate the
3277 MachO::dysymtab_command Dysymtab = info->O->getDysymtabLoadCommand(); in GuessIndirectSymbol()
3278 MachO::symtab_command Symtab = info->O->getSymtabLoadCommand(); in GuessIndirectSymbol()
3279 for (const auto &Load : info->O->load_commands()) { in GuessIndirectSymbol()
3281 MachO::segment_command_64 Seg = info->O->getSegment64LoadCommand(Load); in GuessIndirectSymbol()
3283 MachO::section_64 Sec = info->O->getSection64(Load, J); in GuessIndirectSymbol()
3299 uint32_t index = Sec.reserved1 + (ReferenceValue - Sec.addr) / stride; in GuessIndirectSymbol()
3302 info->O->getIndirectSymbolTableEntry(Dysymtab, index); in GuessIndirectSymbol()
3304 symbol_iterator Sym = info->O->getSymbolByIndex(indirect_symbol); in GuessIndirectSymbol()
3305 return unwrapOrError(Sym->getName(), info->O->getFileName()) in GuessIndirectSymbol()
3312 MachO::segment_command Seg = info->O->getSegmentLoadCommand(Load); in GuessIndirectSymbol()
3314 MachO::section Sec = info->O->getSection(Load, J); in GuessIndirectSymbol()
3330 uint32_t index = Sec.reserved1 + (ReferenceValue - Sec.addr) / stride; in GuessIndirectSymbol()
3333 info->O->getIndirectSymbolTableEntry(Dysymtab, index); in GuessIndirectSymbol()
3335 symbol_iterator Sym = info->O->getSymbolByIndex(indirect_symbol); in GuessIndirectSymbol()
3336 return unwrapOrError(Sym->getName(), info->O->getFileName()) in GuessIndirectSymbol()
3348 // a reference it to an Objective-C method call. If so then it allocates and
3359 unsigned int Arch = info->O->getArch(); in method_reference()
3362 if (info->selector_name != nullptr) { in method_reference()
3363 if (info->class_name != nullptr) { in method_reference()
3364 info->method = std::make_unique<char[]>( in method_reference()
3365 5 + strlen(info->class_name) + strlen(info->selector_name)); in method_reference()
3366 char *method = info->method.get(); in method_reference()
3369 strcat(method, info->class_name); in method_reference()
3371 strcat(method, info->selector_name); in method_reference()
3377 info->method = in method_reference()
3378 std::make_unique<char[]>(9 + strlen(info->selector_name)); in method_reference()
3379 char *method = info->method.get(); in method_reference()
3382 strcpy(method, "-[%rdi "); in method_reference()
3384 strcpy(method, "-[x0 "); in method_reference()
3386 strcpy(method, "-[r? "); in method_reference()
3387 strcat(method, info->selector_name); in method_reference()
3393 info->class_name = nullptr; in method_reference()
3396 if (info->selector_name != nullptr) { in method_reference()
3397 info->method = in method_reference()
3398 std::make_unique<char[]>(17 + strlen(info->selector_name)); in method_reference()
3399 char *method = info->method.get(); in method_reference()
3402 strcpy(method, "-[[%rdi super] "); in method_reference()
3404 strcpy(method, "-[[x0 super] "); in method_reference()
3406 strcpy(method, "-[[r? super] "); in method_reference()
3407 strcat(method, info->selector_name); in method_reference()
3412 info->class_name = nullptr; in method_reference()
3419 // a reference to an Objective-C class, selector, message ref or cfstring.
3430 for (const auto &Load : info->O->load_commands()) { in GuessPointerPointer()
3432 MachO::segment_command_64 Seg = info->O->getSegment64LoadCommand(Load); in GuessPointerPointer()
3434 MachO::section_64 Sec = info->O->getSection64(Load, J); in GuessPointerPointer()
3442 uint64_t sect_offset = ReferenceValue - Sec.addr; in GuessPointerPointer()
3444 StringRef MachOContents = info->O->getData(); in GuessPointerPointer()
3451 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in GuessPointerPointer()
3463 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in GuessPointerPointer()
3474 // TODO: Look for LC_SEGMENT for 32-bit Mach-O files. in GuessPointerPointer()
3480 // Address from a section in the Mach-O file. And indirectly returns the
3491 for (unsigned SectIdx = 0; SectIdx != info->Sections->size(); SectIdx++) { in get_pointer_64()
3492 uint64_t SectAddress = ((*(info->Sections))[SectIdx]).getAddress(); in get_pointer_64()
3493 uint64_t SectSize = ((*(info->Sections))[SectIdx]).getSize(); in get_pointer_64()
3499 ((*(info->Sections))[SectIdx]).getName(); in get_pointer_64()
3505 DataRefImpl Ref = ((*(info->Sections))[SectIdx]).getRawDataRefImpl(); in get_pointer_64()
3506 StringRef SegName = info->O->getSectionFinalSegmentName(Ref); in get_pointer_64()
3511 S = (*(info->Sections))[SectIdx]; in get_pointer_64()
3512 offset = Address - SectAddress; in get_pointer_64()
3513 left = SectSize - offset; in get_pointer_64()
3515 ((*(info->Sections))[SectIdx]).getContents(), info->O->getFileName()); in get_pointer_64()
3532 // If no relocation information is found and a non-zero ReferenceValue for the
3538 if (!info->verbose) in get_symbol_64()
3551 RE = info->O->getRelocation(Rel); in get_symbol_64()
3552 if (info->O->isRelocationScattered(RE)) in get_symbol_64()
3554 isExtern = info->O->getPlainRelocationExternal(RE); in get_symbol_64()
3569 StringRef Name = unwrapOrError(Symbol.getName(), info->O->getFileName()); in get_symbol_64()
3578 // start of the first writeable segment in the Mach-O file. So the offset in get_symbol_64()
3587 SymbolName = GuessSymbolName(ReferenceValue, info->AddrMap); in get_symbol_64()
3601 // These are structs in the Objective-C meta data and read to produce the
3606 // The cfstring object in a 64-bit Mach-O file.
3608 uint64_t isa; // class64_t * (64-bit pointer)
3610 uint64_t characters; // char * (64-bit pointer)
3611 uint64_t length; // number of non-NULL characters in above
3614 // The class object in a 64-bit Mach-O file.
3616 uint64_t isa; // class64_t * (64-bit pointer)
3617 uint64_t superclass; // class64_t * (64-bit pointer)
3618 uint64_t cache; // Cache (64-bit pointer)
3619 uint64_t vtable; // IMP * (64-bit pointer)
3620 uint64_t data; // class_ro64_t * (64-bit pointer)
3624 uint32_t isa; /* class32_t * (32-bit pointer) */
3625 uint32_t superclass; /* class32_t * (32-bit pointer) */
3626 uint32_t cache; /* Cache (32-bit pointer) */
3627 uint32_t vtable; /* IMP * (32-bit pointer) */
3628 uint32_t data; /* class_ro32_t * (32-bit pointer) */
3636 uint64_t ivarLayout; // const uint8_t * (64-bit pointer)
3637 uint64_t name; // const char * (64-bit pointer)
3638 uint64_t baseMethods; // const method_list_t * (64-bit pointer)
3639 uint64_t baseProtocols; // const protocol_list_t * (64-bit pointer)
3640 uint64_t ivars; // const ivar_list_t * (64-bit pointer)
3641 uint64_t weakIvarLayout; // const uint8_t * (64-bit pointer)
3642 uint64_t baseProperties; // const struct objc_property_list (64-bit pointer)
3649 uint32_t ivarLayout; /* const uint8_t * (32-bit pointer) */
3650 uint32_t name; /* const char * (32-bit pointer) */
3651 uint32_t baseMethods; /* const method_list_t * (32-bit pointer) */
3652 uint32_t baseProtocols; /* const protocol_list_t * (32-bit pointer) */
3653 uint32_t ivars; /* const ivar_list_t * (32-bit pointer) */
3654 uint32_t weakIvarLayout; /* const uint8_t * (32-bit pointer) */
3656 (32-bit pointer) */
3659 /* Values for class_ro{64,32}_t->flags */
3664 /* Values for method_list{64,32}_t->entsize */
3681 uint64_t name; /* SEL (64-bit pointer) */
3682 uint64_t types; /* const char * (64-bit pointer) */
3683 uint64_t imp; /* IMP (64-bit pointer) */
3687 uint32_t name; /* SEL (32-bit pointer) */
3688 uint32_t types; /* const char * (32-bit pointer) */
3689 uint32_t imp; /* IMP (32-bit pointer) */
3693 int32_t name; /* SEL (32-bit relative) */
3694 int32_t types; /* const char * (32-bit relative) */
3695 int32_t imp; /* IMP (32-bit relative) */
3699 uint64_t count; /* uintptr_t (a 64-bit value) */
3704 uint32_t count; /* uintptr_t (a 32-bit value) */
3709 uint64_t isa; /* id * (64-bit pointer) */
3710 uint64_t name; /* const char * (64-bit pointer) */
3712 (64-bit pointer) */
3713 uint64_t instanceMethods; /* method_list_t * (64-bit pointer) */
3714 uint64_t classMethods; /* method_list_t * (64-bit pointer) */
3715 uint64_t optionalInstanceMethods; /* method_list_t * (64-bit pointer) */
3716 uint64_t optionalClassMethods; /* method_list_t * (64-bit pointer) */
3718 (64-bit pointer) */
3722 uint32_t isa; /* id * (32-bit pointer) */
3723 uint32_t name; /* const char * (32-bit pointer) */
3725 (32-bit pointer) */
3726 uint32_t instanceMethods; /* method_list_t * (32-bit pointer) */
3727 uint32_t classMethods; /* method_list_t * (32-bit pointer) */
3728 uint32_t optionalInstanceMethods; /* method_list_t * (32-bit pointer) */
3729 uint32_t optionalClassMethods; /* method_list_t * (32-bit pointer) */
3731 (32-bit pointer) */
3747 uint64_t offset; /* uintptr_t * (64-bit pointer) */
3748 uint64_t name; /* const char * (64-bit pointer) */
3749 uint64_t type; /* const char * (64-bit pointer) */
3755 uint32_t offset; /* uintptr_t * (32-bit pointer) */
3756 uint32_t name; /* const char * (32-bit pointer) */
3757 uint32_t type; /* const char * (32-bit pointer) */
3775 uint64_t name; /* const char * (64-bit pointer) */
3776 uint64_t attributes; /* const char * (64-bit pointer) */
3780 uint32_t name; /* const char * (32-bit pointer) */
3781 uint32_t attributes; /* const char * (32-bit pointer) */
3785 uint64_t name; /* const char * (64-bit pointer) */
3786 uint64_t cls; /* struct class_t * (64-bit pointer) */
3787 uint64_t instanceMethods; /* struct method_list_t * (64-bit pointer) */
3788 uint64_t classMethods; /* struct method_list_t * (64-bit pointer) */
3789 uint64_t protocols; /* struct protocol_list_t * (64-bit pointer) */
3791 (64-bit pointer) */
3795 uint32_t name; /* const char * (32-bit pointer) */
3796 uint32_t cls; /* struct class_t * (32-bit pointer) */
3797 uint32_t instanceMethods; /* struct method_list_t * (32-bit pointer) */
3798 uint32_t classMethods; /* struct method_list_t * (32-bit pointer) */
3799 uint32_t protocols; /* struct protocol_list_t * (32-bit pointer) */
3801 (32-bit pointer) */
3823 uint64_t imp; /* IMP (64-bit pointer) */
3824 uint64_t sel; /* SEL (64-bit pointer) */
3828 uint32_t imp; /* IMP (32-bit pointer) */
3829 uint32_t sel; /* SEL (32-bit pointer) */
3832 // Objective-C 1 (32-bit only) meta data structs.
3837 uint32_t name; /* char * (32-bit pointer) */
3838 uint32_t symtab; /* struct objc_symtab * (32-bit pointer) */
3843 uint32_t refs; /* SEL * (32-bit pointer) */
3846 // uint32_t defs[1]; /* void * (32-bit pointer) variable size */
3850 uint32_t isa; /* struct objc_class * (32-bit pointer) */
3851 uint32_t super_class; /* struct objc_class * (32-bit pointer) */
3852 uint32_t name; /* const char * (32-bit pointer) */
3856 uint32_t ivars; /* struct objc_ivar_list * (32-bit pointer) */
3857 uint32_t methodLists; /* struct objc_method_list ** (32-bit pointer) */
3858 uint32_t cache; /* struct objc_cache * (32-bit pointer) */
3859 uint32_t protocols; /* struct objc_protocol_list * (32-bit pointer) */
3862 #define CLS_GETINFO(cls, infomask) ((cls)->info & (infomask))
3869 uint32_t category_name; /* char * (32-bit pointer) */
3870 uint32_t class_name; /* char * (32-bit pointer) */
3871 uint32_t instance_methods; /* struct objc_method_list * (32-bit pointer) */
3872 uint32_t class_methods; /* struct objc_method_list * (32-bit pointer) */
3873 uint32_t protocols; /* struct objc_protocol_list * (32-bit ptr) */
3877 uint32_t ivar_name; /* char * (32-bit pointer) */
3878 uint32_t ivar_type; /* char * (32-bit pointer) */
3888 uint32_t obsolete; /* struct objc_method_list * (32-bit pointer) */
3894 uint32_t method_name; /* SEL, aka struct objc_selector * (32-bit pointer) */
3895 uint32_t method_types; /* char * (32-bit pointer) */
3897 (32-bit pointer) */
3901 uint32_t next; /* struct objc_protocol_list * (32-bit pointer) */
3904 // (32-bit pointer) */
3908 uint32_t isa; /* struct objc_class * (32-bit pointer) */
3909 uint32_t protocol_name; /* char * (32-bit pointer) */
3910 uint32_t protocol_list; /* struct objc_protocol_list * (32-bit pointer) */
3912 (32-bit pointer) */
3914 (32-bit pointer) */
3923 uint32_t name; /* SEL, aka struct objc_selector * (32-bit pointer) */
3924 uint32_t types; /* char * (32-bit pointer) */
4208 // to an Objective-C class and returns the class name. It is also passed the
4237 // The case were the pointer_value is non-zero and points to a class defined in get_objc2_64bit_class_name()
4238 // in this Mach-O file. in get_objc2_64bit_class_name()
4244 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in get_objc2_64bit_class_name()
4253 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in get_objc2_64bit_class_name()
4275 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in get_objc2_64bit_cfstring_name()
4292 // of a pointer to an Objective-C selector reference when the pointer value is
4314 for (const SectionRef &Section : O->sections()) { in get_section()
4323 StringRef SegName = O->getSectionFinalSegmentName(Ref); in get_section()
4345 StringRef SegName = O->getSectionFinalSegmentName(Ref); in walk_pointer_list_64()
4348 StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName()); in walk_pointer_list_64()
4352 uint32_t left = S.getSize() - i; in walk_pointer_list_64()
4361 if (O->isLittleEndian() != sys::IsLittleEndianHost) in walk_pointer_list_64()
4392 StringRef SectName = unwrapOrError(S.getName(), O->getFileName()); in walk_pointer_list_32()
4394 StringRef SegName = O->getSectionFinalSegmentName(Ref); in walk_pointer_list_32()
4397 StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName()); in walk_pointer_list_32()
4401 uint32_t left = S.getSize() - i; in walk_pointer_list_32()
4411 if (O->isLittleEndian() != sys::IsLittleEndianHost) in walk_pointer_list_32()
4428 outs() << " layout map: "; in print_layout_map()
4431 left--; in print_layout_map()
4484 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_relative_method_list()
4503 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_relative_method_list()
4508 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_relative_method_list()
4531 name = GuessSymbolName(absImpVA, info->AddrMap); in print_relative_method_list()
4560 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_list64_t()
4584 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_list64_t()
4591 if (info->verbose && sym_name != nullptr) in print_method_list64_t()
4608 if (info->verbose && sym_name != nullptr) in print_method_list64_t()
4624 if (info->verbose && name == nullptr) { in print_method_list64_t()
4658 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_list32_t()
4682 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_list32_t()
4729 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_list()
4744 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_list()
4749 if (info->verbose) { in print_method_list()
4760 if (info->verbose) { in print_method_list()
4771 if (info->verbose) { in print_method_list()
4772 SymbolName = GuessSymbolName(method.method_imp, info->AddrMap); in print_method_list()
4799 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list64_t()
4815 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list64_t()
4821 if (info->verbose && sym_name != nullptr) in print_protocol_list64_t()
4840 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list64_t()
4849 if (info->verbose && sym_name != nullptr) in print_protocol_list64_t()
4869 if (info->verbose && sym_name != nullptr) in print_protocol_list64_t()
4886 if (info->verbose && sym_name != nullptr) in print_protocol_list64_t()
4928 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list32_t()
4944 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list32_t()
4957 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list32_t()
4988 if (indent - i >= 8) { in print_indent()
5021 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_description_list()
5038 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_method_description_list()
5043 if (info->verbose) { in print_method_description_list()
5054 if (info->verbose) { in print_method_description_list()
5089 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol()
5099 if (info->verbose) { in print_protocol()
5149 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list()
5165 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_protocol_list()
5194 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_ivar_list64_t()
5211 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_ivar_list64_t()
5218 if (info->verbose && sym_name != nullptr) in print_ivar_list64_t()
5229 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_ivar_list64_t()
5239 if (info->verbose && sym_name != nullptr) in print_ivar_list64_t()
5257 if (info->verbose && sym_name != nullptr) in print_ivar_list64_t()
5295 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_ivar_list32_t()
5312 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_ivar_list32_t()
5319 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_ivar_list32_t()
5364 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_objc_property_list64()
5381 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_objc_property_list64()
5388 if (info->verbose && sym_name != nullptr) in print_objc_property_list64()
5406 if (info->verbose && sym_name != nullptr) in print_objc_property_list64()
5442 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_objc_property_list32()
5459 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_objc_property_list32()
5492 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_class_ro64_t()
5514 if (info->verbose && sym_name != nullptr) in print_class_ro64_t()
5531 if (info->verbose && sym_name != nullptr) in print_class_ro64_t()
5548 if (info->verbose && sym_name != nullptr) in print_class_ro64_t()
5564 if (info->verbose && sym_name != nullptr) in print_class_ro64_t()
5581 if (info->verbose && sym_name != nullptr) in print_class_ro64_t()
5597 if (info->verbose && sym_name != nullptr) in print_class_ro64_t()
5630 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_class_ro32_t()
5689 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_class64_t()
5730 if (info->verbose && name != nullptr) in print_class64_t()
5751 info->depth < 100) { in print_class64_t()
5752 info->depth++; in print_class64_t()
5774 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_class32_t()
5833 outs() << "\t\t isa " << format("0x%08" PRIx32, objc_class->isa); in print_objc_class_t()
5834 if (info->verbose && CLS_GETINFO(objc_class, CLS_META)) { in print_objc_class_t()
5835 name = get_pointer_32(objc_class->isa, offset, left, S, info, true); in print_objc_class_t()
5844 << format("0x%08" PRIx32, objc_class->super_class); in print_objc_class_t()
5845 if (info->verbose) { in print_objc_class_t()
5846 name = get_pointer_32(objc_class->super_class, offset, left, S, info, true); in print_objc_class_t()
5854 outs() << "\t\t name " << format("0x%08" PRIx32, objc_class->name); in print_objc_class_t()
5855 if (info->verbose) { in print_objc_class_t()
5856 name = get_pointer_32(objc_class->name, offset, left, S, info, true); in print_objc_class_t()
5864 outs() << "\t\t version " << format("0x%08" PRIx32, objc_class->version) in print_objc_class_t()
5867 outs() << "\t\t info " << format("0x%08" PRIx32, objc_class->info); in print_objc_class_t()
5868 if (info->verbose) { in print_objc_class_t()
5877 << format("0x%08" PRIx32, objc_class->instance_size) << "\n"; in print_objc_class_t()
5879 p = get_pointer_32(objc_class->ivars, offset, left, S, info, true); in print_objc_class_t()
5880 outs() << "\t\t ivars " << format("0x%08" PRIx32, objc_class->ivars); in print_objc_class_t()
5890 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_objc_class_t()
5901 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_objc_class_t()
5905 if (info->verbose) { in print_objc_class_t()
5915 if (info->verbose) { in print_objc_class_t()
5931 outs() << "\t\t methods " << format("0x%08" PRIx32, objc_class->methodLists); in print_objc_class_t()
5932 if (print_method_list(objc_class->methodLists, info)) in print_objc_class_t()
5935 outs() << "\t\t cache " << format("0x%08" PRIx32, objc_class->cache) in print_objc_class_t()
5938 outs() << "\t\tprotocols " << format("0x%08" PRIx32, objc_class->protocols); in print_objc_class_t()
5939 if (print_protocol_list(objc_class->protocols, 16, info)) in print_objc_class_t()
5950 << format("0x%08" PRIx32, objc_category->category_name); in print_objc_objc_category_t()
5951 if (info->verbose) { in print_objc_objc_category_t()
5952 name = get_pointer_32(objc_category->category_name, offset, left, S, info, in print_objc_objc_category_t()
5962 << format("0x%08" PRIx32, objc_category->class_name); in print_objc_objc_category_t()
5963 if (info->verbose) { in print_objc_objc_category_t()
5965 get_pointer_32(objc_category->class_name, offset, left, S, info, true); in print_objc_objc_category_t()
5974 << format("0x%08" PRIx32, objc_category->instance_methods); in print_objc_objc_category_t()
5975 if (print_method_list(objc_category->instance_methods, info)) in print_objc_objc_category_t()
5979 << format("0x%08" PRIx32, objc_category->class_methods); in print_objc_objc_category_t()
5980 if (print_method_list(objc_category->class_methods, info)) in print_objc_objc_category_t()
6001 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_category64_t()
6008 if (info->verbose && sym_name != nullptr) in print_category64_t()
6025 if (info->verbose && sym_name != nullptr) in print_category64_t()
6042 if (info->verbose && sym_name != nullptr) in print_category64_t()
6058 if (info->verbose && sym_name != nullptr) in print_category64_t()
6074 if (info->verbose && sym_name != nullptr) in print_category64_t()
6091 if (info->verbose && sym_name != nullptr) in print_category64_t()
6120 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_category32_t()
6169 StringRef SegName = info->O->getSectionFinalSegmentName(Ref); in print_message_refs64()
6183 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_message_refs64()
6203 if (info->verbose && sym_name != nullptr) in print_message_refs64()
6237 StringRef SegName = info->O->getSectionFinalSegmentName(Ref); in print_message_refs32()
6251 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_message_refs32()
6288 StringRef SegName = info->O->getSectionFinalSegmentName(Ref); in print_image_info64()
6300 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_image_info64()
6350 StringRef SegName = info->O->getSectionFinalSegmentName(Ref); in print_image_info32()
6362 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_image_info32()
6405 StringRef SegName = info->O->getSectionFinalSegmentName(Ref); in print_image_info()
6417 if (info->O->isLittleEndian() != sys::IsLittleEndianHost) in print_image_info()
6426 outs() << " GC-only"; in print_image_info()
6438 append_range(Sections, O->sections()); in printObjc2_64bit_MetaData()
6519 append_range(Sections, O->sections()); in printObjc2_32bit_MetaData()
6603 outs() << "Objective-C segment\n"; in printObjc1_32bit_MetaData()
6613 append_range(Sections, O->sections()); in printObjc1_32bit_MetaData()
6628 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6659 defs_left = left - sizeof(struct objc_symtab_t); in printObjc1_32bit_MetaData()
6663 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6683 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6697 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6716 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6734 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6749 if (O->isLittleEndian() != sys::IsLittleEndianHost) in printObjc1_32bit_MetaData()
6770 append_range(Sections, O->sections()); in DumpProtocolSection()
6779 left = size - (p - sect); in DumpProtocolSection()
6785 if (O->isLittleEndian() != sys::IsLittleEndianHost) in DumpProtocolSection()
6787 paddr = addr + (p - sect); in DumpProtocolSection()
6795 if (O->is64Bit()) in printObjcMetaData()
6799 H = O->getHeader(); in printObjcMetaData()
6803 // This is the 32-bit non-arm cputype case. Which is normally in printObjcMetaData()
6804 // the first Objective-C ABI. But it may be the case of a in printObjcMetaData()
6805 // binary for the iOS simulator which is the second Objective-C in printObjcMetaData()
6814 // GuessLiteralPointer returns a string which for the item in the Mach-O file
6823 // If ReferenceValue is an address of an Objective-C CFString, Selector ref or
6830 // If there is no item in the Mach-O file for the address passed in as
6837 if (info->O->getHeader().filetype == MachO::MH_OBJECT) { in GuessLiteralPointer()
6838 uint64_t sect_addr = info->S.getAddress(); in GuessLiteralPointer()
6839 uint64_t sect_offset = ReferencePC - sect_addr; in GuessLiteralPointer()
6845 for (const RelocationRef &Reloc : info->S.relocations()) { in GuessLiteralPointer()
6849 RE = info->O->getRelocation(Rel); in GuessLiteralPointer()
6850 if (info->O->isRelocationScattered(RE)) in GuessLiteralPointer()
6852 isExtern = info->O->getPlainRelocationExternal(RE); in GuessLiteralPointer()
6864 if (info->O->getAnyRelocationPCRel(RE)) { in GuessLiteralPointer()
6865 unsigned Type = info->O->getAnyRelocationType(RE); in GuessLiteralPointer()
6873 // Look for literals such as Objective-C CFStrings refs, Selector refs, in GuessLiteralPointer()
6888 info->class_name = class_name + 2; in GuessLiteralPointer()
6899 info->class_name = name; in GuessLiteralPointer()
6921 info->selector_name = name; in GuessLiteralPointer()
6923 info->class_name = nullptr; in GuessLiteralPointer()
6925 info->selector_name = name; in GuessLiteralPointer()
6948 // "llvm-c/Disassembler.h". On return the ReferenceType can set to a specific
6966 // or an Objective-C meta data reference. If so the output ReferenceType is
6975 if (!info->verbose) { in SymbolizerSymbolLookUp()
6981 const char *SymbolName = GuessSymbolName(ReferenceValue, info->AddrMap); in SymbolizerSymbolLookUp()
6990 if (info->demangled_name != nullptr) in SymbolizerSymbolLookUp()
6991 free(info->demangled_name); in SymbolizerSymbolLookUp()
6992 info->demangled_name = itaniumDemangle(SymbolName + 1); in SymbolizerSymbolLookUp()
6993 if (info->demangled_name != nullptr) { in SymbolizerSymbolLookUp()
6994 *ReferenceName = info->demangled_name; in SymbolizerSymbolLookUp()
7010 } else if (info->O->getArch() == Triple::aarch64 && in SymbolizerSymbolLookUp()
7012 info->adrp_inst = ReferenceValue; in SymbolizerSymbolLookUp()
7013 info->adrp_addr = ReferencePC; in SymbolizerSymbolLookUp()
7024 } else if (info->O->getArch() == Triple::aarch64 && in SymbolizerSymbolLookUp()
7026 ReferencePC - 4 == info->adrp_addr && in SymbolizerSymbolLookUp()
7027 (info->adrp_inst & 0x9f000000) == 0x90000000 && in SymbolizerSymbolLookUp()
7028 (info->adrp_inst & 0x1f) == ((ReferenceValue >> 5) & 0x1f)) { in SymbolizerSymbolLookUp()
7033 ((info->adrp_inst & 0x00ffffe0) >> 3) | ((info->adrp_inst >> 29) & 0x3); in SymbolizerSymbolLookUp()
7034 if (info->adrp_inst & 0x0200000) in SymbolizerSymbolLookUp()
7042 ReferenceValue = (info->adrp_addr & 0xfffffffffffff000LL) + in SymbolizerSymbolLookUp()
7054 } else if (info->O->getArch() == Triple::aarch64 && in SymbolizerSymbolLookUp()
7056 ReferencePC - 4 == info->adrp_addr && in SymbolizerSymbolLookUp()
7057 (info->adrp_inst & 0x9f000000) == 0x90000000 && in SymbolizerSymbolLookUp()
7058 (info->adrp_inst & 0x1f) == ((ReferenceValue >> 5) & 0x1f)) { in SymbolizerSymbolLookUp()
7063 ((info->adrp_inst & 0x00ffffe0) >> 3) | ((info->adrp_inst >> 29) & 0x3); in SymbolizerSymbolLookUp()
7064 if (info->adrp_inst & 0x0200000) in SymbolizerSymbolLookUp()
7070 ReferenceValue = (info->adrp_addr & 0xfffffffffffff000LL) + in SymbolizerSymbolLookUp()
7078 // If this arm64 and is an load register (PC-relative) instruction the in SymbolizerSymbolLookUp()
7080 else if (info->O->getArch() == Triple::aarch64 && in SymbolizerSymbolLookUp()
7088 if (info->demangled_name != nullptr) in SymbolizerSymbolLookUp()
7089 free(info->demangled_name); in SymbolizerSymbolLookUp()
7090 info->demangled_name = itaniumDemangle(SymbolName + 1); in SymbolizerSymbolLookUp()
7091 if (info->demangled_name != nullptr) { in SymbolizerSymbolLookUp()
7092 *ReferenceName = info->demangled_name; in SymbolizerSymbolLookUp()
7138 // Auto-detect w/o --dsym. in getMachODSymObject()
7156 // If DSYMPath is a .dSYM directory, append the Mach-O file. in getMachODSymObject()
7182 createBinary(DSYMBuf->getMemBufferRef()); in getMachODSymObject()
7191 // this is a Mach-O object file, use it in getMachODSymObject()
7195 WithColor::error(errs(), "llvm-objdump") in getMachODSymObject()
7196 << DSYMPath << " is not a Mach-O file type.\n"; in getMachODSymObject()
7200 // this is a Universal Binary, find a Mach-O for this architecture in getMachODSymObject()
7203 if (MachOOF->is64Bit()) { in getMachODSymObject()
7204 const MachO::mach_header_64 H_64 = MachOOF->getHeader64(); in getMachODSymObject()
7208 const MachO::mach_header H = MachOOF->getHeader(); in getMachODSymObject()
7215 UB->getMachOObjectForArch(ArchFlag); in getMachODSymObject()
7225 WithColor::error(errs(), "llvm-objdump") in getMachODSymObject()
7226 << DSYMPath << " is not a Mach-O or Universal file type.\n"; in getMachODSymObject()
7251 WithColor::error(errs(), "llvm-objdump") \ in DisassembleMachO()
7260 WithColor::error(errs(), "llvm-objdump") \ in DisassembleMachO()
7267 std::unique_ptr<const MCInstrInfo> InstrInfo(TheTarget->createMCInstrInfo()); in DisassembleMachO()
7271 ThumbInstrInfo.reset(ThumbTarget->createMCInstrInfo()); in DisassembleMachO()
7287 TheTarget->createMCRegInfo(TripleName)); in DisassembleMachO()
7290 TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions)); in DisassembleMachO()
7293 TheTarget->createMCSubtargetInfo(TripleName, MachOMCPU, FeaturesStr)); in DisassembleMachO()
7297 TheTarget->createMCDisassembler(*STI, Ctx)); in DisassembleMachO()
7302 TheTarget->createMCRelocationInfo(TripleName, Ctx)); in DisassembleMachO()
7304 Symbolizer.reset(TheTarget->createMCSymbolizer( in DisassembleMachO()
7307 DisAsm->setSymbolizer(std::move(Symbolizer)); in DisassembleMachO()
7309 int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); in DisassembleMachO()
7310 std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( in DisassembleMachO()
7314 IP->setPrintImmHex(PrintImmHex); in DisassembleMachO()
7321 // (32-bit and 64-bit) comments printed with different spacing before the in DisassembleMachO()
7323 // IP->setCommentStream(CommentStream); in DisassembleMachO()
7336 ThumbMRI.reset(ThumbTarget->createMCRegInfo(ThumbTripleName)); in DisassembleMachO()
7339 ThumbTarget->createMCAsmInfo(*ThumbMRI, ThumbTripleName, MCOptions)); in DisassembleMachO()
7342 ThumbTarget->createMCSubtargetInfo(ThumbTripleName, MachOMCPU, in DisassembleMachO()
7347 ThumbDisAsm.reset(ThumbTarget->createMCDisassembler(*ThumbSTI, *ThumbCtx)); in DisassembleMachO()
7351 ThumbTarget->createMCRelocationInfo(ThumbTripleName, *PtrThumbCtx)); in DisassembleMachO()
7353 ThumbSymbolizer.reset(ThumbTarget->createMCSymbolizer( in DisassembleMachO()
7356 ThumbDisAsm->setSymbolizer(std::move(ThumbSymbolizer)); in DisassembleMachO()
7358 int ThumbAsmPrinterVariant = ThumbAsmInfo->getAssemblerDialect(); in DisassembleMachO()
7359 ThumbIP.reset(ThumbTarget->createMCInstPrinter( in DisassembleMachO()
7364 ThumbIP->setPrintImmHex(PrintImmHex); in DisassembleMachO()
7370 MachO::mach_header Header = MachOOF->getHeader(); in DisassembleMachO()
7372 // FIXME: Using the -cfg command line option, this code used to be able to in DisassembleMachO()
7394 for (dice_iterator DI = MachOOF->begin_dices(), DE = MachOOF->end_dices(); in DisassembleMachO()
7397 DI->getOffset(Offset); in DisassembleMachO()
7432 StringRef SegmentName = MachOOF->getSectionFinalSegmentName(DR); in DisassembleMachO()
7447 for (const SymbolRef &Symbol : MachOOF->symbols()) { in DisassembleMachO()
7449 unwrapOrError(Symbol.getType(), MachOOF->getFileName()); in DisassembleMachO()
7454 unwrapOrError(Symbol.getName(), MachOOF->getFileName()); in DisassembleMachO()
7461 outs() << "Can't find -dis-symname: " << DisSymName << "\n"; in DisassembleMachO()
7477 unsigned int Arch = MachOOF->getArch(); in DisassembleMachO()
7492 unwrapOrError(Symbols[SymIdx].getName(), MachOOF->getFileName()); in DisassembleMachO()
7494 unwrapOrError(Symbols[SymIdx].getType(), MachOOF->getFileName()); in DisassembleMachO()
7502 outs() << "-dis-symname: " << DisSymName << " not in the section\n"; in DisassembleMachO()
7513 outs() << "-dis-symname: __mh_execute_header not in any section\n"; in DisassembleMachO()
7533 Start -= SectionAddress; in DisassembleMachO()
7548 Symbols[NextSymIdx].getType(), MachOOF->getFileName()); in DisassembleMachO()
7553 NextSym -= SectionAddress; in DisassembleMachO()
7565 uint32_t SymbolFlags = cantFail(MachOOF->getSymbolFlags(Symb)); in DisassembleMachO()
7569 // (i.e. we're not targeting M-class) and the function is Thumb. in DisassembleMachO()
7598 if (MachOOF->is64Bit()) in DisassembleMachO()
7617 gotInst = ThumbDisAsm->getInstruction(Inst, Size, Bytes.slice(Index), in DisassembleMachO()
7620 gotInst = DisAsm->getInstruction(Inst, Size, Bytes.slice(Index), PC, in DisassembleMachO()
7629 ThumbIP->printInst(&Inst, PC, AnnotationsStr, *ThumbSTI, in DisassembleMachO()
7632 IP->printInst(&Inst, PC, AnnotationsStr, *STI, FormattedOS); in DisassembleMachO()
7637 DILineInfo dli = diContext->getLineInfoForAddress({PC, SectIdx}); in DisassembleMachO()
7646 if (MachOOF->getArchTriple().isX86()) { in DisassembleMachO()
7665 WithColor::warning(errs(), "llvm-objdump") in DisassembleMachO()
7691 if (DisAsm->getInstruction(Inst, InstSize, Bytes.slice(Index), PC, in DisassembleMachO()
7695 if (MachOOF->is64Bit()) in DisassembleMachO()
7708 IP->printInst(&Inst, PC, AnnotationsStr, *STI, outs()); in DisassembleMachO()
7711 if (MachOOF->getArchTriple().isX86()) { in DisassembleMachO()
7716 WithColor::warning(errs(), "llvm-objdump") in DisassembleMachO()
7736 //===----------------------------------------------------------------------===//
7738 //===----------------------------------------------------------------------===//
7799 /// 2. Otherwise the data is an offset in the object file's layout; try to find
7807 if (Reloc.getSymbol() != Obj->symbol_end()) { in findUnwindRelocNameAddend()
7808 Name = unwrapOrError(Reloc.getSymbol()->getName(), Obj->getFileName()); in findUnwindRelocNameAddend()
7813 auto RE = Obj->getRelocation(Reloc.getRawDataRefImpl()); in findUnwindRelocNameAddend()
7814 SectionRef RelocSection = Obj->getAnyRelocationSection(RE); in findUnwindRelocNameAddend()
7821 // do is section-relative notation. in findUnwindRelocNameAddend()
7827 Addend = Addr - SectionAddr; in findUnwindRelocNameAddend()
7832 --Sym; in findUnwindRelocNameAddend()
7835 unwrapOrError(Sym->second.getSection(), Obj->getFileName()); in findUnwindRelocNameAddend()
7838 Name = unwrapOrError(Sym->second.getName(), Obj->getFileName()); in findUnwindRelocNameAddend()
7839 Addend = Addr - Sym->first; in findUnwindRelocNameAddend()
7850 Addend = Addr - SectionAddr; in findUnwindRelocNameAddend()
7874 if (!Obj->isLittleEndian()) { in printMachOCompactUnwindSection()
7875 outs() << "Skipping big-endian __compact_unwind section\n"; in printMachOCompactUnwindSection()
7879 bool Is64 = Obj->is64Bit(); in printMachOCompactUnwindSection()
7884 unwrapOrError(CompactUnwind.getContents(), Obj->getFileName()); in printMachOCompactUnwindSection()
7899 uint32_t OffsetInEntry = RelocAddress - EntryIdx * EntrySize; in printMachOCompactUnwindSection()
7929 // 3. The 32-bit compact encoding. in printMachOCompactUnwindSection()
7942 // 5. This entry's language-specific data area. in printMachOCompactUnwindSection()
7952 //===----------------------------------------------------------------------===//
7954 //===----------------------------------------------------------------------===//
8013 Encoding = PageEncodings[EncodingIdx - NumCommonEncodings]; in printCompressedSecondLevelUnwindPage()
8027 if (!Obj->isLittleEndian()) { in printMachOUnwindInfoSection()
8028 outs() << "Skipping big-endian __unwind_info section\n"; in printMachOUnwindInfoSection()
8035 unwrapOrError(UnwindInfo.getContents(), Obj->getFileName()); in printMachOUnwindInfoSection()
8038 //===---------------------------------- in printMachOUnwindInfoSection()
8040 //===---------------------------------- in printMachOUnwindInfoSection()
8071 //===---------------------------------- in printMachOUnwindInfoSection()
8073 //===---------------------------------- in printMachOUnwindInfoSection()
8091 //===---------------------------------- in printMachOUnwindInfoSection()
8093 //===---------------------------------- in printMachOUnwindInfoSection()
8106 //===---------------------------------- in printMachOUnwindInfoSection()
8108 //===---------------------------------- in printMachOUnwindInfoSection()
8139 //===---------------------------------- in printMachOUnwindInfoSection()
8141 //===---------------------------------- in printMachOUnwindInfoSection()
8143 // The LSDA layout is rather implicit: it's a contiguous array of entries from in printMachOUnwindInfoSection()
8144 // the first top-level index's LSDAOffset to the last (sentinel). in printMachOUnwindInfoSection()
8150 (IndexEntries.back().LSDAStart - IndexEntries[0].LSDAStart) / LSDASize; in printMachOUnwindInfoSection()
8161 //===---------------------------------- in printMachOUnwindInfoSection()
8163 //===---------------------------------- in printMachOUnwindInfoSection()
8170 for (unsigned i = 0; i < IndexEntries.size() - 1; ++i) { in printMachOUnwindInfoSection()
8171 // The final sentinel top-level index has no associated 2nd level page in printMachOUnwindInfoSection()
8204 for (const SymbolRef &SymRef : Obj->symbols()) { in printMachOUnwindInfo()
8214 if (Section == Obj->section_end()) in printMachOUnwindInfo()
8221 for (const SectionRef &Section : Obj->sections()) { in printMachOUnwindInfo()
8586 outs() << ((maxprot & MachO::VM_PROT_READ) ? "r" : "-"); in PrintSegmentCommand()
8587 outs() << ((maxprot & MachO::VM_PROT_WRITE) ? "w" : "-"); in PrintSegmentCommand()
8588 outs() << ((maxprot & MachO::VM_PROT_EXECUTE) ? "x\n" : "-\n"); in PrintSegmentCommand()
8596 outs() << ((initprot & MachO::VM_PROT_READ) ? "r" : "-"); in PrintSegmentCommand()
8597 outs() << ((initprot & MachO::VM_PROT_WRITE) ? "w" : "-"); in PrintSegmentCommand()
8598 outs() << ((initprot & MachO::VM_PROT_EXECUTE) ? "x\n" : "-\n"); in PrintSegmentCommand()
9063 outs() << "-"; in PrintUuidLoadCommand()
9178 MachO::build_tool_version bv = obj->getBuildToolVersion(i); in PrintBuildVersionLoadCommand()
9269 uint32_t left = lo.cmdsize - sizeof(struct MachO::linker_option_command); in PrintLinkerOptionCommand()
9274 left--; in PrintLinkerOptionCommand()
9282 left -= len; in PrintLinkerOptionCommand()
9646 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9655 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9672 left = end - begin; in PrintThreadCommand()
9692 left = end - begin; in PrintThreadCommand()
9724 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9733 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9750 left = end - begin; in PrintThreadCommand()
9770 left = end - begin; in PrintThreadCommand()
9800 left = end - begin; in PrintThreadCommand()
9831 left = end - begin; in PrintThreadCommand()
9862 left = end - begin; in PrintThreadCommand()
9883 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9892 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9909 left = end - begin; in PrintThreadCommand()
9931 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9940 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9957 left = end - begin; in PrintThreadCommand()
9978 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
9987 if (end - begin > (ptrdiff_t)sizeof(uint32_t)) { in PrintThreadCommand()
10092 StringRef Buf = Obj->getData(); in PrintLoadCommands()
10094 for (const auto &Command : Obj->load_commands()) { in PrintLoadCommands()
10097 MachO::segment_command SLC = Obj->getSegmentLoadCommand(Command); in PrintLoadCommands()
10104 MachO::section S = Obj->getSection(Command, j); in PrintLoadCommands()
10110 MachO::segment_command_64 SLC_64 = Obj->getSegment64LoadCommand(Command); in PrintLoadCommands()
10117 MachO::section_64 S_64 = Obj->getSection64(Command, j); in PrintLoadCommands()
10124 MachO::symtab_command Symtab = Obj->getSymtabLoadCommand(); in PrintLoadCommands()
10125 PrintSymtabLoadCommand(Symtab, Obj->is64Bit(), Buf.size()); in PrintLoadCommands()
10127 MachO::dysymtab_command Dysymtab = Obj->getDysymtabLoadCommand(); in PrintLoadCommands()
10128 MachO::symtab_command Symtab = Obj->getSymtabLoadCommand(); in PrintLoadCommands()
10130 Obj->is64Bit()); in PrintLoadCommands()
10133 MachO::dyld_info_command DyldInfo = Obj->getDyldInfoLoadCommand(Command); in PrintLoadCommands()
10138 MachO::dylinker_command Dyld = Obj->getDylinkerCommand(Command); in PrintLoadCommands()
10141 MachO::uuid_command Uuid = Obj->getUuidCommand(Command); in PrintLoadCommands()
10144 MachO::rpath_command Rpath = Obj->getRpathCommand(Command); in PrintLoadCommands()
10150 MachO::version_min_command Vd = Obj->getVersionMinLoadCommand(Command); in PrintLoadCommands()
10153 MachO::note_command Nt = Obj->getNoteLoadCommand(Command); in PrintLoadCommands()
10157 Obj->getBuildVersionLoadCommand(Command); in PrintLoadCommands()
10160 MachO::source_version_command Sd = Obj->getSourceVersionCommand(Command); in PrintLoadCommands()
10163 MachO::entry_point_command Ep = Obj->getEntryPointCommand(Command); in PrintLoadCommands()
10167 Obj->getEncryptionInfoCommand(Command); in PrintLoadCommands()
10171 Obj->getEncryptionInfoCommand64(Command); in PrintLoadCommands()
10175 Obj->getLinkerOptionLoadCommand(Command); in PrintLoadCommands()
10178 MachO::sub_framework_command Sf = Obj->getSubFrameworkCommand(Command); in PrintLoadCommands()
10181 MachO::sub_umbrella_command Sf = Obj->getSubUmbrellaCommand(Command); in PrintLoadCommands()
10184 MachO::sub_library_command Sl = Obj->getSubLibraryCommand(Command); in PrintLoadCommands()
10187 MachO::sub_client_command Sc = Obj->getSubClientCommand(Command); in PrintLoadCommands()
10190 MachO::routines_command Rc = Obj->getRoutinesCommand(Command); in PrintLoadCommands()
10193 MachO::routines_command_64 Rc = Obj->getRoutinesCommand64(Command); in PrintLoadCommands()
10197 MachO::thread_command Tc = Obj->getThreadCommand(Command); in PrintLoadCommands()
10198 PrintThreadCommand(Tc, Command.Ptr, Obj->isLittleEndian(), cputype); in PrintLoadCommands()
10205 MachO::dylib_command Dl = Obj->getDylibIDLoadCommand(Command); in PrintLoadCommands()
10217 Obj->getLinkeditDataLoadCommand(Command); in PrintLoadCommands()
10230 if (Obj->is64Bit()) { in PrintMachHeader()
10232 H_64 = Obj->getHeader64(); in PrintMachHeader()
10237 H = Obj->getHeader(); in PrintMachHeader()
10258 if (file->is64Bit()) { in printMachOLoadCommands()
10260 H_64 = file->getHeader64(); in printMachOLoadCommands()
10265 H = file->getHeader(); in printMachOLoadCommands()
10272 //===----------------------------------------------------------------------===//
10274 //===----------------------------------------------------------------------===//
10278 for (const auto &Command : Obj->load_commands()) { in printMachOExportsTrie()
10280 MachO::segment_command Seg = Obj->getSegmentLoadCommand(Command); in printMachOExportsTrie()
10286 MachO::segment_command_64 Seg = Obj->getSegment64LoadCommand(Command); in printMachOExportsTrie()
10294 for (const object::ExportEntry &Entry : Obj->exports(Err)) { in printMachOExportsTrie()
10304 outs() << "[re-export] "; in printMachOExportsTrie()
10315 outs() << LS << "per-thread"; in printMachOExportsTrie()
10324 int Ordinal = Entry.other() - 1; in printMachOExportsTrie()
10325 Obj->getLibraryShortNameByIndex(Ordinal, DylibName); in printMachOExportsTrie()
10334 reportError(std::move(Err), Obj->getFileName()); in printMachOExportsTrie()
10337 //===----------------------------------------------------------------------===//
10339 //===----------------------------------------------------------------------===//
10344 for (const object::MachORebaseEntry &Entry : Obj->rebaseTable(Err)) { in printMachORebaseTable()
10350 outs() << format("%-8s %-18s 0x%08" PRIX64 " %s\n", in printMachORebaseTable()
10355 reportError(std::move(Err), Obj->getFileName()); in printMachORebaseTable()
10362 return "this-image"; in ordinalName()
10364 return "main-executable"; in ordinalName()
10366 return "flat-namespace"; in ordinalName()
10372 Obj->getLibraryShortNameByIndex(Ordinal - 1, DylibName); in ordinalName()
10381 //===----------------------------------------------------------------------===//
10383 //===----------------------------------------------------------------------===//
10390 for (const object::MachOBindEntry &Entry : Obj->bindTable(Err)) { in printMachOBindTable()
10409 reportError(std::move(Err), Obj->getFileName()); in printMachOBindTable()
10412 //===----------------------------------------------------------------------===//
10414 //===----------------------------------------------------------------------===//
10420 for (const object::MachOBindEntry &Entry : Obj->lazyBindTable(Err)) { in printMachOLazyBindTable()
10434 reportError(std::move(Err), Obj->getFileName()); in printMachOLazyBindTable()
10437 //===----------------------------------------------------------------------===//
10439 //===----------------------------------------------------------------------===//
10445 for (const object::MachOBindEntry &Entry : Obj->weakBindTable(Err)) { in printMachOWeakBindTable()
10466 reportError(std::move(Err), Obj->getFileName()); in printMachOWeakBindTable()
10470 // address, ReferenceValue, in the Mach-O file and looks in the dyld bind
10475 if (info->bindtable == nullptr) { in get_dyld_bind_info_symbolname()
10476 info->bindtable = std::make_unique<SymbolAddressMap>(); in get_dyld_bind_info_symbolname()
10478 for (const object::MachOBindEntry &Entry : info->O->bindTable(Err)) { in get_dyld_bind_info_symbolname()
10482 (*info->bindtable)[Address] = name; in get_dyld_bind_info_symbolname()
10485 reportError(std::move(Err), info->O->getFileName()); in get_dyld_bind_info_symbolname()
10487 auto name = info->bindtable->lookup(ReferenceValue); in get_dyld_bind_info_symbolname()
10498 "for Mach-O executable files.\n"; in printLazyBindTable()
10508 "for Mach-O executable files.\n"; in printWeakBindTable()
10518 "for Mach-O executable files.\n"; in printExportsTrie()
10528 "for Mach-O executable files.\n"; in printRebaseTable()
10538 "for Mach-O executable files.\n"; in printBindTable()