From 951469b2328f66378344f7b110a7bc1035b16ef6 Mon Sep 17 00:00:00 2001 From: Eugene Leviant Date: Mon, 31 Oct 2016 11:03:01 +0000 Subject: [PATCH] Add getOffset to ELFSectionRef Differential revision: https://reviews.llvm.org/D26074 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285558 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFObjectFile.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index a023d5b3295..93b84a8d069 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -59,6 +59,7 @@ protected: 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,10 @@ public: uint64_t getFlags() const { return getObject()->getSectionFlags(getRawDataRefImpl()); } + + uint64_t getOffset() const { + return getObject()->getSectionOffset(getRawDataRefImpl()); + } }; class elf_section_iterator : public section_iterator { @@ -245,6 +250,7 @@ protected: 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. @@ -380,6 +386,11 @@ uint32_t ELFObjectFile::getSectionType(DataRefImpl Sec) const { return getSection(Sec)->sh_type; } +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); -- 2.40.0