From 993db8494ba829e18fd115d311744d1fe9d0fa93 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 2 Nov 2016 12:49:55 +0000 Subject: [PATCH] Simplify getSection. NFC. llvm-svn: 285803 --- 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