From 3e750a4ebf495d27c0f90bdca4a1737ba475fed6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 26 Jun 2015 11:39:57 +0000 Subject: [PATCH] Make getOther ELF only. No other format has this field. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240774 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFObjectFile.h | 13 ++++++++----- include/llvm/Object/ObjectFile.h | 9 --------- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 5 ++--- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index d78949cb505..4f3157e1673 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -45,6 +45,7 @@ protected: ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source); virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0; + virtual uint8_t getSymbolOther(DataRefImpl Symb) const = 0; public: virtual ErrorOr getRelocationAddend(DataRefImpl Rel) const = 0; @@ -77,6 +78,10 @@ public: uint64_t getSize() const { return getObject()->getSymbolSize(getRawDataRefImpl()); } + + uint8_t getOther() const { + return getObject()->getSymbolOther(getRawDataRefImpl()); + } }; class elf_symbol_iterator : public symbol_iterator { @@ -130,7 +135,7 @@ protected: uint32_t getSymbolAlignment(DataRefImpl Symb) const override; uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override; uint32_t getSymbolFlags(DataRefImpl Symb) const override; - std::error_code getSymbolOther(DataRefImpl Symb, uint8_t &Res) const override; + uint8_t getSymbolOther(DataRefImpl Symb) const override; std::error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const override; section_iterator getSymbolSection(const Elf_Sym *Symb) const; @@ -380,10 +385,8 @@ uint64_t ELFObjectFile::getCommonSymbolSizeImpl(DataRefImpl Symb) const { } template -std::error_code ELFObjectFile::getSymbolOther(DataRefImpl Symb, - uint8_t &Result) const { - Result = toELFSymIter(Symb)->st_other; - return std::error_code(); +uint8_t ELFObjectFile::getSymbolOther(DataRefImpl Symb) const { + return toELFSymIter(Symb)->st_other; } template diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index 60186554a1f..ed7113e4d4f 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -151,7 +151,6 @@ public: uint32_t getAlignment() const; uint64_t getCommonSize() const; std::error_code getType(SymbolRef::Type &Result) const; - std::error_code getOther(uint8_t &Result) const; /// @brief Get section this symbol is defined in reference to. Result is /// end_sections() if it is undefined or is an absolute symbol. @@ -215,10 +214,6 @@ protected: SymbolRef::Type &Res) const = 0; virtual std::error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const = 0; - virtual std::error_code getSymbolOther(DataRefImpl Symb, - uint8_t &Res) const { - return object_error::invalid_file_type; - } // Same as above for SectionRef. friend class SectionRef; @@ -356,10 +351,6 @@ inline std::error_code SymbolRef::getType(SymbolRef::Type &Result) const { return getObject()->getSymbolType(getRawDataRefImpl(), Result); } -inline std::error_code SymbolRef::getOther(uint8_t &Result) const { - return getObject()->getSymbolOther(getRawDataRefImpl(), Result); -} - inline const ObjectFile *SymbolRef::getObject() const { const SymbolicFile *O = BasicSymbolRef::getObject(); return cast(O); diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index 54a1df9dd55..5f288f18e67 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -1066,7 +1066,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef( int64_t Addend = 0; if (Obj.hasRelocationAddend(RelI->getRawDataRefImpl())) Addend = *Obj.getRelocationAddend(RelI->getRawDataRefImpl()); - symbol_iterator Symbol = RelI->getSymbol(); + elf_symbol_iterator Symbol = RelI->getSymbol(); // Obtain the symbol name which is referenced in the relocation StringRef TargetName; @@ -1312,8 +1312,7 @@ relocation_iterator RuntimeDyldELF::processRelocationRef( } else { // In the ELFv2 ABI, a function symbol may provide a local entry // point, which must be used for direct calls. - uint8_t SymOther; - Symbol->getOther(SymOther); + uint8_t SymOther = Symbol->getOther(); Value.Addend += ELF::decodePPC64LocalEntryOffset(SymOther); } uint8_t *RelocTarget = Sections[Value.SectionID].Address + Value.Addend; -- 2.34.1