summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h')
-rw-r--r--contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h b/contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
index 59c9b71..903a246 100644
--- a/contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
+++ b/contrib/llvm/tools/llvm-readobj/ARMEHABIPrinter.h
@@ -349,11 +349,12 @@ template <typename ET>
ErrorOr<StringRef>
PrinterContext<ET>::FunctionAtAddress(unsigned Section,
uint64_t Address) const {
- ErrorOr<StringRef> StrTableOrErr = ELF->getStringTableForSymtab(*Symtab);
- error(StrTableOrErr.getError());
+ auto StrTableOrErr = ELF->getStringTableForSymtab(*Symtab);
+ if (!StrTableOrErr)
+ error(StrTableOrErr.takeError());
StringRef StrTable = *StrTableOrErr;
- for (const Elf_Sym &Sym : ELF->symbols(Symtab))
+ for (const Elf_Sym &Sym : unwrapOrError(ELF->symbols(Symtab)))
if (Sym.st_shndx == Section && Sym.st_value == Address &&
Sym.getType() == ELF::STT_FUNC) {
auto NameOrErr = Sym.getName(StrTable);
@@ -379,15 +380,16 @@ PrinterContext<ET>::FindExceptionTable(unsigned IndexSectionIndex,
/// handling table. Use this symbol to recover the actual exception handling
/// table.
- for (const Elf_Shdr &Sec : ELF->sections()) {
+ for (const Elf_Shdr &Sec : unwrapOrError(ELF->sections())) {
if (Sec.sh_type != ELF::SHT_REL || Sec.sh_info != IndexSectionIndex)
continue;
- ErrorOr<const Elf_Shdr *> SymTabOrErr = ELF->getSection(Sec.sh_link);
- error(SymTabOrErr.getError());
+ auto SymTabOrErr = ELF->getSection(Sec.sh_link);
+ if (!SymTabOrErr)
+ error(SymTabOrErr.takeError());
const Elf_Shdr *SymTab = *SymTabOrErr;
- for (const Elf_Rel &R : ELF->rels(&Sec)) {
+ for (const Elf_Rel &R : unwrapOrError(ELF->rels(&Sec))) {
if (R.r_offset != static_cast<unsigned>(IndexTableOffset))
continue;
@@ -396,12 +398,12 @@ PrinterContext<ET>::FindExceptionTable(unsigned IndexSectionIndex,
RelA.r_info = R.r_info;
RelA.r_addend = 0;
- const Elf_Sym *Symbol = ELF->getRelocationSymbol(&RelA, SymTab);
+ const Elf_Sym *Symbol =
+ unwrapOrError(ELF->getRelocationSymbol(&RelA, SymTab));
- ErrorOr<const Elf_Shdr *> Ret =
- ELF->getSection(Symbol, SymTab, ShndxTable);
- if (std::error_code EC = Ret.getError())
- report_fatal_error(EC.message());
+ auto Ret = ELF->getSection(Symbol, SymTab, ShndxTable);
+ if (!Ret)
+ report_fatal_error(errorToErrorCode(Ret.takeError()).message());
return *Ret;
}
}
@@ -412,7 +414,7 @@ template <typename ET>
void PrinterContext<ET>::PrintExceptionTable(const Elf_Shdr *IT,
const Elf_Shdr *EHT,
uint64_t TableEntryOffset) const {
- ErrorOr<ArrayRef<uint8_t> > Contents = ELF->getSectionContents(EHT);
+ Expected<ArrayRef<uint8_t>> Contents = ELF->getSectionContents(EHT);
if (!Contents)
return;
@@ -479,7 +481,7 @@ void PrinterContext<ET>::PrintOpcodes(const uint8_t *Entry,
template <typename ET>
void PrinterContext<ET>::PrintIndexTable(unsigned SectionIndex,
const Elf_Shdr *IT) const {
- ErrorOr<ArrayRef<uint8_t> > Contents = ELF->getSectionContents(IT);
+ Expected<ArrayRef<uint8_t>> Contents = ELF->getSectionContents(IT);
if (!Contents)
return;
@@ -532,7 +534,7 @@ void PrinterContext<ET>::PrintIndexTable(unsigned SectionIndex,
const Elf_Shdr *EHT =
FindExceptionTable(SectionIndex, Entry * IndexTableEntrySize + 4);
- if (ErrorOr<StringRef> Name = ELF->getSectionName(EHT))
+ if (auto Name = ELF->getSectionName(EHT))
SW.printString("ExceptionHandlingTable", *Name);
uint64_t TableEntryOffset = PREL31(Word1, IT->sh_addr);
@@ -548,12 +550,12 @@ void PrinterContext<ET>::PrintUnwindInformation() const {
DictScope UI(SW, "UnwindInformation");
int SectionIndex = 0;
- for (const Elf_Shdr &Sec : ELF->sections()) {
+ for (const Elf_Shdr &Sec : unwrapOrError(ELF->sections())) {
if (Sec.sh_type == ELF::SHT_ARM_EXIDX) {
DictScope UIT(SW, "UnwindIndexTable");
SW.printNumber("SectionIndex", SectionIndex);
- if (ErrorOr<StringRef> SectionName = ELF->getSectionName(&Sec))
+ if (auto SectionName = ELF->getSectionName(&Sec))
SW.printString("SectionName", *SectionName);
SW.printHex("SectionOffset", Sec.sh_offset);
OpenPOWER on IntegriCloud