diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index d10c1f60233..e1cbced3fea 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -247,9 +247,6 @@ protected: return *Sec; } - const Elf_Rel *getRel(DataRefImpl Rel) const; - const Elf_Rela *getRela(DataRefImpl Rela) const; - const Elf_Sym *toELFSymIter(DataRefImpl Sym) const { return reinterpret_cast(Sym.p & ~uintptr_t(1)); } @@ -304,6 +301,9 @@ protected: public: ELFObjectFile(MemoryBufferRef Object, std::error_code &EC); + const Elf_Rel *getRel(DataRefImpl Rel) const; + const Elf_Rela *getRela(DataRefImpl Rela) const; + const Elf_Sym *getSymbol(DataRefImpl Symb) const; basic_symbol_iterator symbol_begin_impl() const override; diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 6139cfbea1b..d225d4943ec 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -297,26 +297,15 @@ PrettyPrinter &selectPrettyPrinter(Triple const &Triple) { } } -template -static const typename ELFObjectFile::Elf_Rel * -getRel(const ELFFile &EF, DataRefImpl Rel) { - typedef typename ELFObjectFile::Elf_Rel Elf_Rel; - return EF.template getEntry(Rel.d.a, Rel.d.b); -} - -template -static const typename ELFObjectFile::Elf_Rela * -getRela(const ELFFile &EF, DataRefImpl Rela) { - typedef typename ELFObjectFile::Elf_Rela Elf_Rela; - return EF.template getEntry(Rela.d.a, Rela.d.b); -} - template static std::error_code getRelocationValueString(const ELFObjectFile *Obj, DataRefImpl Rel, SmallVectorImpl &Result) { typedef typename ELFObjectFile::Elf_Sym Elf_Sym; typedef typename ELFObjectFile::Elf_Shdr Elf_Shdr; + typedef typename ELFObjectFile::Elf_Rel Elf_Rel; + typedef typename ELFObjectFile::Elf_Rela Elf_Rela; + const ELFFile &EF = *Obj->getELFFile(); ErrorOr SecOrErr = EF.getSection(Rel.d.a); @@ -344,15 +333,17 @@ static std::error_code getRelocationValueString(const ELFObjectFile *Obj, default: return object_error::parse_failed; case ELF::SHT_REL: { - type = getRel(EF, Rel)->getType(EF.isMips64EL()); - symbol_index = getRel(EF, Rel)->getSymbol(EF.isMips64EL()); + const Elf_Rel *ERel = Obj->getRel(Rel); + type = ERel->getType(EF.isMips64EL()); + symbol_index = ERel->getSymbol(EF.isMips64EL()); // TODO: Read implicit addend from section data. break; } case ELF::SHT_RELA: { - type = getRela(EF, Rel)->getType(EF.isMips64EL()); - symbol_index = getRela(EF, Rel)->getSymbol(EF.isMips64EL()); - addend = getRela(EF, Rel)->r_addend; + const Elf_Rela *ERela = Obj->getRela(Rel); + type = ERela->getType(EF.isMips64EL()); + symbol_index = ERela->getSymbol(EF.isMips64EL()); + addend = ERela->r_addend; break; } }