Implement elf_section_iterator and getELFType().
[oota-llvm.git] / include / llvm / Object / ELFObjectFile.h
index 60a9f70f6abc479af9c252e6c1173b63bde75ccc..011b2c5d1b6a257ccd0c7f846dba7b83b536c4c0 100644 (file)
@@ -47,6 +47,8 @@ protected:
 
   virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0;
   virtual uint8_t getSymbolOther(DataRefImpl Symb) const = 0;
+  virtual uint8_t getSymbolELFType(DataRefImpl Symb) const = 0;
+
   virtual uint32_t getSectionType(DataRefImpl Sec) const = 0;
   virtual uint64_t getSectionFlags(DataRefImpl Sec) const = 0;
 
@@ -84,6 +86,21 @@ public:
   }
 };
 
+class elf_section_iterator : public section_iterator {
+public:
+  elf_section_iterator(const section_iterator &B) : section_iterator(B) {
+    assert(isa<ELFObjectFileBase>(B->getObject()));
+  }
+
+  const ELFSectionRef *operator->() const {
+    return static_cast<const ELFSectionRef *>(section_iterator::operator->());
+  }
+
+  const ELFSectionRef &operator*() const {
+    return static_cast<const ELFSectionRef &>(section_iterator::operator*());
+  }
+};
+
 class ELFSymbolRef : public SymbolRef {
 public:
   ELFSymbolRef(const SymbolRef &B) : SymbolRef(B) {
@@ -101,6 +118,10 @@ public:
   uint8_t getOther() const {
     return getObject()->getSymbolOther(getRawDataRefImpl());
   }
+
+  uint8_t getELFType() const {
+    return getObject()->getSymbolELFType(getRawDataRefImpl());
+  }
 };
 
 class elf_symbol_iterator : public symbol_iterator {
@@ -155,6 +176,7 @@ protected:
   uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
   uint32_t getSymbolFlags(DataRefImpl Symb) const override;
   uint8_t getSymbolOther(DataRefImpl Symb) const override;
+  uint8_t getSymbolELFType(DataRefImpl Symb) const override;
   SymbolRef::Type getSymbolType(DataRefImpl Symb) const override;
   section_iterator getSymbolSection(const Elf_Sym *Symb) const;
   std::error_code getSymbolSection(DataRefImpl Symb,
@@ -404,6 +426,11 @@ uint8_t ELFObjectFile<ELFT>::getSymbolOther(DataRefImpl Symb) const {
   return toELFSymIter(Symb)->st_other;
 }
 
+template <class ELFT>
+uint8_t ELFObjectFile<ELFT>::getSymbolELFType(DataRefImpl Symb) const {
+  return toELFSymIter(Symb)->getType();
+}
+
 template <class ELFT>
 SymbolRef::Type ELFObjectFile<ELFT>::getSymbolType(DataRefImpl Symb) const {
   const Elf_Sym *ESym = getSymbol(Symb);