From 6ae5b9e40587f5586e2970ca717797b68c34758d Mon Sep 17 00:00:00 2001 From: Georgii Rymar Date: Wed, 5 Aug 2020 16:30:28 +0300 Subject: [PATCH] [llvm-readobj] - Make decode_relrs() don't return Expected<>. NFCI. The `decode_relrs` helper is declared as: `Expected> decode_relrs(Elf_Relr_Range relrs) const;` it never returns an error though and hence can be simplified to return a vector. Differential revision: https://reviews.llvm.org/D85302 --- llvm/include/llvm/Object/ELF.h | 2 +- llvm/lib/Object/ELF.cpp | 2 +- llvm/tools/llvm-readobj/ELFDumper.cpp | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index 0080d0ba58f3..35d2456f7ce2 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -203,7 +203,7 @@ public: return getSectionContentsAsArray(Sec); } - Expected> decode_relrs(Elf_Relr_Range relrs) const; + std::vector decode_relrs(Elf_Relr_Range relrs) const; Expected> android_relas(const Elf_Shdr *Sec) const; diff --git a/llvm/lib/Object/ELF.cpp b/llvm/lib/Object/ELF.cpp index 7a675944bb44..0e06af92d64b 100644 --- a/llvm/lib/Object/ELF.cpp +++ b/llvm/lib/Object/ELF.cpp @@ -278,7 +278,7 @@ StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) { } template -Expected> +std::vector ELFFile::decode_relrs(Elf_Relr_Range relrs) const { // This function decodes the contents of an SHT_RELR packed relocation // section. diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 78d47b540ab6..54b2d67421d0 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -3779,7 +3779,7 @@ template void GNUStyle::printRelocations(const ELFO *Obj) { } else if (!opts::RawRelr && (Sec.sh_type == ELF::SHT_RELR || Sec.sh_type == ELF::SHT_ANDROID_RELR)) { Elf_Relr_Range Relrs = unwrapOrError(this->FileName, Obj->relrs(&Sec)); - Entries = unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)).size(); + Entries = Obj->decode_relrs(Relrs).size(); } else { Entries = Sec.getEntityCount(); } @@ -4507,9 +4507,7 @@ void GNUStyle::printDynamicRelocations(const ELFO *Obj) { << " contains " << DynRelrRegion.Size << " bytes:\n"; printRelocHeader(ELF::SHT_REL); Elf_Relr_Range Relrs = this->dumper()->dyn_relrs(); - std::vector RelrRels = - unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); - for (const Elf_Rel &R : RelrRels) + for (const Elf_Rel &R : Obj->decode_relrs(Relrs)) printDynamicRelocation(Obj, R); } if (DynPLTRelRegion.Size) { @@ -5533,9 +5531,8 @@ void DumpStyle::printRelocationsHelper(const ELFFile *Obj, printRelrReloc(R); break; } - std::vector RelrRels = - unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); - for (const Elf_Rel &R : RelrRels) + + for (const Elf_Rel &R : Obj->decode_relrs(Relrs)) printRelReloc(Obj, SecNdx, SymTab, R, ++RelNdx); break; } @@ -6426,9 +6423,7 @@ void LLVMStyle::printDynamicRelocations(const ELFO *Obj) { if (DynRelrRegion.Size > 0) { Elf_Relr_Range Relrs = this->dumper()->dyn_relrs(); - std::vector RelrRels = - unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); - for (const Elf_Rel &R : RelrRels) + for (const Elf_Rel &R : Obj->decode_relrs(Relrs)) printDynamicRelocation(Obj, R); } if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela))