[llvm] r285558 - Add getOffset to ELFSectionRef

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 04:03:03 PDT 2016


Author: evgeny777
Date: Mon Oct 31 06:03:01 2016
New Revision: 285558

URL: http://llvm.org/viewvc/llvm-project?rev=285558&view=rev
Log:
Add getOffset to ELFSectionRef

Differential revision: https://reviews.llvm.org/D26074

Modified:
    llvm/trunk/include/llvm/Object/ELFObjectFile.h

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=285558&r1=285557&r2=285558&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Mon Oct 31 06:03:01 2016
@@ -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<int64_t> 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.
@@ -381,6 +387,11 @@ uint32_t ELFObjectFile<ELFT>::getSection
 }
 
 template <class ELFT>
+uint64_t ELFObjectFile<ELFT>::getSectionOffset(DataRefImpl Sec) const {
+  return getSection(Sec)->sh_offset;
+}
+
+template <class ELFT>
 uint64_t ELFObjectFile<ELFT>::getSymbolValueImpl(DataRefImpl Symb) const {
   const Elf_Sym *ESym = getSymbol(Symb);
   uint64_t Ret = ESym->st_value;




More information about the llvm-commits mailing list