[llvm] r243011 - Add a version of getSymbol with an explicit symbol table. Use it. NFC.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jul 23 05:49:40 PDT 2015
Author: rafael
Date: Thu Jul 23 07:49:40 2015
New Revision: 243011
URL: http://llvm.org/viewvc/llvm-project?rev=243011&view=rev
Log:
Add a version of getSymbol with an explicit symbol table. Use it. NFC.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/tools/obj2yaml/elf2yaml.cpp
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=243011&r1=243010&r2=243011&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Jul 23 07:49:40 2015
@@ -268,7 +268,13 @@ public:
const Elf_Ehdr *getHeader() const { return Header; }
ErrorOr<const Elf_Shdr *> getSection(const Elf_Sym *symb) const;
ErrorOr<const Elf_Shdr *> getSection(uint32_t Index) const;
- const Elf_Sym *getSymbol(uint32_t index) const;
+
+ const Elf_Sym *getSymbol(const Elf_Shdr *Sec, uint32_t Index) const {
+ return &*(symbol_begin(Sec) + Index);
+ }
+ const Elf_Sym *getSymbol(uint32_t Index) const {
+ return getSymbol(dot_symtab_sec, Index);
+ }
ErrorOr<StringRef> getSectionName(const Elf_Shdr *Section) const;
ErrorOr<ArrayRef<uint8_t> > getSectionContents(const Elf_Shdr *Sec) const;
@@ -379,12 +385,6 @@ ELFFile<ELFT>::getSection(const Elf_Sym
}
template <class ELFT>
-const typename ELFFile<ELFT>::Elf_Sym *
-ELFFile<ELFT>::getSymbol(uint32_t Index) const {
- return &*(symbol_begin() + Index);
-}
-
-template <class ELFT>
ErrorOr<ArrayRef<uint8_t> >
ELFFile<ELFT>::getSectionContents(const Elf_Shdr *Sec) const {
if (Sec->sh_offset + Sec->sh_size > Buf.size())
Modified: llvm/trunk/tools/obj2yaml/elf2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/elf2yaml.cpp?rev=243011&r1=243010&r2=243011&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/elf2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/elf2yaml.cpp Thu Jul 23 07:49:40 2015
@@ -338,11 +338,12 @@ ErrorOr<ELFYAML::Group *> ELFDumper<ELFT
if (std::error_code EC = dumpCommonSection(Shdr, *S))
return EC;
// Get sh_info which is the signature.
- const Elf_Sym *symbol = Obj.getSymbol(Shdr->sh_info);
- ErrorOr<const Elf_Shdr *> Symtab = Obj.getSection(Shdr->sh_link);
- if (std::error_code EC = Symtab.getError())
+ ErrorOr<const Elf_Shdr *> SymtabOrErr = Obj.getSection(Shdr->sh_link);
+ if (std::error_code EC = SymtabOrErr.getError())
return EC;
- ErrorOr<const Elf_Shdr *> StrTabSec = Obj.getSection((*Symtab)->sh_link);
+ const Elf_Shdr *Symtab = *SymtabOrErr;
+ const Elf_Sym *symbol = Obj.getSymbol(Symtab, Shdr->sh_info);
+ ErrorOr<const Elf_Shdr *> StrTabSec = Obj.getSection(Symtab->sh_link);
if (std::error_code EC = StrTabSec.getError())
return EC;
ErrorOr<StringRef> StrTabOrErr = Obj.getStringTable(*StrTabSec);
More information about the llvm-commits
mailing list