summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-02-17 15:38:21 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-02-17 15:38:21 +0000
commitce2fbddd1903b078e4837e42071e6555b0baecf5 (patch)
treeb82ff1d9b9528a16fb2899f2160a9f7724c28df4 /llvm/include
parenta462b4502f2b6135c2b95ff22f9784c4ce478fe9 (diff)
downloadbcm5719-llvm-ce2fbddd1903b078e4837e42071e6555b0baecf5.tar.gz
bcm5719-llvm-ce2fbddd1903b078e4837e42071e6555b0baecf5.zip
Change how readobj stores info about dynamic symbols.
We used to keep both a section and a pointer to the first symbol. The oddity of keeping a section for dynamic symbols is because there is a DT_SYMTAB but no DT_SYMTABZ, so to print the table we have to find the size via a section table. The reason for still keeping a pointer to the first symbol is because we want to be able to print relocation tables even if the section table is missing (it is mandatory only for files used in linking). With this patch we keep just a DynRegionInfo. This then requires changing a few places that were asking for a Elf_Shdr but actually just needed the first symbol. The test change is to delete the program header pointer. Now that we use the information of both DT_SYMTAB and .dynsym, we don't depend on the sh_entsize of .dynsym if we see DT_SYMTAB. Note: It is questionable if it is worth it putting the effort to report broken sh_entsize given that in files with no section table we have to assume it is sizeof(Elf_Sym), but that is for another change. Extracted from r260488. llvm-svn: 261099
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Object/ELF.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index b0eaa3f5ed4..d01c3cfab16 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -200,6 +200,9 @@ public:
uint32_t getExtendedSymbolTableIndex(const Elf_Sym *Sym,
const Elf_Shdr *SymTab,
ArrayRef<Elf_Word> ShndxTable) const;
+ uint32_t getExtendedSymbolTableIndex(const Elf_Sym *Sym,
+ const Elf_Sym *FirstSym,
+ ArrayRef<Elf_Word> ShndxTable) const;
const Elf_Ehdr *getHeader() const { return Header; }
ErrorOr<const Elf_Shdr *> getSection(const Elf_Sym *Sym,
const Elf_Shdr *SymTab,
@@ -225,8 +228,15 @@ template <class ELFT>
uint32_t ELFFile<ELFT>::getExtendedSymbolTableIndex(
const Elf_Sym *Sym, const Elf_Shdr *SymTab,
ArrayRef<Elf_Word> ShndxTable) const {
+ return getExtendedSymbolTableIndex(Sym, symbol_begin(SymTab), ShndxTable);
+}
+
+template <class ELFT>
+uint32_t ELFFile<ELFT>::getExtendedSymbolTableIndex(
+ const Elf_Sym *Sym, const Elf_Sym *FirstSym,
+ ArrayRef<Elf_Word> ShndxTable) const {
assert(Sym->st_shndx == ELF::SHN_XINDEX);
- unsigned Index = Sym - symbol_begin(SymTab);
+ unsigned Index = Sym - FirstSym;
// The size of the table was checked in getSHNDXTable.
return ShndxTable[Index];
OpenPOWER on IntegriCloud