From 2a33cec3eca058d023d33db1828928ea9b4954cd Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 3 Nov 2016 13:22:51 +0000 Subject: [PATCH] Split getStringTableForSymtab. For use in cases where we already have the section table. llvm-svn: 285903 --- llvm/include/llvm/Object/ELF.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index 48120a3..5fd2d38 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -79,6 +79,8 @@ public: ErrorOr getStringTable(const Elf_Shdr *Section) const; ErrorOr getStringTableForSymtab(const Elf_Shdr &Section) const; + ErrorOr getStringTableForSymtab(const Elf_Shdr &Section, + Elf_Shdr_Range Sections) const; ErrorOr> getSHNDXTable(const Elf_Shdr &Section) const; ErrorOr> getSHNDXTable(const Elf_Shdr &Section, @@ -456,9 +458,21 @@ ELFFile::getSHNDXTable(const Elf_Shdr &Section, template ErrorOr ELFFile::getStringTableForSymtab(const Elf_Shdr &Sec) const { + auto SectionsOrErr = sections(); + if (std::error_code EC = SectionsOrErr.getError()) + return EC; + return getStringTableForSymtab(Sec, *SectionsOrErr); +} + +template +ErrorOr +ELFFile::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 SectionOrErr = getSection(Sec.sh_link); + ErrorOr SectionOrErr = + object::getSection(Sections, Sec.sh_link); if (std::error_code EC = SectionOrErr.getError()) return EC; return getStringTable(*SectionOrErr); -- 2.7.4