Skip to content

Commit

Permalink
Split getStringTableForSymtab.
Browse files Browse the repository at this point in the history
For use in cases where we already have the section table.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285903 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Nov 3, 2016
1 parent fdc348b commit 7450907
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion include/llvm/Object/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class ELFFile {

ErrorOr<StringRef> getStringTable(const Elf_Shdr *Section) const;
ErrorOr<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;
ErrorOr<StringRef> getStringTableForSymtab(const Elf_Shdr &Section,
Elf_Shdr_Range Sections) const;

ErrorOr<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section) const;
ErrorOr<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section,
Expand Down Expand Up @@ -456,9 +458,21 @@ ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section,
template <class ELFT>
ErrorOr<StringRef>
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec) const {
auto SectionsOrErr = sections();
if (std::error_code EC = SectionsOrErr.getError())
return EC;
return getStringTableForSymtab(Sec, *SectionsOrErr);
}

template <class ELFT>
ErrorOr<StringRef>
ELFFile<ELFT>::getStringTableForSymtab(const Elf_Shdr &Sec,
Elf_Shdr_Range Sections) const {

if (Sec.sh_type != ELF::SHT_SYMTAB && Sec.sh_type != ELF::SHT_DYNSYM)
return object_error::parse_failed;
ErrorOr<const Elf_Shdr *> SectionOrErr = getSection(Sec.sh_link);
ErrorOr<const Elf_Shdr *> SectionOrErr =
object::getSection<ELFT>(Sections, Sec.sh_link);
if (std::error_code EC = SectionOrErr.getError())
return EC;
return getStringTable(*SectionOrErr);
Expand Down

0 comments on commit 7450907

Please sign in to comment.