mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
elf2yaml: Use existing section walk to find the symbol table. NFC.
llvm-svn: 244447
This commit is contained in:
parent
106510316b
commit
16999b6002
@ -68,15 +68,19 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||
Y->Header.Flags = Obj.getHeader()->e_flags;
|
||||
Y->Header.Entry = Obj.getHeader()->e_entry;
|
||||
|
||||
const Elf_Shdr *Symtab = nullptr;
|
||||
|
||||
// Dump sections
|
||||
for (const Elf_Shdr &Sec : Obj.sections()) {
|
||||
switch (Sec.sh_type) {
|
||||
case ELF::SHT_NULL:
|
||||
case ELF::SHT_SYMTAB:
|
||||
case ELF::SHT_DYNSYM:
|
||||
case ELF::SHT_STRTAB:
|
||||
// Do not dump these sections.
|
||||
break;
|
||||
case ELF::SHT_SYMTAB:
|
||||
Symtab = &Sec;
|
||||
break;
|
||||
case ELF::SHT_RELA: {
|
||||
ErrorOr<ELFYAML::RelocationSection *> S = dumpRelaSection(&Sec);
|
||||
if (std::error_code EC = S.getError())
|
||||
@ -122,14 +126,13 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
|
||||
}
|
||||
|
||||
// Dump symbols
|
||||
const Elf_Shdr *Symtab = Obj.getDotSymtabSec();
|
||||
ErrorOr<StringRef> StrTableOrErr = Obj.getStringTableForSymtab(*Symtab);
|
||||
if (std::error_code EC = StrTableOrErr.getError())
|
||||
return EC;
|
||||
StringRef StrTable = *StrTableOrErr;
|
||||
|
||||
bool IsFirstSym = true;
|
||||
for (const Elf_Sym &Sym : Obj.symbols(Obj.getDotSymtabSec())) {
|
||||
for (const Elf_Sym &Sym : Obj.symbols(Symtab)) {
|
||||
if (IsFirstSym) {
|
||||
IsFirstSym = false;
|
||||
continue;
|
||||
@ -172,7 +175,7 @@ std::error_code ELFDumper<ELFT>::dumpSymbol(const Elf_Sym *Sym,
|
||||
return EC;
|
||||
S.Name = NameOrErr.get();
|
||||
|
||||
ErrorOr<const Elf_Shdr *> ShdrOrErr = Obj.getSection(&*Sym);
|
||||
ErrorOr<const Elf_Shdr *> ShdrOrErr = Obj.getSection(Sym);
|
||||
if (std::error_code EC = ShdrOrErr.getError())
|
||||
return EC;
|
||||
const Elf_Shdr *Shdr = *ShdrOrErr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user