[llvm] r244447 - elf2yaml: Use existing section walk to find the symbol table. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 07:27:50 PDT 2015


Author: rafael
Date: Mon Aug 10 09:27:50 2015
New Revision: 244447

URL: http://llvm.org/viewvc/llvm-project?rev=244447&view=rev
Log:
elf2yaml: Use existing section walk to find the symbol table. NFC.

Modified:
    llvm/trunk/tools/obj2yaml/elf2yaml.cpp

Modified: llvm/trunk/tools/obj2yaml/elf2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/elf2yaml.cpp?rev=244447&r1=244446&r2=244447&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/elf2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/elf2yaml.cpp Mon Aug 10 09:27:50 2015
@@ -68,15 +68,19 @@ ErrorOr<ELFYAML::Object *> ELFDumper<ELF
   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<ELF
   }
 
   // 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>::dumpSym
     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;




More information about the llvm-commits mailing list