From ecd7bde20ca69338433d1be15d0d6122799f3ace Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 2 Nov 2016 12:49:55 +0000 Subject: [PATCH] Simplify getSection. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285803 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 -- 2.40.0