[llvm-readobj] - Make decode_relrs() don't return Expected<>. NFCI.

The `decode_relrs` helper is declared as:

`Expected<std::vector<Elf_Rel>> 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
This commit is contained in:
Georgii Rymar 2020-08-05 16:30:28 +03:00
parent 5ab43989c3
commit 6ae5b9e405
3 changed files with 7 additions and 12 deletions

View File

@ -203,7 +203,7 @@ public:
return getSectionContentsAsArray<Elf_Relr>(Sec); return getSectionContentsAsArray<Elf_Relr>(Sec);
} }
Expected<std::vector<Elf_Rel>> decode_relrs(Elf_Relr_Range relrs) const; std::vector<Elf_Rel> decode_relrs(Elf_Relr_Range relrs) const;
Expected<std::vector<Elf_Rela>> android_relas(const Elf_Shdr *Sec) const; Expected<std::vector<Elf_Rela>> android_relas(const Elf_Shdr *Sec) const;

View File

@ -278,7 +278,7 @@ StringRef llvm::object::getELFSectionTypeName(uint32_t Machine, unsigned Type) {
} }
template <class ELFT> template <class ELFT>
Expected<std::vector<typename ELFT::Rel>> std::vector<typename ELFT::Rel>
ELFFile<ELFT>::decode_relrs(Elf_Relr_Range relrs) const { ELFFile<ELFT>::decode_relrs(Elf_Relr_Range relrs) const {
// This function decodes the contents of an SHT_RELR packed relocation // This function decodes the contents of an SHT_RELR packed relocation
// section. // section.

View File

@ -3779,7 +3779,7 @@ template <class ELFT> void GNUStyle<ELFT>::printRelocations(const ELFO *Obj) {
} else if (!opts::RawRelr && (Sec.sh_type == ELF::SHT_RELR || } else if (!opts::RawRelr && (Sec.sh_type == ELF::SHT_RELR ||
Sec.sh_type == ELF::SHT_ANDROID_RELR)) { Sec.sh_type == ELF::SHT_ANDROID_RELR)) {
Elf_Relr_Range Relrs = unwrapOrError(this->FileName, Obj->relrs(&Sec)); 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 { } else {
Entries = Sec.getEntityCount(); Entries = Sec.getEntityCount();
} }
@ -4507,9 +4507,7 @@ void GNUStyle<ELFT>::printDynamicRelocations(const ELFO *Obj) {
<< " contains " << DynRelrRegion.Size << " bytes:\n"; << " contains " << DynRelrRegion.Size << " bytes:\n";
printRelocHeader(ELF::SHT_REL); printRelocHeader(ELF::SHT_REL);
Elf_Relr_Range Relrs = this->dumper()->dyn_relrs(); Elf_Relr_Range Relrs = this->dumper()->dyn_relrs();
std::vector<Elf_Rel> RelrRels = for (const Elf_Rel &R : Obj->decode_relrs(Relrs))
unwrapOrError(this->FileName, Obj->decode_relrs(Relrs));
for (const Elf_Rel &R : RelrRels)
printDynamicRelocation(Obj, R); printDynamicRelocation(Obj, R);
} }
if (DynPLTRelRegion.Size) { if (DynPLTRelRegion.Size) {
@ -5533,9 +5531,8 @@ void DumpStyle<ELFT>::printRelocationsHelper(const ELFFile<ELFT> *Obj,
printRelrReloc(R); printRelrReloc(R);
break; break;
} }
std::vector<Elf_Rel> RelrRels =
unwrapOrError(this->FileName, Obj->decode_relrs(Relrs)); for (const Elf_Rel &R : Obj->decode_relrs(Relrs))
for (const Elf_Rel &R : RelrRels)
printRelReloc(Obj, SecNdx, SymTab, R, ++RelNdx); printRelReloc(Obj, SecNdx, SymTab, R, ++RelNdx);
break; break;
} }
@ -6426,9 +6423,7 @@ void LLVMStyle<ELFT>::printDynamicRelocations(const ELFO *Obj) {
if (DynRelrRegion.Size > 0) { if (DynRelrRegion.Size > 0) {
Elf_Relr_Range Relrs = this->dumper()->dyn_relrs(); Elf_Relr_Range Relrs = this->dumper()->dyn_relrs();
std::vector<Elf_Rel> RelrRels = for (const Elf_Rel &R : Obj->decode_relrs(Relrs))
unwrapOrError(this->FileName, Obj->decode_relrs(Relrs));
for (const Elf_Rel &R : RelrRels)
printDynamicRelocation(Obj, R); printDynamicRelocation(Obj, R);
} }
if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela)) if (DynPLTRelRegion.EntSize == sizeof(Elf_Rela))