Index: include/llvm/Object/ELFObjectFile.h =================================================================== --- include/llvm/Object/ELFObjectFile.h +++ include/llvm/Object/ELFObjectFile.h @@ -59,6 +59,7 @@ virtual uint32_t getSectionType(DataRefImpl Sec) const = 0; virtual uint64_t getSectionFlags(DataRefImpl Sec) const = 0; + virtual uint64_t getSectionOffset(DataRefImpl Sec) const = 0; virtual ErrorOr getRelocationAddend(DataRefImpl Rel) const = 0; @@ -90,6 +91,14 @@ uint64_t getFlags() const { return getObject()->getSectionFlags(getRawDataRefImpl()); } + + uint64_t getOffset() const { + return getObject()->getSectionOffset(getRawDataRefImpl()); + } + + static inline bool classof(const SectionRef *v) { + return v->getObject()->isELF(); + } }; class elf_section_iterator : public section_iterator { @@ -245,6 +254,7 @@ uint32_t getSectionType(DataRefImpl Sec) const override; uint64_t getSectionFlags(DataRefImpl Sec) const override; + uint64_t getSectionOffset(DataRefImpl Sec) const override; StringRef getRelocationTypeName(uint32_t Type) const; /// \brief Get the relocation section that contains \a Rel. @@ -381,6 +391,11 @@ } template +uint64_t ELFObjectFile::getSectionOffset(DataRefImpl Sec) const { + return getSection(Sec)->sh_offset; +} + +template uint64_t ELFObjectFile::getSymbolValueImpl(DataRefImpl Symb) const { const Elf_Sym *ESym = getSymbol(Symb); uint64_t Ret = ESym->st_value;