[llvm] r240730 - [ELF] Add some accessors for lld.

Michael J. Spencer bigcheesegs at gmail.com
Thu Jun 25 16:40:45 PDT 2015


Author: mspencer
Date: Thu Jun 25 18:40:41 2015
New Revision: 240730

URL: http://llvm.org/viewvc/llvm-project?rev=240730&view=rev
Log:
[ELF] Add some accessors for lld.

Modified:
    llvm/trunk/include/llvm/Object/ELF.h
    llvm/trunk/include/llvm/Object/ELFTypes.h

Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=240730&r1=240729&r2=240730&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Thu Jun 25 18:40:41 2015
@@ -227,6 +227,8 @@ public:
                    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;
@@ -340,6 +342,9 @@ public:
 
   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
@@ -424,6 +429,7 @@ public:
   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.
@@ -962,6 +968,12 @@ ErrorOr<StringRef> ELFFile<ELFT>::getSym
 }
 
 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 {
   if (Symb->st_name == 0)

Modified: llvm/trunk/include/llvm/Object/ELFTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFTypes.h?rev=240730&r1=240729&r2=240730&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFTypes.h (original)
+++ llvm/trunk/include/llvm/Object/ELFTypes.h Thu Jun 25 18:40:41 2015
@@ -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





More information about the llvm-commits mailing list