]> granicus.if.org Git - llvm/commitdiff
Simplify getSection. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 2 Nov 2016 12:49:55 +0000 (12:49 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 2 Nov 2016 12:49:55 +0000 (12:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285803 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/ELF.h

index 3e0802e48557c6949e905daefb61019e358222c3..4c3dc2ae809f7cf616a0ec4fe8f61841c001e40a 100644 (file)
@@ -415,11 +415,10 @@ ELFFile<ELFT>::getSection(uint32_t Index) const {
   if (Index >= getNumSections())
     return object_error::invalid_section_index;
 
-  const uint8_t *Addr = reinterpret_cast<const uint8_t *>(SectionHeaderTable) +
-                        (Index * Header->e_shentsize);
-  if (Addr >= base() + getBufSize())
+  const Elf_Shdr *Addr = SectionHeaderTable + Index;
+  if (reinterpret_cast<const uint8_t *>(Addr) >= base() + getBufSize())
     return object_error::invalid_section_index;
-  return reinterpret_cast<const Elf_Shdr *>(Addr);
+  return Addr;
 }
 
 template <class ELFT>