Lines Matching refs:Obj

378 static Expected<std::unique_ptr<Dumper>> createDumper(const ObjectFile &Obj) {
379 if (const auto *O = dyn_cast<COFFObjectFile>(&Obj))
381 if (const auto *O = dyn_cast<ELFObjectFileBase>(&Obj))
383 if (const auto *O = dyn_cast<MachOObjectFile>(&Obj))
385 if (const auto *O = dyn_cast<WasmObjectFile>(&Obj))
387 if (const auto *O = dyn_cast<XCOFFObjectFile>(&Obj))
513 static const Target *getTarget(const ObjectFile *Obj) {
517 TheTriple = Obj->makeTriple();
520 auto Arch = Obj->getArch();
522 Obj->setARMSubArch(TheTriple);
530 reportError(Obj->getFileName(), "can't find target: " + Error);
544 const ObjectFile *Obj = Rel.getObject();
545 if (auto *ELF = dyn_cast<ELFObjectFileBase>(Obj))
547 if (auto *COFF = dyn_cast<COFFObjectFile>(Obj))
549 if (auto *Wasm = dyn_cast<WasmObjectFile>(Obj))
551 if (auto *MachO = dyn_cast<MachOObjectFile>(Obj))
553 if (auto *XCOFF = dyn_cast<XCOFFObjectFile>(Obj))
621 static bool isAArch64Elf(const ObjectFile &Obj) {
622 const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj);
626 static bool isArmElf(const ObjectFile &Obj) {
627 const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj);
631 static bool isCSKYElf(const ObjectFile &Obj) {
632 const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj);
636 static bool hasMappingSymbols(const ObjectFile &Obj) {
637 return isArmElf(Obj) || isAArch64Elf(Obj) || isCSKYElf(Obj) ;
1035 DisassemblerTarget(const Target *TheTarget, ObjectFile &Obj,
1048 DisassemblerTarget::DisassemblerTarget(const Target *TheTarget, ObjectFile &Obj,
1055 reportError(Obj.getFileName(), "no register info for target " + TripleName);
1060 reportError(Obj.getFileName(), "no assembly info for target " + TripleName);
1065 reportError(Obj.getFileName(),
1069 reportError(Obj.getFileName(),
1082 reportError(Obj.getFileName(), "no disassembler for target " + TripleName);
1084 if (auto *ELFObj = dyn_cast<ELFObjectFileBase>(&Obj))
1094 reportError(Obj.getFileName(),
1128 static uint8_t getElfSymbolType(const ObjectFile &Obj, const SymbolRef &Sym) {
1129 assert(Obj.isELF());
1130 if (auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(&Obj))
1132 Obj.getFileName())
1134 if (auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(&Obj))
1136 Obj.getFileName())
1138 if (auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(&Obj))
1140 Obj.getFileName())
1142 if (auto *Elf64BEObj = cast<ELF64BEObjectFile>(&Obj))
1144 Obj.getFileName())
1151 addDynamicElfSymbols(const ELFObjectFile<ELFT> &Obj,
1153 for (auto Symbol : Obj.getDynamicSymbolIterators()) {
1158 uint64_t Address = unwrapOrError(Symbol.getAddress(), Obj.getFileName());
1162 Address = unwrapOrError(Obj.getSymbol(Symbol.getRawDataRefImpl()),
1163 Obj.getFileName())
1166 StringRef Name = unwrapOrError(Symbol.getName(), Obj.getFileName());
1171 unwrapOrError(Symbol.getSection(), Obj.getFileName());
1172 if (SecI == Obj.section_end())
1180 addDynamicElfSymbols(const ELFObjectFileBase &Obj,
1182 if (auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(&Obj))
1184 else if (auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(&Obj))
1186 else if (auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(&Obj))
1188 else if (auto *Elf64BEObj = cast<ELF64BEObjectFile>(&Obj))
1194 static std::optional<SectionRef> getWasmCodeSection(const WasmObjectFile &Obj) {
1195 for (auto SecI : Obj.sections()) {
1196 const WasmSection &Section = Obj.getWasmSection(SecI);
1204 addMissingWasmCodeSymbols(const WasmObjectFile &Obj,
1206 std::optional<SectionRef> Section = getWasmCodeSection(Obj);
1215 for (const wasm::WasmFunction &Function : Obj.functions()) {
1217 uint32_t Adjustment = Obj.isRelocatableObject() || Obj.isSharedObject()
1235 static void addPltEntries(const ObjectFile &Obj,
1238 auto *ElfObj = dyn_cast<ELFObjectFileBase>(&Obj);
1242 for (SectionRef Section : Obj.sections()) {
1253 uint8_t SymbolType = getElfSymbolType(Obj, Symbol);
1266 Obj.getFileName());
1291 getRelocsMap(object::ObjectFile const &Obj) {
1294 for (SectionRef Sec : Obj.sections()) {
1298 reportError(Obj.getFileName(),
1304 if (Relocated == Obj.section_end() || !checkSectionFilter(*Relocated).Keep)
1320 const ObjectFile *Obj = Section.getObject();
1321 if (Obj->isELF())
1342 uint64_t End, const ObjectFile &Obj,
1347 Obj.isLittleEndian() ? llvm::endianness::little : llvm::endianness::big;
1405 SymbolInfoTy objdump::createSymbolInfo(const ObjectFile &Obj,
1408 const StringRef FileName = Obj.getFileName();
1412 if (Obj.isXCOFF() && (SymbolDescription || TracebackTable)) {
1413 const auto &XCOFFObj = cast<XCOFFObjectFile>(Obj);
1421 } else if (Obj.isXCOFF()) {
1425 } else if (Obj.isWasm()) {
1427 cast<WasmObjectFile>(&Obj)->getWasmSymbol(Symbol).Info.Kind;
1431 Obj.isELF() ? getElfSymbolType(Obj, Symbol) : (uint8_t)ELF::STT_NOTYPE;
1436 static SymbolInfoTy createDummySymbolInfo(const ObjectFile &Obj,
1439 if (Obj.isXCOFF() && (SymbolDescription || TracebackTable))
1441 if (Obj.isWasm())
1623 static void createFakeELFSections(ObjectFile &Obj) {
1624 assert(Obj.isELF());
1625 if (auto *Elf32LEObj = dyn_cast<ELF32LEObjectFile>(&Obj))
1627 else if (auto *Elf64LEObj = dyn_cast<ELF64LEObjectFile>(&Obj))
1629 else if (auto *Elf32BEObj = dyn_cast<ELF32BEObjectFile>(&Obj))
1631 else if (auto *Elf64BEObj = cast<ELF64BEObjectFile>(&Obj))
1640 fetchBinaryByBuildID(const ObjectFile &Obj) {
1641 object::BuildIDRef BuildID = getBuildID(&Obj);
1656 disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
1665 if (isArmElf(Obj)) {
1668 } else if (const auto *COFFObj = dyn_cast<COFFObjectFile>(&Obj)) {
1689 if (InlineRelocs || Obj.isXCOFF())
1690 RelocMap = getRelocsMap(Obj);
1691 bool Is64Bits = Obj.getBytesInAddress() > 4;
1698 const StringRef FileName = Obj.getFileName();
1699 const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(&Obj);
1700 for (const SymbolRef &Symbol : Obj.symbols()) {
1706 if (NameOrErr->empty() && !(Obj.isXCOFF() && SymbolDescription))
1709 if (Obj.isELF() &&
1718 if (getElfSymbolType(Obj, Symbol) != ELF::STT_SECTION &&
1719 hasMappingSymbols(Obj)) {
1721 if (SecI != Obj.section_end()) {
1730 createSymbolInfo(Obj, Symbol, /*MappingSymbol=*/true));
1755 if (SecI != Obj.section_end())
1756 AllSymbols[*SecI].push_back(createSymbolInfo(Obj, Symbol));
1758 AbsoluteSymbols.push_back(createSymbolInfo(Obj, Symbol));
1761 if (AllSymbols.empty() && Obj.isELF())
1762 addDynamicElfSymbols(cast<ELFObjectFileBase>(Obj), AllSymbols);
1764 if (Obj.isWasm())
1765 addMissingWasmCodeSymbols(cast<WasmObjectFile>(Obj), AllSymbols);
1767 if (Obj.isELF() && Obj.sections().empty())
1768 createFakeELFSections(Obj);
1772 addPltEntries(Obj, AllSymbols, Saver);
1779 for (SectionRef Sec : Obj.sections())
1789 if (const auto *COFFObj = dyn_cast<COFFObjectFile>(&Obj)) {
1793 reportError(std::move(E), Obj.getFileName());
1799 reportError(std::move(E), Obj.getFileName());
1837 if (const auto *Elf = dyn_cast<ELFObjectFileBase>(&Obj)) {
1841 reportWarning(toString(BBAddrMapsOrErr.takeError()), Obj.getFileName());
1854 if (SymbolizeOperands && !Obj.isRelocatableObject())
1858 if (InlineRelocs && BTFParser::hasBTFSections(Obj)) {
1863 if (Error E = BTF->parse(Obj, Opts))
1867 for (const SectionRef &Section : ToolSectionFilter(Obj)) {
1879 if (SymbolizeOperands && Obj.isRelocatableObject())
1888 unwrapOrError(Section.getContents(), Obj.getFileName()));
1891 if (Obj.isELF() && Obj.getArch() == Triple::amdgcn) {
1898 StringRef SectionName = unwrapOrError(Section.getName(), Obj.getFileName());
1914 Obj, SectionAddr, SectionName,
1916 if (Obj.isXCOFF())
1932 uint64_t RelAdjustment = Obj.isRelocatableObject() ? 0 : SectionAddr;
1991 if (Obj.isELF() && !DisassembleAll && Section.isText()) {
2079 if (Obj.isXCOFF() && SymbolDescription) {
2168 Obj.isXCOFF() && Section.isText() && TracebackTable &&
2246 Size = dumpARMELFData(SectionAddr, Index, End, Obj, Bytes,
2272 *DT->SubtargetInfo, cast<XCOFFObjectFile>(&Obj));
2310 "", *DT->SubtargetInfo, &SP, Obj.getFileName(), &Rels, LVP);
2354 if (!Obj.isRelocatableObject()) {
2414 if (Obj.isXCOFF() && findRel()) {
2419 if (Obj.is64Bit()) {
2501 if (InlineRelocs && Obj.getArch() != Triple::hexagon) {
2504 if (RelCur->getSymbol() != Obj.symbol_end()) {
2507 if (SymSI && *SymSI != Obj.section_end() &&
2512 printRelocation(FOS, Obj.getFileName(), *RelCur,
2529 static void disassembleObject(ObjectFile *Obj, bool InlineRelocs) {
2533 if (Obj->symbols().empty()) {
2535 fetchBinaryByBuildID(*Obj)) {
2538 (!O->sections().empty() && Obj->sections().empty())) {
2540 Obj = O;
2546 const Target *TheTarget = getTarget(Obj);
2549 Expected<SubtargetFeatures> FeaturesValue = Obj->getFeatures();
2551 reportError(FeaturesValue.takeError(), Obj->getFileName());
2556 } else if (MCPU.empty() && Obj->getArch() == llvm::Triple::aarch64) {
2561 MCPU = Obj->tryGetCPUName().value_or("").str();
2563 if (isArmElf(*Obj)) {
2575 const auto *Elf32BE = dyn_cast<ELF32BEObjectFile>(Obj);
2586 DisassemblerTarget PrimaryTarget(TheTarget, *Obj, TripleName, MCPU, Features);
2594 if (isArmElf(*Obj)) {
2602 } else if (const auto *COFFObj = dyn_cast<COFFObjectFile>(Obj)) {
2614 SecondaryTarget.emplace(X64Target, *Obj, X64Triple.getTriple(), "",
2617 reportWarning(Error, Obj->getFileName());
2622 const ObjectFile *DbgObj = Obj;
2623 if (!FetchedBinary.getBinary() && !Obj->hasDebugInfo()) {
2625 fetchBinaryByBuildID(*Obj)) {
2639 if (const MachOObjectFile *MachOOF = dyn_cast<MachOObjectFile>(&*Obj)) {
2640 DbgObj = objdump::getMachODSymObject(MachOOF, Obj->getFileName(),
2651 reportError(Obj->getFileName(),
2654 disassembleObject(*Obj, *DbgObj, PrimaryTarget, SecondaryTarget, SP,
2722 static bool shouldDisplayLMA(const ObjectFile &Obj) {
2723 if (!Obj.isELF())
2725 for (const SectionRef &S : ToolSectionFilter(Obj))
2731 static size_t getMaxSectionNameWidth(const ObjectFile &Obj) {
2734 for (const SectionRef &Section : ToolSectionFilter(Obj)) {
2735 StringRef Name = unwrapOrError(Section.getName(), Obj.getFileName());
2741 void objdump::printSectionHeaders(ObjectFile &Obj) {
2742 if (Obj.isELF() && Obj.sections().empty())
2743 createFakeELFSections(Obj);
2745 size_t NameWidth = getMaxSectionNameWidth(Obj);
2746 size_t AddressWidth = 2 * Obj.getBytesInAddress();
2747 bool HasLMAColumn = shouldDisplayLMA(Obj);
2758 for (const SectionRef &Section : ToolSectionFilter(Obj, &Idx)) {
2759 StringRef Name = unwrapOrError(Section.getName(), Obj.getFileName());
2787 void objdump::printSectionContents(const ObjectFile *Obj) {
2788 const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj);
2790 for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
2791 StringRef Name = unwrapOrError(Section.getName(), Obj->getFileName());
2809 StringRef Contents = unwrapOrError(Section.getContents(), Obj->getFileName());
3079 static void printRawClangAST(const ObjectFile *Obj) {
3090 if (Obj->isCOFF()) {
3095 for (auto Sec : ToolSectionFilter(*Obj)) {
3111 unwrapOrError(ClangASTSection->getContents(), Obj->getFileName());
3115 static void printFaultMaps(const ObjectFile *Obj) {
3118 if (Obj->isELF()) {
3120 } else if (Obj->isMachO()) {
3131 for (auto Sec : ToolSectionFilter(*Obj)) {
3152 unwrapOrError(FaultMapSection->getContents(), Obj->getFileName());
3225 static bool shouldWarnForInvalidStartStopAddress(ObjectFile *Obj) {
3226 if (const auto *Elf = dyn_cast<ELFObjectFileBase>(Obj)) {
3233 static void checkForInvalidStartStopAddress(ObjectFile *Obj,
3235 if (!shouldWarnForInvalidStartStopAddress(Obj))
3238 for (const SectionRef &Section : Obj->sections())
3249 Obj->getFileName());
3253 Obj->getFileName());
3258 Obj->getFileName());