[llvm] r285803 - Simplify getSection. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 2 05:49:56 PDT 2016
Author: rafael
Date: Wed Nov 2 07:49:55 2016
New Revision: 285803
URL: http://llvm.org/viewvc/llvm-project?rev=285803&view=rev
Log:
Simplify getSection. NFC.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=285803&r1=285802&r2=285803&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Wed Nov 2 07:49:55 2016
@@ -415,11 +415,10 @@ ELFFile<ELFT>::getSection(uint32_t Index
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>
More information about the llvm-commits
mailing list