Index: llvm/tools/llvm-readobj/ARMEHABIPrinter.h =================================================================== --- llvm/tools/llvm-readobj/ARMEHABIPrinter.h +++ llvm/tools/llvm-readobj/ARMEHABIPrinter.h @@ -373,7 +373,8 @@ reportError(StrTableOrErr.takeError(), FileName); StringRef StrTable = *StrTableOrErr; - for (const Elf_Sym &Sym : unwrapOrError(FileName, ELF->symbols(Symtab))) + for (const Elf_Sym &Sym : + unwrapOrError_DEPRECATED(FileName, ELF->symbols(Symtab))) if (Sym.st_shndx == Section && Sym.st_value == Address && Sym.getType() == ELF::STT_FUNC) { auto NameOrErr = Sym.getName(StrTable); @@ -399,7 +400,7 @@ /// handling table. Use this symbol to recover the actual exception handling /// table. - for (const Elf_Shdr &Sec : unwrapOrError(FileName, ELF->sections())) { + for (const Elf_Shdr &Sec : unwrapOrError_DEPRECATED(FileName, ELF->sections())) { if (Sec.sh_type != ELF::SHT_REL || Sec.sh_info != IndexSectionIndex) continue; @@ -408,7 +409,7 @@ reportError(SymTabOrErr.takeError(), FileName); const Elf_Shdr *SymTab = *SymTabOrErr; - for (const Elf_Rel &R : unwrapOrError(FileName, ELF->rels(&Sec))) { + for (const Elf_Rel &R : unwrapOrError_DEPRECATED(FileName, ELF->rels(&Sec))) { if (R.r_offset != static_cast(IndexTableOffset)) continue; @@ -418,7 +419,7 @@ RelA.r_addend = 0; const Elf_Sym *Symbol = - unwrapOrError(FileName, ELF->getRelocationSymbol(&RelA, SymTab)); + unwrapOrError_DEPRECATED(FileName, ELF->getRelocationSymbol(&RelA, SymTab)); auto Ret = ELF->getSection(Symbol, SymTab, ShndxTable); if (!Ret) @@ -571,7 +572,7 @@ DictScope UI(SW, "UnwindInformation"); int SectionIndex = 0; - for (const Elf_Shdr &Sec : unwrapOrError(FileName, ELF->sections())) { + for (const Elf_Shdr &Sec : unwrapOrError_DEPRECATED(FileName, ELF->sections())) { if (Sec.sh_type == ELF::SHT_ARM_EXIDX) { DictScope UIT(SW, "UnwindIndexTable"); Index: llvm/tools/llvm-readobj/COFFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/COFFDumper.cpp +++ llvm/tools/llvm-readobj/COFFDumper.cpp @@ -890,14 +890,14 @@ void COFFDumper::printCodeViewDebugInfo() { // Print types first to build CVUDTNames, then print symbols. for (const SectionRef &S : Obj->sections()) { - StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName()); + StringRef SectionName = unwrapOrError_DEPRECATED(Obj->getFileName(), S.getName()); // .debug$T is a standard CodeView type section, while .debug$P is the same // format but used for MSVC precompiled header object files. if (SectionName == ".debug$T" || SectionName == ".debug$P") printCodeViewTypeSection(SectionName, S); } for (const SectionRef &S : Obj->sections()) { - StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName()); + StringRef SectionName = unwrapOrError_DEPRECATED(Obj->getFileName(), S.getName()); if (SectionName == ".debug$S") printCodeViewSymbolSection(SectionName, S); } @@ -942,7 +942,7 @@ void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, const SectionRef &Section) { StringRef SectionContents = - unwrapOrError(Obj->getFileName(), Section.getContents()); + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getContents()); StringRef Data = SectionContents; SmallVector FunctionNames; @@ -1066,7 +1066,7 @@ // To find the active frame description, search this array for the // smallest PC range that includes the current PC. for (const auto &FD : FrameData) { - StringRef FrameFunc = unwrapOrError( + StringRef FrameFunc = unwrapOrError_DEPRECATED( Obj->getFileName(), CVStringTable.getString(FD.FrameFunc)); DictScope S(W, "FrameData"); @@ -1190,7 +1190,7 @@ for (auto &FC : Checksums) { DictScope S(W, "FileChecksum"); - StringRef Filename = unwrapOrError( + StringRef Filename = unwrapOrError_DEPRECATED( Obj->getFileName(), CVStringTable.getString(FC.FileNameOffset)); W.printHex("Filename", Filename, FC.FileNameOffset); W.printHex("ChecksumSize", FC.Checksum.size()); @@ -1236,7 +1236,7 @@ reportError(errorCodeToError(object_error::parse_failed), Obj->getFileName()); - return unwrapOrError(Obj->getFileName(), + return unwrapOrError_DEPRECATED(Obj->getFileName(), CVStringTable.getString(Iter->FileNameOffset)); } @@ -1250,9 +1250,11 @@ GlobalTypeTableBuilder &GlobalCVTypes, bool GHash) { for (const SectionRef &S : Obj->sections()) { - StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName()); + StringRef SectionName = + unwrapOrError_DEPRECATED(Obj->getFileName(), S.getName()); if (SectionName == ".debug$T") { - StringRef Data = unwrapOrError(Obj->getFileName(), S.getContents()); + StringRef Data = + unwrapOrError_DEPRECATED(Obj->getFileName(), S.getContents()); uint32_t Magic; if (Error E = consume(Data, Magic)) reportError(std::move(E), Obj->getFileName()); @@ -1292,7 +1294,7 @@ ListScope D(W, "CodeViewTypes"); W.printNumber("Section", SectionName, Obj->getSectionID(Section)); - StringRef Data = unwrapOrError(Obj->getFileName(), Section.getContents()); + StringRef Data = unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getContents()); if (opts::CodeViewSubsectionBytes) W.printBinaryBlock("Data", Data); @@ -1321,7 +1323,7 @@ ++SectionNumber; const coff_section *Section = Obj->getCOFFSection(Sec); - StringRef Name = unwrapOrError(Obj->getFileName(), Sec.getName()); + StringRef Name = unwrapOrError_DEPRECATED(Obj->getFileName(), Sec.getName()); DictScope D(W, "Section"); W.printNumber("Number", SectionNumber); @@ -1356,7 +1358,8 @@ if (opts::SectionData && !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) { - StringRef Data = unwrapOrError(Obj->getFileName(), Sec.getContents()); + StringRef Data = + unwrapOrError_DEPRECATED(Obj->getFileName(), Sec.getContents()); W.printBinaryBlock("SectionData", Data); } } @@ -1368,7 +1371,7 @@ int SectionNumber = 0; for (const SectionRef &Section : Obj->sections()) { ++SectionNumber; - StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName()); + StringRef Name = unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); bool PrintedGroup = false; for (const RelocationRef &Reloc : Section.relocations()) { @@ -1718,12 +1721,13 @@ void COFFDumper::printCOFFDirectives() { for (const SectionRef &Section : Obj->sections()) { - StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName()); + StringRef Name = + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); if (Name != ".drectve") continue; StringRef Contents = - unwrapOrError(Obj->getFileName(), Section.getContents()); + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getContents()); W.printString("Directive(s)", Contents); } } @@ -1759,18 +1763,19 @@ void COFFDumper::printCOFFResources() { ListScope ResourcesD(W, "Resources"); for (const SectionRef &S : Obj->sections()) { - StringRef Name = unwrapOrError(Obj->getFileName(), S.getName()); + StringRef Name = unwrapOrError_DEPRECATED(Obj->getFileName(), S.getName()); if (!Name.startswith(".rsrc")) continue; - StringRef Ref = unwrapOrError(Obj->getFileName(), S.getContents()); + StringRef Ref = unwrapOrError_DEPRECATED(Obj->getFileName(), S.getContents()); if ((Name == ".rsrc") || (Name == ".rsrc$01")) { ResourceSectionRef RSF; Error E = RSF.load(Obj, S); if (E) reportError(std::move(E), Obj->getFileName()); - auto &BaseTable = unwrapOrError(Obj->getFileName(), RSF.getBaseTable()); + auto &BaseTable = + unwrapOrError_DEPRECATED(Obj->getFileName(), RSF.getBaseTable()); W.printNumber("Total Number of Resources", countTotalTableEntries(RSF, BaseTable, "Type")); W.printHex("Base Table Address", @@ -1790,15 +1795,16 @@ uint32_t TotalEntries = 0; for (int i = 0; i < Table.NumberOfNameEntries + Table.NumberOfIDEntries; i++) { - auto Entry = unwrapOrError(Obj->getFileName(), RSF.getTableEntry(Table, i)); + auto Entry = unwrapOrError_DEPRECATED(Obj->getFileName(), + RSF.getTableEntry(Table, i)); if (Entry.Offset.isSubDir()) { StringRef NextLevel; if (Level == "Name") NextLevel = "Language"; else NextLevel = "Name"; - auto &NextTable = - unwrapOrError(Obj->getFileName(), RSF.getEntrySubDir(Entry)); + auto &NextTable = unwrapOrError_DEPRECATED(Obj->getFileName(), + RSF.getEntrySubDir(Entry)); TotalEntries += countTotalTableEntries(RSF, NextTable, NextLevel); } else { TotalEntries += 1; @@ -1817,13 +1823,14 @@ // Iterate through level in resource directory tree. for (int i = 0; i < Table.NumberOfNameEntries + Table.NumberOfIDEntries; i++) { - auto Entry = unwrapOrError(Obj->getFileName(), RSF.getTableEntry(Table, i)); + auto Entry = unwrapOrError_DEPRECATED(Obj->getFileName(), + RSF.getTableEntry(Table, i)); StringRef Name; SmallString<20> IDStr; raw_svector_ostream OS(IDStr); if (i < Table.NumberOfNameEntries) { - ArrayRef RawEntryNameString = - unwrapOrError(Obj->getFileName(), RSF.getEntryNameString(Entry)); + ArrayRef RawEntryNameString = unwrapOrError_DEPRECATED( + Obj->getFileName(), RSF.getEntryNameString(Entry)); std::vector EndianCorrectedNameString; if (llvm::sys::IsBigEndianHost) { EndianCorrectedNameString.resize(RawEntryNameString.size() + 1); @@ -1855,8 +1862,8 @@ NextLevel = "Language"; else NextLevel = "Name"; - auto &NextTable = - unwrapOrError(Obj->getFileName(), RSF.getEntrySubDir(Entry)); + auto &NextTable = unwrapOrError_DEPRECATED(Obj->getFileName(), + RSF.getEntrySubDir(Entry)); printResourceDirectoryTable(RSF, NextTable, NextLevel); } else { W.printHex("Entry Offset", Entry.Offset.value()); @@ -1869,13 +1876,13 @@ W.printNumber("Characteristics", Table.Characteristics); ListScope DataScope(W, "Data"); auto &DataEntry = - unwrapOrError(Obj->getFileName(), RSF.getEntryData(Entry)); + unwrapOrError_DEPRECATED(Obj->getFileName(), RSF.getEntryData(Entry)); W.printHex("DataRVA", DataEntry.DataRVA); W.printNumber("DataSize", DataEntry.DataSize); W.printNumber("Codepage", DataEntry.Codepage); W.printNumber("Reserved", DataEntry.Reserved); StringRef Contents = - unwrapOrError(Obj->getFileName(), RSF.getContents(DataEntry)); + unwrapOrError_DEPRECATED(Obj->getFileName(), RSF.getContents(DataEntry)); W.printBinaryBlock("Data", Contents); } } @@ -1900,7 +1907,7 @@ return; StringRef StackMapContents = - unwrapOrError(Obj->getFileName(), StackMapSection.getContents()); + unwrapOrError_DEPRECATED(Obj->getFileName(), StackMapSection.getContents()); ArrayRef StackMapContentsArray = arrayRefFromStringRef(StackMapContents); @@ -1931,7 +1938,7 @@ return; StringRef AddrsigContents = - unwrapOrError(Obj->getFileName(), AddrsigSection.getContents()); + unwrapOrError_DEPRECATED(Obj->getFileName(), AddrsigSection.getContents()); ArrayRef AddrsigContentsArray(AddrsigContents.bytes_begin(), AddrsigContents.size()); Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -669,11 +669,11 @@ } else { if (!DotSymtabSec) return; - StrTable = unwrapOrError(ObjF->getFileName(), + StrTable = unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->getStringTableForSymtab(*DotSymtabSec)); - Syms = unwrapOrError(ObjF->getFileName(), Obj->symbols(DotSymtabSec)); + Syms = unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->symbols(DotSymtabSec)); SymtabName = - unwrapOrError(ObjF->getFileName(), Obj->getSectionName(DotSymtabSec)); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->getSectionName(DotSymtabSec)); Entries = DotSymtabSec->getEntityCount(); } if (Syms.begin() == Syms.end()) @@ -1044,7 +1044,7 @@ sizeof(Elf_Sym); // Get the corresponding version index entry. - const Elf_Versym *Versym = unwrapOrError( + const Elf_Versym *Versym = unwrapOrError_DEPRECATED( ObjF->getFileName(), ObjF->getELFFile()->template getEntry( SymbolVersionSection, EntryIndex)); return this->getSymbolVersionByIndex(Versym->vs_index, IsDefault); @@ -1105,10 +1105,10 @@ StringRef StrTable, bool IsDynamic) const { std::string SymbolName = maybeDemangle( - unwrapOrError(ObjF->getFileName(), Symbol->getName(StrTable))); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Symbol->getName(StrTable))); if (SymbolName.empty() && Symbol->getType() == ELF::STT_SECTION) { - Elf_Sym_Range Syms = unwrapOrError( + Elf_Sym_Range Syms = unwrapOrError_DEPRECATED( ObjF->getFileName(), ObjF->getELFFile()->symbols(DotSymtabSec)); Expected SectionIndex = getSymbolSectionIndex(Symbol, Syms.begin()); @@ -1185,7 +1185,7 @@ static const typename ELFO::Elf_Shdr * findNotEmptySectionByAddress(const ELFO *Obj, StringRef FileName, uint64_t Addr) { - for (const auto &Shdr : unwrapOrError(FileName, Obj->sections())) + for (const auto &Shdr : unwrapOrError_DEPRECATED(FileName, Obj->sections())) if (Shdr.sh_addr == Addr && Shdr.sh_size > 0) return &Shdr; return nullptr; @@ -1194,8 +1194,8 @@ template static const typename ELFO::Elf_Shdr * findSectionByName(const ELFO &Obj, StringRef FileName, StringRef Name) { - for (const auto &Shdr : unwrapOrError(FileName, Obj.sections())) - if (Name == unwrapOrError(FileName, Obj.getSectionName(&Shdr))) + for (const auto &Shdr : unwrapOrError_DEPRECATED(FileName, Obj.sections())) + if (Name == unwrapOrError_DEPRECATED(FileName, Obj.getSectionName(&Shdr))) return &Shdr; return nullptr; } @@ -1802,7 +1802,7 @@ // Try to locate the PT_DYNAMIC header. const Elf_Phdr *DynamicPhdr = nullptr; for (const Elf_Phdr &Phdr : - unwrapOrError(ObjF->getFileName(), Obj->program_headers())) { + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->program_headers())) { if (Phdr.p_type != ELF::PT_DYNAMIC) continue; DynamicPhdr = &Phdr; @@ -1812,7 +1812,7 @@ // Try to locate the .dynamic section in the sections header table. const Elf_Shdr *DynamicSec = nullptr; for (const Elf_Shdr &Sec : - unwrapOrError(ObjF->getFileName(), Obj->sections())) { + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->sections())) { if (Sec.sh_type != ELF::SHT_DYNAMIC) continue; DynamicSec = &Sec; @@ -1831,7 +1831,7 @@ if (DynamicPhdr && DynamicSec) { StringRef Name = - unwrapOrError(ObjF->getFileName(), Obj->getSectionName(DynamicSec)); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->getSectionName(DynamicSec)); if (DynamicSec->sh_addr + DynamicSec->sh_size > DynamicPhdr->p_vaddr + DynamicPhdr->p_memsz || DynamicSec->sh_addr < DynamicPhdr->p_vaddr) @@ -1944,7 +1944,7 @@ DynamicTable(ObjF->getFileName()) { const ELFFile *Obj = ObjF->getELFFile(); typename ELFT::ShdrRange Sections = - unwrapOrError(ObjF->getFileName(), Obj->sections()); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->sections()); for (const Elf_Shdr &Sec : Sections) { switch (Sec.sh_type) { case ELF::SHT_SYMTAB: @@ -1958,8 +1958,8 @@ ("section with index " + Twine(&Sec - &Sections.front())).str(); // This is only used (if Elf_Shdr present)for naming section in GNU // style - DynSymtabName = - unwrapOrError(ObjF->getFileName(), Obj->getSectionName(&Sec)); + DynSymtabName = unwrapOrError_DEPRECATED(ObjF->getFileName(), + Obj->getSectionName(&Sec)); if (Expected E = Obj->getStringTableForSymtab(Sec)) DynamicStringTable = *E; @@ -1968,7 +1968,8 @@ } break; case ELF::SHT_SYMTAB_SHNDX: - ShndxTable = unwrapOrError(ObjF->getFileName(), Obj->getSHNDXTable(Sec)); + ShndxTable = unwrapOrError_DEPRECATED(ObjF->getFileName(), + Obj->getSHNDXTable(Sec)); break; case ELF::SHT_GNU_versym: if (!SymbolVersionSection) @@ -2624,12 +2625,12 @@ DictScope BA(W, "BuildAttributes"); for (const ELFO::Elf_Shdr &Sec : - unwrapOrError(ObjF->getFileName(), Obj->sections())) { + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->sections())) { if (Sec.sh_type != ELF::SHT_ARM_ATTRIBUTES) continue; ArrayRef Contents = - unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(&Sec)); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->getSectionContents(&Sec)); if (Contents[0] != ARMBuildAttrs::Format_Version) { errs() << "unrecognised FormatVersion: 0x" << Twine::utohexstr(Contents[0]) << '\n'; @@ -2717,7 +2718,7 @@ return; ArrayRef Content = - unwrapOrError(FileName, Obj->getSectionContents(GotSec)); + unwrapOrError_DEPRECATED(FileName, Obj->getSectionContents(GotSec)); GotEntries = Entries(reinterpret_cast(Content.data()), Content.size() / sizeof(Entry)); LocalNum = GotEntries.size(); @@ -2775,7 +2776,7 @@ GlobalNum = DynSymTotal - *DtGotSym; ArrayRef Content = - unwrapOrError(FileName, Obj->getSectionContents(GotSec)); + unwrapOrError_DEPRECATED(FileName, Obj->getSectionContents(GotSec)); GotEntries = Entries(reinterpret_cast(Content.data()), Content.size() / sizeof(Entry)); GotDynSyms = DynSyms.drop_front(*DtGotSym); @@ -2799,13 +2800,13 @@ Twine::utohexstr(*DtJmpRel)); ArrayRef PltContent = - unwrapOrError(FileName, Obj->getSectionContents(PltSec)); + unwrapOrError_DEPRECATED(FileName, Obj->getSectionContents(PltSec)); PltEntries = Entries(reinterpret_cast(PltContent.data()), PltContent.size() / sizeof(Entry)); - PltSymTable = unwrapOrError(FileName, Obj->getSection(PltRelSec->sh_link)); + PltSymTable = unwrapOrError_DEPRECATED(FileName, Obj->getSection(PltRelSec->sh_link)); PltStrTable = - unwrapOrError(FileName, Obj->getStringTableForSymtab(*PltSymTable)); + unwrapOrError_DEPRECATED(FileName, Obj->getStringTableForSymtab(*PltSymTable)); } } @@ -2906,12 +2907,12 @@ MipsGOTParser::getPltSym(const Entry *E) const { int64_t Offset = std::distance(getPltEntries().data(), E); if (PltRelSec->sh_type == ELF::SHT_REL) { - Elf_Rel_Range Rels = unwrapOrError(FileName, Obj->rels(PltRelSec)); - return unwrapOrError(FileName, + Elf_Rel_Range Rels = unwrapOrError_DEPRECATED(FileName, Obj->rels(PltRelSec)); + return unwrapOrError_DEPRECATED(FileName, Obj->getRelocationSymbol(&Rels[Offset], PltSymTable)); } else { - Elf_Rela_Range Rels = unwrapOrError(FileName, Obj->relas(PltRelSec)); - return unwrapOrError(FileName, + Elf_Rela_Range Rels = unwrapOrError_DEPRECATED(FileName, Obj->relas(PltRelSec)); + return unwrapOrError_DEPRECATED(FileName, Obj->getRelocationSymbol(&Rels[Offset], PltSymTable)); } } @@ -3008,7 +3009,7 @@ return; } ArrayRef Sec = - unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr)); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->getSectionContents(Shdr)); if (Sec.size() != sizeof(Elf_Mips_RegInfo)) { W.startLine() << "The .reginfo section has a wrong size.\n"; return; @@ -3031,7 +3032,7 @@ DictScope GS(W, "MIPS Options"); ArrayRef Sec = - unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr)); + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->getSectionContents(Shdr)); while (!Sec.empty()) { if (Sec.size() < sizeof(Elf_Mips_Options)) { W.startLine() << "The .MIPS.options section has a wrong size.\n"; @@ -3054,9 +3055,10 @@ template void ELFDumper::printStackMap() const { const ELFFile *Obj = ObjF->getELFFile(); const Elf_Shdr *StackMapSection = nullptr; - for (const auto &Sec : unwrapOrError(ObjF->getFileName(), Obj->sections())) { - StringRef Name = - unwrapOrError(ObjF->getFileName(), Obj->getSectionName(&Sec)); + for (const auto &Sec : + unwrapOrError_DEPRECATED(ObjF->getFileName(), Obj->sections())) { + StringRef Name = unwrapOrError_DEPRECATED(ObjF->getFileName(), + Obj->getSectionName(&Sec)); if (Name == ".llvm_stackmaps") { StackMapSection = &Sec; break; @@ -3066,7 +3068,7 @@ if (!StackMapSection) return; - ArrayRef StackMapContentsArray = unwrapOrError( + ArrayRef StackMapContentsArray = unwrapOrError_DEPRECATED( ObjF->getFileName(), Obj->getSectionContents(StackMapSection)); prettyPrintStackMap( @@ -3097,7 +3099,7 @@ if (ElfHeader->e_shnum != 0) return to_string(ElfHeader->e_shnum); - ArrayRef Arr = unwrapOrError(FileName, Obj->sections()); + ArrayRef Arr = unwrapOrError_DEPRECATED(FileName, Obj->sections()); if (Arr.empty()) return "0"; return "0 (" + to_string(Arr[0].sh_size) + ")"; @@ -3110,7 +3112,7 @@ if (ElfHeader->e_shstrndx != SHN_XINDEX) return to_string(ElfHeader->e_shstrndx); - ArrayRef Arr = unwrapOrError(FileName, Obj->sections()); + ArrayRef Arr = unwrapOrError_DEPRECATED(FileName, Obj->sections()); if (Arr.empty()) return "65535 (corrupt: out of range)"; return to_string(ElfHeader->e_shstrndx) + " (" + to_string(Arr[0].sh_link) + @@ -3204,21 +3206,21 @@ std::vector Ret; uint64_t I = 0; - for (const Elf_Shdr &Sec : unwrapOrError(FileName, Obj->sections())) { + for (const Elf_Shdr &Sec : unwrapOrError_DEPRECATED(FileName, Obj->sections())) { ++I; if (Sec.sh_type != ELF::SHT_GROUP) continue; const Elf_Shdr *Symtab = - unwrapOrError(FileName, Obj->getSection(Sec.sh_link)); + unwrapOrError_DEPRECATED(FileName, Obj->getSection(Sec.sh_link)); StringRef StrTable = - unwrapOrError(FileName, Obj->getStringTableForSymtab(*Symtab)); - const Elf_Sym *Sym = unwrapOrError( + unwrapOrError_DEPRECATED(FileName, Obj->getStringTableForSymtab(*Symtab)); + const Elf_Sym *Sym = unwrapOrError_DEPRECATED( FileName, Obj->template getEntry(Symtab, Sec.sh_info)); - auto Data = unwrapOrError( + auto Data = unwrapOrError_DEPRECATED( FileName, Obj->template getSectionContentsAsArray(&Sec)); - StringRef Name = unwrapOrError(FileName, Obj->getSectionName(&Sec)); + StringRef Name = unwrapOrError_DEPRECATED(FileName, Obj->getSectionName(&Sec)); StringRef Signature = StrTable.data() + Sym->st_name; Ret.push_back({Name, maybeDemangle(Signature), @@ -3231,8 +3233,8 @@ std::vector &GM = Ret.back().Members; for (uint32_t Ndx : Data.slice(1)) { - auto Sec = unwrapOrError(FileName, Obj->getSection(Ndx)); - const StringRef Name = unwrapOrError(FileName, Obj->getSectionName(Sec)); + auto Sec = unwrapOrError_DEPRECATED(FileName, Obj->getSection(Ndx)); + const StringRef Name = unwrapOrError_DEPRECATED(FileName, Obj->getSectionName(Sec)); GM.push_back({Name, Ndx}); } } @@ -3282,17 +3284,17 @@ void GNUStyle::printRelocation(const ELFO *Obj, const Elf_Shdr *SymTab, const Elf_Rela &R, bool IsRela) { const Elf_Sym *Sym = - unwrapOrError(this->FileName, Obj->getRelocationSymbol(&R, SymTab)); + unwrapOrError_DEPRECATED(this->FileName, Obj->getRelocationSymbol(&R, SymTab)); std::string TargetName; if (Sym && Sym->getType() == ELF::STT_SECTION) { - const Elf_Shdr *Sec = unwrapOrError( + const Elf_Shdr *Sec = unwrapOrError_DEPRECATED( this->FileName, Obj->getSection(Sym, SymTab, this->dumper()->getShndxTable())); TargetName = - std::string(unwrapOrError(this->FileName, Obj->getSectionName(Sec))); + std::string(unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(Sec))); } else if (Sym) { StringRef StrTable = - unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*SymTab)); + unwrapOrError_DEPRECATED(this->FileName, Obj->getStringTableForSymtab(*SymTab)); TargetName = this->dumper()->getFullSymbolName( Sym, StrTable, SymTab->sh_type == SHT_DYNSYM /* IsDynamic */); } @@ -3361,21 +3363,21 @@ template void GNUStyle::printRelocations(const ELFO *Obj) { bool HasRelocSections = false; - for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) { + for (const Elf_Shdr &Sec : unwrapOrError_DEPRECATED(this->FileName, Obj->sections())) { if (Sec.sh_type != ELF::SHT_REL && Sec.sh_type != ELF::SHT_RELA && Sec.sh_type != ELF::SHT_RELR && Sec.sh_type != ELF::SHT_ANDROID_REL && Sec.sh_type != ELF::SHT_ANDROID_RELA && Sec.sh_type != ELF::SHT_ANDROID_RELR) continue; HasRelocSections = true; - StringRef Name = unwrapOrError(this->FileName, Obj->getSectionName(&Sec)); + StringRef Name = unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(&Sec)); unsigned Entries = Sec.getEntityCount(); std::vector AndroidRelas; if (Sec.sh_type == ELF::SHT_ANDROID_REL || Sec.sh_type == ELF::SHT_ANDROID_RELA) { // Android's packed relocation section needs to be unpacked first // to get the actual number of entries. - AndroidRelas = unwrapOrError(this->FileName, Obj->android_relas(&Sec)); + AndroidRelas = unwrapOrError_DEPRECATED(this->FileName, Obj->android_relas(&Sec)); Entries = AndroidRelas.size(); } std::vector RelrRelas; @@ -3383,8 +3385,8 @@ Sec.sh_type == ELF::SHT_ANDROID_RELR)) { // .relr.dyn relative relocation section needs to be unpacked first // to get the actual number of entries. - Elf_Relr_Range Relrs = unwrapOrError(this->FileName, Obj->relrs(&Sec)); - RelrRelas = unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); + Elf_Relr_Range Relrs = unwrapOrError_DEPRECATED(this->FileName, Obj->relrs(&Sec)); + RelrRelas = unwrapOrError_DEPRECATED(this->FileName, Obj->decode_relrs(Relrs)); Entries = RelrRelas.size(); } uintX_t Offset = Sec.sh_offset; @@ -3393,10 +3395,11 @@ << " entries:\n"; printRelocHeader(Sec.sh_type); const Elf_Shdr *SymTab = - unwrapOrError(this->FileName, Obj->getSection(Sec.sh_link)); + unwrapOrError_DEPRECATED(this->FileName, Obj->getSection(Sec.sh_link)); switch (Sec.sh_type) { case ELF::SHT_REL: - for (const auto &R : unwrapOrError(this->FileName, Obj->rels(&Sec))) { + for (const auto &R : + unwrapOrError_DEPRECATED(this->FileName, Obj->rels(&Sec))) { Elf_Rela Rela; Rela.r_offset = R.r_offset; Rela.r_info = R.r_info; @@ -3405,13 +3408,15 @@ } break; case ELF::SHT_RELA: - for (const auto &R : unwrapOrError(this->FileName, Obj->relas(&Sec))) + for (const auto &R : + unwrapOrError_DEPRECATED(this->FileName, Obj->relas(&Sec))) printRelocation(Obj, SymTab, R, true); break; case ELF::SHT_RELR: case ELF::SHT_ANDROID_RELR: if (opts::RawRelr) - for (const auto &R : unwrapOrError(this->FileName, Obj->relrs(&Sec))) + for (const auto &R : + unwrapOrError_DEPRECATED(this->FileName, Obj->relrs(&Sec))) OS << to_string(format_hex_no_prefix(R, ELFT::Is64Bits ? 16 : 8)) << "\n"; else @@ -3578,7 +3583,8 @@ template void GNUStyle::printSectionHeaders(const ELFO *Obj) { unsigned Bias = ELFT::Is64Bits ? 0 : 8; - ArrayRef Sections = unwrapOrError(this->FileName, Obj->sections()); + ArrayRef Sections = + unwrapOrError_DEPRECATED(this->FileName, Obj->sections()); OS << "There are " << to_string(Sections.size()) << " section headers, starting at offset " << "0x" << to_hexString(Obj->getHeader()->e_shoff, false) << ":\n\n"; @@ -3593,7 +3599,7 @@ OS << "\n"; const ELFObjectFile *ElfObj = this->dumper()->getElfObject(); - StringRef SecStrTable = unwrapOrError( + StringRef SecStrTable = unwrapOrError_DEPRECATED( ElfObj->getFileName(), Obj->getSectionStringTable(Sections, this->WarningHandler)); size_t SectionIndex = 0; @@ -3602,7 +3608,7 @@ if (SecStrTable.empty()) Fields[1].Str = ""; else - Fields[1].Str = std::string(unwrapOrError( + Fields[1].Str = std::string(unwrapOrError_DEPRECATED( ElfObj->getFileName(), Obj->getSectionName(&Sec, SecStrTable))); Fields[2].Str = getSectionTypeString(Obj->getHeader()->e_machine, Sec.sh_type); @@ -3957,7 +3963,7 @@ unsigned Width = ELFT::Is64Bits ? 18 : 10; unsigned SizeWidth = ELFT::Is64Bits ? 8 : 7; for (const auto &Phdr : - unwrapOrError(this->FileName, Obj->program_headers())) { + unwrapOrError_DEPRECATED(this->FileName, Obj->program_headers())) { Fields[0].Str = getElfPtType(Header->e_machine, Phdr.p_type); Fields[1].Str = to_string(format_hex(Phdr.p_offset, 8)); Fields[2].Str = to_string(format_hex(Phdr.p_vaddr, Width)); @@ -3982,10 +3988,11 @@ DenseSet BelongsToSegment; int Phnum = 0; for (const Elf_Phdr &Phdr : - unwrapOrError(this->FileName, Obj->program_headers())) { + unwrapOrError_DEPRECATED(this->FileName, Obj->program_headers())) { std::string Sections; OS << format(" %2.2d ", Phnum++); - for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) { + for (const Elf_Shdr &Sec : + unwrapOrError_DEPRECATED(this->FileName, Obj->sections())) { // Check if each section is in a segment and then print mapping. // readelf additionally makes sure it does not print zero sized sections // at end of segments and for PT_DYNAMIC both start and end of section @@ -3997,7 +4004,7 @@ checkoffsets(Phdr, Sec) && checkVMA(Phdr, Sec) && checkPTDynamic(Phdr, Sec) && (Sec.sh_type != ELF::SHT_NULL)) { Sections += - unwrapOrError(this->FileName, Obj->getSectionName(&Sec)).str() + + unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(&Sec)).str() + " "; BelongsToSegment.insert(&Sec); } @@ -4008,10 +4015,10 @@ // Display sections that do not belong to a segment. std::string Sections; - for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) { + for (const Elf_Shdr &Sec : unwrapOrError_DEPRECATED(this->FileName, Obj->sections())) { if (BelongsToSegment.find(&Sec) == BelongsToSegment.end()) Sections += - unwrapOrError(this->FileName, Obj->getSectionName(&Sec)).str() + ' '; + unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(&Sec)).str() + ' '; } if (!Sections.empty()) { OS << " None " << Sections << '\n'; @@ -4152,7 +4159,7 @@ printRelocHeader(ELF::SHT_REL); Elf_Relr_Range Relrs = this->dumper()->dyn_relrs(); std::vector RelrRelas = - unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); + unwrapOrError_DEPRECATED(this->FileName, Obj->decode_relrs(Relrs)); for (const Elf_Rela &Rela : RelrRelas) { printDynamicRelocation(Obj, Rela, false); } @@ -4184,7 +4191,7 @@ void GNUStyle::printGNUVersionSectionProlog( const ELFFile *Obj, const typename ELFT::Shdr *Sec, const Twine &Label, unsigned EntriesNum) { - StringRef SecName = unwrapOrError(this->FileName, Obj->getSectionName(Sec)); + StringRef SecName = unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(Sec)); OS << Label << " section '" << SecName << "' " << "contains " << EntriesNum << " entries:\n"; @@ -4195,7 +4202,7 @@ Obj->getSection(Sec->sh_link); if (SymTabOrErr) SymTabName = - unwrapOrError(this->FileName, Obj->getSectionName(*SymTabOrErr)); + unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(*SymTabOrErr)); else this->reportUniqueWarning( createError("invalid section linked to " + @@ -5058,7 +5065,7 @@ } }; - ArrayRef Sections = unwrapOrError(this->FileName, Obj->sections()); + ArrayRef Sections = unwrapOrError_DEPRECATED(this->FileName, Obj->sections()); if (Obj->getHeader()->e_type != ELF::ET_CORE && !Sections.empty()) { for (const auto &S : Sections) { if (S.sh_type != SHT_NOTE) @@ -5072,7 +5079,7 @@ } } else { for (const auto &P : - unwrapOrError(this->FileName, Obj->program_headers())) { + unwrapOrError_DEPRECATED(this->FileName, Obj->program_headers())) { if (P.p_type != PT_NOTE) continue; PrintHeader(P.p_offset, P.p_filesz); @@ -5239,13 +5246,13 @@ PrintHeader(); const Elf_Shdr *ElfSec = Obj->getSection(Sec.getRawDataRefImpl()); ArrayRef Contents = - unwrapOrError(this->FileName, EF->getSectionContents(ElfSec)); + unwrapOrError_DEPRECATED(this->FileName, EF->getSectionContents(ElfSec)); DataExtractor Data(Contents, Obj->isLittleEndian(), sizeof(Elf_Addr)); // A .stack_sizes section header's sh_link field is supposed to point // to the section that contains the functions whose stack sizes are // described in it. const Elf_Shdr *FunctionELFSec = - unwrapOrError(this->FileName, EF->getSection(ElfSec->sh_link)); + unwrapOrError_DEPRECATED(this->FileName, EF->getSection(ElfSec->sh_link)); uint64_t Offset = 0; while (Offset < Contents.size()) { // The function address is followed by a ULEB representing the stack @@ -5339,13 +5346,13 @@ // described in it. const Elf_Shdr *StackSizesELFSec = Obj->getSection(StackSizesSec.getRawDataRefImpl()); - const SectionRef FunctionSec = Obj->toSectionRef(unwrapOrError( + const SectionRef FunctionSec = Obj->toSectionRef(unwrapOrError_DEPRECATED( this->FileName, EF->getSection(StackSizesELFSec->sh_link))); bool (*IsSupportedFn)(uint64_t); RelocationResolver Resolver; std::tie(IsSupportedFn, Resolver) = getRelocationResolver(*Obj); - auto Contents = unwrapOrError(this->FileName, StackSizesSec.getContents()); + auto Contents = unwrapOrError_DEPRECATED(this->FileName, StackSizesSec.getContents()); DataExtractor Data(Contents, Obj->isLittleEndian(), sizeof(Elf_Addr)); for (const RelocationRef &Reloc : RelocSec.relocations()) { if (!IsSupportedFn || !IsSupportedFn(Reloc.getType())) @@ -5514,8 +5521,8 @@ if (!Shdr) return; - ArrayRef Sec = - unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr)); + ArrayRef Sec = unwrapOrError_DEPRECATED( + ObjF->getFileName(), Obj->getSectionContents(Shdr)); if (Sec.size() != sizeof(Elf_Mips_ABIFlags)) reportError(createError(".MIPS.abiflags section has a wrong size"), ObjF->getFileName()); @@ -5643,7 +5650,8 @@ ListScope D(W, "Relocations"); int SectionNumber = -1; - for (const Elf_Shdr &Sec : unwrapOrError(this->FileName, Obj->sections())) { + for (const Elf_Shdr &Sec : + unwrapOrError_DEPRECATED(this->FileName, Obj->sections())) { ++SectionNumber; if (Sec.sh_type != ELF::SHT_REL && Sec.sh_type != ELF::SHT_RELA && @@ -5652,7 +5660,8 @@ Sec.sh_type != ELF::SHT_ANDROID_RELR) continue; - StringRef Name = unwrapOrError(this->FileName, Obj->getSectionName(&Sec)); + StringRef Name = + unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(&Sec)); W.startLine() << "Section (" << SectionNumber << ") " << Name << " {\n"; W.indent(); @@ -5667,11 +5676,12 @@ template void LLVMStyle::printRelocations(const Elf_Shdr *Sec, const ELFO *Obj) { const Elf_Shdr *SymTab = - unwrapOrError(this->FileName, Obj->getSection(Sec->sh_link)); + unwrapOrError_DEPRECATED(this->FileName, Obj->getSection(Sec->sh_link)); switch (Sec->sh_type) { case ELF::SHT_REL: - for (const Elf_Rel &R : unwrapOrError(this->FileName, Obj->rels(Sec))) { + for (const Elf_Rel &R : + unwrapOrError_DEPRECATED(this->FileName, Obj->rels(Sec))) { Elf_Rela Rela; Rela.r_offset = R.r_offset; Rela.r_info = R.r_info; @@ -5680,18 +5690,20 @@ } break; case ELF::SHT_RELA: - for (const Elf_Rela &R : unwrapOrError(this->FileName, Obj->relas(Sec))) + for (const Elf_Rela &R : + unwrapOrError_DEPRECATED(this->FileName, Obj->relas(Sec))) printRelocation(Obj, R, SymTab); break; case ELF::SHT_RELR: case ELF::SHT_ANDROID_RELR: { - Elf_Relr_Range Relrs = unwrapOrError(this->FileName, Obj->relrs(Sec)); + Elf_Relr_Range Relrs = + unwrapOrError_DEPRECATED(this->FileName, Obj->relrs(Sec)); if (opts::RawRelr) { for (const Elf_Relr &R : Relrs) W.startLine() << W.hex(R) << "\n"; } else { std::vector RelrRelas = - unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); + unwrapOrError_DEPRECATED(this->FileName, Obj->decode_relrs(Relrs)); for (const Elf_Rela &R : RelrRelas) printRelocation(Obj, R, SymTab); } @@ -5700,7 +5712,7 @@ case ELF::SHT_ANDROID_REL: case ELF::SHT_ANDROID_RELA: for (const Elf_Rela &R : - unwrapOrError(this->FileName, Obj->android_relas(Sec))) + unwrapOrError_DEPRECATED(this->FileName, Obj->android_relas(Sec))) printRelocation(Obj, R, SymTab); break; } @@ -5712,17 +5724,17 @@ SmallString<32> RelocName; Obj->getRelocationTypeName(Rel.getType(Obj->isMips64EL()), RelocName); std::string TargetName; - const Elf_Sym *Sym = - unwrapOrError(this->FileName, Obj->getRelocationSymbol(&Rel, SymTab)); + const Elf_Sym *Sym = unwrapOrError_DEPRECATED( + this->FileName, Obj->getRelocationSymbol(&Rel, SymTab)); if (Sym && Sym->getType() == ELF::STT_SECTION) { - const Elf_Shdr *Sec = unwrapOrError( + const Elf_Shdr *Sec = unwrapOrError_DEPRECATED( this->FileName, Obj->getSection(Sym, SymTab, this->dumper()->getShndxTable())); - TargetName = - std::string(unwrapOrError(this->FileName, Obj->getSectionName(Sec))); + TargetName = std::string( + unwrapOrError_DEPRECATED(this->FileName, Obj->getSectionName(Sec))); } else if (Sym) { - StringRef StrTable = - unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*SymTab)); + StringRef StrTable = unwrapOrError_DEPRECATED( + this->FileName, Obj->getStringTableForSymtab(*SymTab)); TargetName = this->dumper()->getFullSymbolName( Sym, StrTable, SymTab->sh_type == SHT_DYNSYM /* IsDynamic */); } @@ -5747,7 +5759,8 @@ ListScope SectionsD(W, "Sections"); int SectionIndex = -1; - ArrayRef Sections = unwrapOrError(this->FileName, Obj->sections()); + ArrayRef Sections = + unwrapOrError_DEPRECATED(this->FileName, Obj->sections()); std::vector> FlagsList = getSectionFlagsForTarget(Obj->getHeader()->e_machine); for (const Elf_Shdr &Sec : Sections) { @@ -5782,25 +5795,26 @@ if (opts::SectionSymbols) { ListScope D(W, "Symbols"); const Elf_Shdr *Symtab = this->dumper()->getDotSymtabSec(); - StringRef StrTable = - unwrapOrError(this->FileName, Obj->getStringTableForSymtab(*Symtab)); + StringRef StrTable = unwrapOrError_DEPRECATED( + this->FileName, Obj->getStringTableForSymtab(*Symtab)); for (const Elf_Sym &Sym : - unwrapOrError(this->FileName, Obj->symbols(Symtab))) { - const Elf_Shdr *SymSec = unwrapOrError( + unwrapOrError_DEPRECATED(this->FileName, Obj->symbols(Symtab))) { + const Elf_Shdr *SymSec = unwrapOrError_DEPRECATED( this->FileName, Obj->getSection(&Sym, Symtab, this->dumper()->getShndxTable())); if (SymSec == &Sec) printSymbol( Obj, &Sym, - unwrapOrError(this->FileName, Obj->symbols(Symtab)).begin(), + unwrapOrError_DEPRECATED(this->FileName, Obj->symbols(Symtab)) + .begin(), StrTable, false, false); } } if (opts::SectionData && Sec.sh_type != ELF::SHT_NOBITS) { - ArrayRef Data = - unwrapOrError(this->FileName, Obj->getSectionContents(&Sec)); + ArrayRef Data = unwrapOrError_DEPRECATED( + this->FileName, Obj->getSectionContents(&Sec)); W.printBinaryBlock( "SectionData", StringRef(reinterpret_cast(Data.data()), Data.size())); @@ -5948,7 +5962,7 @@ if (DynRelrRegion.Size > 0) { Elf_Relr_Range Relrs = this->dumper()->dyn_relrs(); std::vector RelrRelas = - unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); + unwrapOrError_DEPRECATED(this->FileName, Obj->decode_relrs(Relrs)); for (const Elf_Rela &Rela : RelrRelas) printDynamicRelocation(Obj, Rela); } @@ -6003,7 +6017,7 @@ ListScope L(W, "ProgramHeaders"); for (const Elf_Phdr &Phdr : - unwrapOrError(this->FileName, Obj->program_headers())) { + unwrapOrError_DEPRECATED(this->FileName, Obj->program_headers())) { DictScope P(W, "ProgramHeader"); W.printHex("Type", getElfSegmentType(Obj->getHeader()->e_machine, Phdr.p_type), @@ -6112,20 +6126,20 @@ ListScope L(W, "CGProfile"); if (!this->dumper()->getDotCGProfileSec()) return; - auto CGProfile = unwrapOrError( + auto CGProfile = unwrapOrError_DEPRECATED( this->FileName, Obj->template getSectionContentsAsArray( this->dumper()->getDotCGProfileSec())); for (const Elf_CGProfile &CGPE : CGProfile) { DictScope D(W, "CGProfileEntry"); W.printNumber( "From", - unwrapOrError(this->FileName, - this->dumper()->getStaticSymbolName(CGPE.cgp_from)), + unwrapOrError_DEPRECATED( + this->FileName, this->dumper()->getStaticSymbolName(CGPE.cgp_from)), CGPE.cgp_from); W.printNumber( "To", - unwrapOrError(this->FileName, - this->dumper()->getStaticSymbolName(CGPE.cgp_to)), + unwrapOrError_DEPRECATED( + this->FileName, this->dumper()->getStaticSymbolName(CGPE.cgp_to)), CGPE.cgp_to); W.printNumber("Weight", CGPE.cgp_weight); } @@ -6151,7 +6165,7 @@ ListScope L(W, "Addrsig"); if (!this->dumper()->getDotAddrsigSec()) return; - ArrayRef Contents = unwrapOrError( + ArrayRef Contents = unwrapOrError_DEPRECATED( this->FileName, Obj->getSectionContents(this->dumper()->getDotAddrsigSec())); Expected> V = toULEB128Array(Contents); @@ -6279,7 +6293,8 @@ } }; - ArrayRef Sections = unwrapOrError(this->FileName, Obj->sections()); + ArrayRef Sections = + unwrapOrError_DEPRECATED(this->FileName, Obj->sections()); if (Obj->getHeader()->e_type != ELF::ET_CORE && !Sections.empty()) { for (const auto &S : Sections) { if (S.sh_type != SHT_NOTE) @@ -6294,7 +6309,7 @@ } } else { for (const auto &P : - unwrapOrError(this->FileName, Obj->program_headers())) { + unwrapOrError_DEPRECATED(this->FileName, Obj->program_headers())) { if (P.p_type != PT_NOTE) continue; DictScope D(W, "NoteSection"); @@ -6313,13 +6328,14 @@ ListScope L(W, "LinkerOptions"); unsigned I = -1; - for (const Elf_Shdr &Shdr : unwrapOrError(this->FileName, Obj->sections())) { + for (const Elf_Shdr &Shdr : + unwrapOrError_DEPRECATED(this->FileName, Obj->sections())) { ++I; if (Shdr.sh_type != ELF::SHT_LLVM_LINKER_OPTIONS) continue; - ArrayRef Contents = - unwrapOrError(this->FileName, Obj->getSectionContents(&Shdr)); + ArrayRef Contents = unwrapOrError_DEPRECATED( + this->FileName, Obj->getSectionContents(&Shdr)); if (Contents.empty()) continue; @@ -6361,7 +6377,8 @@ }; unsigned I = -1; - for (const Elf_Shdr &Shdr : unwrapOrError(this->FileName, Obj->sections())) { + for (const Elf_Shdr &Shdr : + unwrapOrError_DEPRECATED(this->FileName, Obj->sections())) { ++I; if (Shdr.sh_type != ELF::SHT_LLVM_DEPENDENT_LIBRARIES) continue; @@ -6510,8 +6527,8 @@ W.startLine() << "There is no .MIPS.abiflags section in the file.\n"; return; } - ArrayRef Sec = - unwrapOrError(ObjF->getFileName(), Obj->getSectionContents(Shdr)); + ArrayRef Sec = unwrapOrError_DEPRECATED( + ObjF->getFileName(), Obj->getSectionContents(Shdr)); if (Sec.size() != sizeof(Elf_Mips_ABIFlags)) { W.startLine() << "The .MIPS.abiflags section has a wrong size.\n"; return; Index: llvm/tools/llvm-readobj/MachODumper.cpp =================================================================== --- llvm/tools/llvm-readobj/MachODumper.cpp +++ llvm/tools/llvm-readobj/MachODumper.cpp @@ -465,7 +465,7 @@ MachOSection MOSection; getSection(Obj, Section.getRawDataRefImpl(), MOSection); DataRefImpl DR = Section.getRawDataRefImpl(); - StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName()); + StringRef Name = unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); ArrayRef RawName = Obj->getSectionRawName(DR); StringRef SegmentName = Obj->getSectionFinalSegmentName(DR); ArrayRef RawSegmentName = Obj->getSectionRawFinalSegmentName(DR); @@ -506,8 +506,9 @@ } if (opts::SectionData && !Section.isBSS()) - W.printBinaryBlock("SectionData", unwrapOrError(Obj->getFileName(), - Section.getContents())); + W.printBinaryBlock( + "SectionData", + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getContents())); } } @@ -516,7 +517,8 @@ std::error_code EC; for (const SectionRef &Section : Obj->sections()) { - StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName()); + StringRef Name = + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); bool PrintedGroup = false; for (const RelocationRef &Reloc : Section.relocations()) { if (!PrintedGroup) { @@ -562,7 +564,8 @@ } else if (!IsScattered) { section_iterator SecI = Obj->getRelocationSection(DR); if (SecI != Obj->section_end()) - TargetName = unwrapOrError(Obj->getFileName(), SecI->getName()); + TargetName = + unwrapOrError_DEPRECATED(Obj->getFileName(), SecI->getName()); } if (TargetName.empty()) TargetName = "-"; @@ -635,7 +638,7 @@ section_iterator SecI = *SecIOrErr; if (SecI != Obj->section_end()) - SectionName = unwrapOrError(Obj->getFileName(), SecI->getName()); + SectionName = unwrapOrError_DEPRECATED(Obj->getFileName(), SecI->getName()); DictScope D(W, "Symbol"); W.printNumber("Name", SymbolName, MOSymbol.StringIndex); @@ -679,8 +682,8 @@ if (StackMapSection == object::SectionRef()) return; - StringRef StackMapContents = - unwrapOrError(Obj->getFileName(), StackMapSection.getContents()); + StringRef StackMapContents = unwrapOrError_DEPRECATED( + Obj->getFileName(), StackMapSection.getContents()); ArrayRef StackMapContentsArray = arrayRefFromStringRef(StackMapContents); Index: llvm/tools/llvm-readobj/ObjDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ObjDumper.cpp +++ llvm/tools/llvm-readobj/ObjDumper.cpp @@ -53,7 +53,7 @@ SecIndex = Obj->isELF() ? 0 : 1; for (object::SectionRef SecRef : Obj->sections()) { - StringRef SecName = unwrapOrError(Obj->getFileName(), SecRef.getName()); + StringRef SecName = unwrapOrError_DEPRECATED(Obj->getFileName(), SecRef.getName()); auto NameIt = SecNames.find(std::string(SecName)); if (NameIt != SecNames.end()) NameIt->second = true; @@ -86,7 +86,7 @@ for (object::SectionRef Section : getSectionRefsByNameOrIndex(Obj, Sections)) { StringRef SectionName = - unwrapOrError(Obj->getFileName(), Section.getName()); + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); if (!First) W.startLine() << '\n'; @@ -94,7 +94,7 @@ W.startLine() << "String dump of section '" << SectionName << "':\n"; StringRef SectionContent = - unwrapOrError(Obj->getFileName(), Section.getContents()); + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getContents()); const uint8_t *SecContent = SectionContent.bytes_begin(); const uint8_t *CurrentWord = SecContent; @@ -121,7 +121,7 @@ for (object::SectionRef Section : getSectionRefsByNameOrIndex(Obj, Sections)) { StringRef SectionName = - unwrapOrError(Obj->getFileName(), Section.getName()); + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); if (!First) W.startLine() << '\n'; @@ -129,7 +129,7 @@ W.startLine() << "Hex dump of section '" << SectionName << "':\n"; StringRef SectionContent = - unwrapOrError(Obj->getFileName(), Section.getContents()); + unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getContents()); const uint8_t *SecContent = SectionContent.bytes_begin(); const uint8_t *SecEnd = SecContent + SectionContent.size(); Index: llvm/tools/llvm-readobj/WasmDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/WasmDumper.cpp +++ llvm/tools/llvm-readobj/WasmDumper.cpp @@ -91,7 +91,7 @@ StringRef SymName; symbol_iterator SI = Reloc.getSymbol(); if (SI != Obj->symbol_end()) - SymName = unwrapOrError(Obj->getFileName(), SI->getName()); + SymName = unwrapOrError_DEPRECATED(Obj->getFileName(), SI->getName()); bool HasAddend = false; switch (RelocType) { @@ -134,7 +134,7 @@ int SectionNumber = 0; for (const SectionRef &Section : Obj->sections()) { bool PrintedGroup = false; - StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName()); + StringRef Name = unwrapOrError_DEPRECATED(Obj->getFileName(), Section.getName()); ++SectionNumber; Index: llvm/tools/llvm-readobj/XCOFFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/XCOFFDumper.cpp +++ llvm/tools/llvm-readobj/XCOFFDumper.cpp @@ -139,14 +139,15 @@ if (Sec.Flags != XCOFF::STYP_TEXT && Sec.Flags != XCOFF::STYP_DATA && Sec.Flags != XCOFF::STYP_TDATA && Sec.Flags != XCOFF::STYP_DWARF) continue; - auto Relocations = unwrapOrError(Obj.getFileName(), Obj.relocations(Sec)); + auto Relocations = + unwrapOrError_DEPRECATED(Obj.getFileName(), Obj.relocations(Sec)); if (Relocations.empty()) continue; W.startLine() << "Section (index: " << Index << ") " << Sec.getName() << " {\n"; for (auto Reloc : Relocations) { - StringRef SymbolName = unwrapOrError( + StringRef SymbolName = unwrapOrError_DEPRECATED( Obj.getFileName(), Obj.getSymbolNameByIndex(Reloc.SymbolIndex)); DictScope RelocScope(W, "Relocation"); @@ -175,7 +176,7 @@ report_fatal_error( "Printing for File Auxiliary Entry in 64-bit is unimplemented."); StringRef FileName = - unwrapOrError(Obj.getFileName(), Obj.getCFileName(AuxEntPtr)); + unwrapOrError_DEPRECATED(Obj.getFileName(), Obj.getCFileName(AuxEntPtr)); DictScope SymDs(W, "File Auxiliary Entry"); W.printNumber("Index", Obj.getSymbolIndex(reinterpret_cast(AuxEntPtr))); @@ -321,7 +322,7 @@ DictScope SymDs(W, "Symbol"); StringRef SymbolName = - unwrapOrError(Obj.getFileName(), Obj.getSymbolName(SymbolDRI)); + unwrapOrError_DEPRECATED(Obj.getFileName(), Obj.getSymbolName(SymbolDRI)); W.printNumber("Index", Obj.getSymbolIndex(reinterpret_cast(SymbolEntPtr))); @@ -330,7 +331,7 @@ SymbolEntPtr->Value); StringRef SectionName = - unwrapOrError(Obj.getFileName(), Obj.getSymbolSectionName(SymbolEntPtr)); + unwrapOrError_DEPRECATED(Obj.getFileName(), Obj.getSymbolSectionName(SymbolEntPtr)); W.printString("Section", SectionName); if (XCOFFSymRef.getStorageClass() == XCOFF::C_FILE) { Index: llvm/tools/llvm-readobj/llvm-readobj.h =================================================================== --- llvm/tools/llvm-readobj/llvm-readobj.h +++ llvm/tools/llvm-readobj/llvm-readobj.h @@ -24,7 +24,8 @@ LLVM_ATTRIBUTE_NORETURN void reportError(Error Err, StringRef Input); void reportWarning(Error Err, StringRef Input); - template T unwrapOrError(StringRef Input, Expected EO) { + template + T unwrapOrError_DEPRECATED(StringRef Input, Expected EO) { if (EO) return *EO; reportError(EO.takeError(), Input);