Skip to content

Commit

Permalink
[llvm-readobj/ELF] Factor out common code.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245813 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dcci committed Aug 23, 2015
1 parent d2681e8 commit a99b964
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tools/llvm-readobj/ELFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ELFDumper : public ObjDumper {
uintX_t EntSize;
};

void printSymbolsHelper(bool IsDynamic);
void printSymbol(const Elf_Sym *Symbol, const Elf_Shdr *SymTab,
StringRef StrTable, bool IsDynamic);

Expand Down Expand Up @@ -1148,27 +1149,25 @@ void ELFDumper<ELFT>::printRelocation(const Elf_Shdr *Sec, Elf_Rela Rel) {
}

template<class ELFT>
void ELFDumper<ELFT>::printSymbols() {
ListScope Group(W, "Symbols");

const Elf_Shdr *Symtab = DotSymtabSec;
void ELFDumper<ELFT>::printSymbolsHelper(bool IsDynamic) {
const Elf_Shdr *Symtab = (IsDynamic) ? DotDynSymSec : DotSymtabSec;
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;
for (const Elf_Sym &Sym : Obj->symbols(Symtab))
printSymbol(&Sym, Symtab, StrTable, false);
printSymbol(&Sym, Symtab, StrTable, IsDynamic);
}

template<class ELFT>
void ELFDumper<ELFT>::printSymbols() {
ListScope Group(W, "Symbols");
printSymbolsHelper(false);
}

template<class ELFT>
void ELFDumper<ELFT>::printDynamicSymbols() {
ListScope Group(W, "DynamicSymbols");

const Elf_Shdr *Symtab = DotDynSymSec;
ErrorOr<StringRef> StrTableOrErr = Obj->getStringTableForSymtab(*Symtab);
error(StrTableOrErr.getError());
StringRef StrTable = *StrTableOrErr;
for (const Elf_Sym &Sym : Obj->symbols(Symtab))
printSymbol(&Sym, Symtab, StrTable, true);
printSymbolsHelper(true);
}

template <class ELFT>
Expand Down

0 comments on commit a99b964

Please sign in to comment.