From 47b7f7863751f66546379cb3e5008ee5d92644b9 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 10 Aug 2015 19:10:37 +0000 Subject: [PATCH] rename toELFShdrIter to getSection and move it closer to getSymbol. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244483 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFObjectFile.h | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 538a031c1ad..ddedf04ee07 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -303,6 +303,10 @@ public: return EF.template getEntry(Sym.d.a, Sym.d.b); } + const Elf_Shdr *getSection(DataRefImpl Sec) const { + return reinterpret_cast(Sec.p); + } + basic_symbol_iterator symbol_begin_impl() const override; basic_symbol_iterator symbol_end_impl() const override; @@ -357,12 +361,12 @@ ErrorOr ELFObjectFile::getSymbolName(DataRefImpl Sym) const { template uint64_t ELFObjectFile::getSectionFlags(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_flags; + return getSection(Sec)->sh_flags; } template uint32_t ELFObjectFile::getSectionType(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_type; + return getSection(Sec)->sh_type; } template @@ -525,14 +529,14 @@ ELFObjectFile::getSymbolSection(DataRefImpl Symb) const { template void ELFObjectFile::moveSectionNext(DataRefImpl &Sec) const { - const Elf_Shdr *ESec = toELFShdrIter(Sec); + const Elf_Shdr *ESec = getSection(Sec); Sec = toDRI(++ESec); } template std::error_code ELFObjectFile::getSectionName(DataRefImpl Sec, StringRef &Result) const { - ErrorOr Name = EF.getSectionName(&*toELFShdrIter(Sec)); + ErrorOr Name = EF.getSectionName(&*getSection(Sec)); if (!Name) return Name.getError(); Result = *Name; @@ -541,50 +545,50 @@ std::error_code ELFObjectFile::getSectionName(DataRefImpl Sec, template uint64_t ELFObjectFile::getSectionAddress(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_addr; + return getSection(Sec)->sh_addr; } template uint64_t ELFObjectFile::getSectionSize(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_size; + return getSection(Sec)->sh_size; } template std::error_code ELFObjectFile::getSectionContents(DataRefImpl Sec, StringRef &Result) const { - const Elf_Shdr *EShdr = toELFShdrIter(Sec); + const Elf_Shdr *EShdr = getSection(Sec); Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size); return std::error_code(); } template uint64_t ELFObjectFile::getSectionAlignment(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_addralign; + return getSection(Sec)->sh_addralign; } template bool ELFObjectFile::isSectionText(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR; + return getSection(Sec)->sh_flags & ELF::SHF_EXECINSTR; } template bool ELFObjectFile::isSectionData(DataRefImpl Sec) const { - const Elf_Shdr *EShdr = toELFShdrIter(Sec); + const Elf_Shdr *EShdr = getSection(Sec); return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) && EShdr->sh_type == ELF::SHT_PROGBITS; } template bool ELFObjectFile::isSectionBSS(DataRefImpl Sec) const { - const Elf_Shdr *EShdr = toELFShdrIter(Sec); + const Elf_Shdr *EShdr = getSection(Sec); return EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) && EShdr->sh_type == ELF::SHT_NOBITS; } template bool ELFObjectFile::isSectionVirtual(DataRefImpl Sec) const { - return toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS; + return getSection(Sec)->sh_type == ELF::SHT_NOBITS; } template @@ -631,7 +635,7 @@ ELFObjectFile::getRelocatedSection(DataRefImpl Sec) const { if (EF.getHeader()->e_type != ELF::ET_REL) return section_end(); - const Elf_Shdr *EShdr = toELFShdrIter(Sec); + const Elf_Shdr *EShdr = getSection(Sec); uintX_t Type = EShdr->sh_type; if (Type != ELF::SHT_REL && Type != ELF::SHT_RELA) return section_end(); -- 2.34.1