diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 3e0802e4855..4c3dc2ae809 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -415,11 +415,10 @@ ELFFile::getSection(uint32_t Index) const { if (Index >= getNumSections()) return object_error::invalid_section_index; - const uint8_t *Addr = reinterpret_cast(SectionHeaderTable) + - (Index * Header->e_shentsize); - if (Addr >= base() + getBufSize()) + const Elf_Shdr *Addr = SectionHeaderTable + Index; + if (reinterpret_cast(Addr) >= base() + getBufSize()) return object_error::invalid_section_index; - return reinterpret_cast(Addr); + return Addr; } template