summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Object/ELF.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index 3e0802e4855..4c3dc2ae809 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -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>
OpenPOWER on IntegriCloud