[PATCH] D26074: [ELF] Add getOffset to ELFSectionRef and enable LLVM casting for it

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rL285558: Add getOffset to ELFSectionRef (authored by evgeny777).

Changed prior to commit:
  https://reviews.llvm.org/D26074?vs=76191&id=76376#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26074

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


Index: llvm/trunk/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h
+++ llvm/trunk/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<int64_t> getRelocationAddend(DataRefImpl Rel) const = 0;
 
@@ -90,6 +91,10 @@
   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 @@
 
   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 @@
 }
 
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26074.76376.patch
Type: text/x-patch
Size: 1466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161031/a5743b43/attachment.bin>


More information about the llvm-commits mailing list