Skip to content

Commit

Permalink
[ELF] Add some accessors for lld.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240730 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Bigcheese committed Jun 25, 2015
1 parent 1cf2b03 commit 7358cbc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/llvm/Object/ELF.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class ELFFile {
ArchivePointerTypeTraits<const char> > Current;
};

typedef iterator_range<Elf_Sym_Iter> Elf_Sym_Range;

private:
typedef SmallVector<const Elf_Shdr *, 2> Sections_t;
typedef DenseMap<unsigned, unsigned> IndexMap_t;
Expand Down Expand Up @@ -340,6 +342,9 @@ class ELFFile {

Elf_Sym_Iter begin_symbols() const;
Elf_Sym_Iter end_symbols() const;
Elf_Sym_Range symbols() const {
return make_range(begin_symbols(), end_symbols());
}

Elf_Dyn_Iter begin_dynamic_table() const;
/// \param NULLEnd use one past the first DT_NULL entry as the end instead of
Expand Down Expand Up @@ -424,6 +429,7 @@ class ELFFile {
const Elf_Sym *getSymbol(uint32_t index) const;

ErrorOr<StringRef> getSymbolName(Elf_Sym_Iter Sym) const;
ErrorOr<StringRef> getStaticSymbolName(const Elf_Sym *Symb) const;

/// \brief Get the name of \p Symb.
/// \param SymTab The symbol table section \p Symb is contained in.
Expand Down Expand Up @@ -961,6 +967,12 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSymbolName(Elf_Sym_Iter Sym) const {
return StringRef(getDynamicString(Sym->st_name));
}

template <class ELFT>
ErrorOr<StringRef>
ELFFile<ELFT>::getStaticSymbolName(const Elf_Sym *Symb) const {
return getSymbolName(dot_symtab_sec, Symb);
}

template <class ELFT>
ErrorOr<StringRef> ELFFile<ELFT>::getSymbolName(const Elf_Shdr *Section,
const Elf_Sym *Symb) const {
Expand Down
3 changes: 3 additions & 0 deletions include/llvm/Object/ELFTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ struct Elf_Sym_Impl : Elf_Sym_Base<ELFT> {
return st_shndx >= ELF::SHN_LORESERVE;
}
bool isUndefined() const { return st_shndx == ELF::SHN_UNDEF; }
bool isExternal() const {
return getBinding() != ELF::STB_LOCAL;
}
};

/// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section
Expand Down

0 comments on commit 7358cbc

Please sign in to comment.