Make getOther ELF only.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 26 Jun 2015 11:39:57 +0000 (11:39 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 26 Jun 2015 11:39:57 +0000 (11:39 +0000)
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
include/llvm/Object/ObjectFile.h
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

index d78949cb505f84b8562cef698c5c7447809bb82b..4f3157e167326e3e1200afe32b541936a011068d 100644 (file)
@@ -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<int64_t> 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<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
 }
 
 template <class ELFT>
-std::error_code ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb,
-                                                    uint8_t &Result) const {
-  Result = toELFSymIter(Symb)->st_other;
-  return std::error_code();
+uint8_t ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const {
+  return toELFSymIter(Symb)->st_other;
 }
 
 template <class ELFT>
index 60186554a1fca105eabd49d91113d0050383cdc8..ed7113e4d4f61731c5828c02dc5ca25339c71799 100644 (file)
@@ -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<ObjectFile>(O);
index 54a1df9dd5556dfd101aefd4d4fb1c019086077b..5f288f18e67c6dd4f1f12adde1e82783686591e1 100644 (file)
@@ -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;