Skip to content

Commit

Permalink
Split getSHNDXTable in two.
Browse files Browse the repository at this point in the history
Some clients already have the section table available.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285898 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Nov 3, 2016
1 parent e03e2fa commit fdc348b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion include/llvm/Object/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ELFFile {
ErrorOr<StringRef> getStringTableForSymtab(const Elf_Shdr &Section) const;

ErrorOr<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section) const;
ErrorOr<ArrayRef<Elf_Word>> getSHNDXTable(const Elf_Shdr &Section,
Elf_Shdr_Range Sections) const;

void VerifyStrTab(const Elf_Shdr *sh) const;

Expand Down Expand Up @@ -423,12 +425,23 @@ ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
template <class ELFT>
ErrorOr<ArrayRef<typename ELFT::Word>>
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section) const {
auto SectionsOrErr = sections();
if (std::error_code EC = SectionsOrErr.getError())
return EC;
return getSHNDXTable(Section, *SectionsOrErr);
}

template <class ELFT>
ErrorOr<ArrayRef<typename ELFT::Word>>
ELFFile<ELFT>::getSHNDXTable(const Elf_Shdr &Section,
Elf_Shdr_Range Sections) const {
assert(Section.sh_type == ELF::SHT_SYMTAB_SHNDX);
auto VOrErr = getSectionContentsAsArray<Elf_Word>(&Section);
if (std::error_code EC = VOrErr.getError())
return EC;
ArrayRef<Elf_Word> V = *VOrErr;
ErrorOr<const Elf_Shdr *> SymTableOrErr = getSection(Section.sh_link);
ErrorOr<const Elf_Shdr *> SymTableOrErr =
object::getSection<ELFT>(Sections, Section.sh_link);
if (std::error_code EC = SymTableOrErr.getError())
return EC;
const Elf_Shdr &SymTable = **SymTableOrErr;
Expand Down

0 comments on commit fdc348b

Please sign in to comment.