[llvm] r285903 - Split getStringTableForSymtab.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 06:22:51 PDT 2016
Author: rafael
Date: Thu Nov 3 08:22:51 2016
New Revision: 285903
URL: http://llvm.org/viewvc/llvm-project?rev=285903&view=rev
Log:
Split getStringTableForSymtab.
For use in cases where we already have the section table.
Modified:
llvm/trunk/include/llvm/Object/ELF.h
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=285903&r1=285902&r2=285903&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Nov 3 08:22:51 2016
@@ -79,6 +79,8 @@ public:
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,
@@ -456,9 +458,21 @@ ELFFile<ELFT>::getSHNDXTable(const Elf_S
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);
More information about the llvm-commits
mailing list