From 454a7bb37229ee366b0ab75c410914d8cfa2a0c7 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 7 Apr 2019 08:28:56 +0000 Subject: [PATCH] . llvm-svn: 357856 --- llvm/tools/llvm-objdump/ELFDump.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/llvm/tools/llvm-objdump/ELFDump.cpp b/llvm/tools/llvm-objdump/ELFDump.cpp index 90a99c9..3b293a7 100644 --- a/llvm/tools/llvm-objdump/ELFDump.cpp +++ b/llvm/tools/llvm-objdump/ELFDump.cpp @@ -23,13 +23,11 @@ using namespace llvm::object; template Expected getDynamicStrTab(const ELFFile *Elf) { - typedef ELFFile ELFO; - auto DynamicEntriesOrError = Elf->dynamicEntries(); if (!DynamicEntriesOrError) return DynamicEntriesOrError.takeError(); - for (const typename ELFO::Elf_Dyn &Dyn : *DynamicEntriesOrError) { + for (const typename ELFT::Dyn &Dyn : *DynamicEntriesOrError) { if (Dyn.d_tag == ELF::DT_STRTAB) { auto MappedAddrOrError = Elf->toMappedAddr(Dyn.getPtr()); if (!MappedAddrOrError) @@ -43,7 +41,7 @@ Expected getDynamicStrTab(const ELFFile *Elf) { if (!SectionsOrError) return SectionsOrError.takeError(); - for (const typename ELFO::Elf_Shdr &Sec : *SectionsOrError) { + for (const typename ELFT::Shdr &Sec : *SectionsOrError) { if (Sec.sh_type == ELF::SHT_DYNSYM) return Elf->getStringTableForSymtab(Sec); } @@ -55,8 +53,6 @@ template static std::error_code getRelocationValueString(const ELFObjectFile *Obj, const RelocationRef &RelRef, SmallVectorImpl &Result) { - typedef typename ELFObjectFile::Elf_Sym Elf_Sym; - typedef typename ELFObjectFile::Elf_Shdr Elf_Shdr; typedef typename ELFObjectFile::Elf_Rela Elf_Rela; const ELFFile &EF = *Obj->getELFFile(); @@ -88,12 +84,13 @@ static std::error_code getRelocationValueString(const ELFObjectFile *Obj, if (!Undef) { symbol_iterator SI = RelRef.getSymbol(); - const Elf_Sym *Sym = Obj->getSymbol(SI->getRawDataRefImpl()); + const typename ELFT::Sym *Sym = Obj->getSymbol(SI->getRawDataRefImpl()); if (Sym->getType() == ELF::STT_SECTION) { Expected SymSI = SI->getSection(); if (!SymSI) return errorToErrorCode(SymSI.takeError()); - const Elf_Shdr *SymSec = Obj->getSection((*SymSI)->getRawDataRefImpl()); + const typename ELFT::Shdr *SymSec = + Obj->getSection((*SymSI)->getRawDataRefImpl()); auto SecName = EF.getSectionName(SymSec); if (!SecName) return errorToErrorCode(SecName.takeError()); @@ -192,13 +189,12 @@ void printDynamicSection(const ELFFile *Elf, StringRef Filename) { } template void printProgramHeaders(const ELFFile *o) { - typedef ELFFile ELFO; outs() << "Program Header:\n"; auto ProgramHeaderOrError = o->program_headers(); if (!ProgramHeaderOrError) report_fatal_error( errorToErrorCode(ProgramHeaderOrError.takeError()).message()); - for (const typename ELFO::Elf_Phdr &Phdr : *ProgramHeaderOrError) { + for (const typename ELFT::Phdr &Phdr : *ProgramHeaderOrError) { switch (Phdr.p_type) { case ELF::PT_DYNAMIC: outs() << " DYNAMIC "; @@ -259,22 +255,17 @@ template void printProgramHeaders(const ELFFile *o) { template void printSymbolVersionDependency(ArrayRef Contents, StringRef StrTab) { - typedef ELFFile ELFO; - typedef typename ELFO::Elf_Verneed Elf_Verneed; - typedef typename ELFO::Elf_Vernaux Elf_Vernaux; - outs() << "Version References:\n"; const uint8_t *Buf = Contents.data(); while (Buf) { - const Elf_Verneed *Verneed = reinterpret_cast(Buf); + auto *Verneed = reinterpret_cast(Buf); outs() << " required from " << StringRef(StrTab.drop_front(Verneed->vn_file).data()) << ":\n"; const uint8_t *BufAux = Buf + Verneed->vn_aux; while (BufAux) { - const Elf_Vernaux *Vernaux = - reinterpret_cast(BufAux); + auto *Vernaux = reinterpret_cast(BufAux); outs() << " " << format("0x%08" PRIx32 " ", (uint32_t)Vernaux->vna_hash) << format("0x%02" PRIx16 " ", (uint16_t)Vernaux->vna_flags) -- 2.7.4