[lld] r239951 - [ELF] Now that there's an API for ELF symbol types in LLVM, use it.

Davide Italiano davide at freebsd.org
Wed Jun 17 14:50:51 PDT 2015


Author: davide
Date: Wed Jun 17 16:50:51 2015
New Revision: 239951

URL: http://llvm.org/viewvc/llvm-project?rev=239951&view=rev
Log:
[ELF] Now that there's an API for ELF symbol types in LLVM, use it.

Common symbols will be handled in a separate patch because it seems
Hexagon redefines the notion of common symbol, which I'm not (yet)
very familiar with.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp?rev=239951&r1=239950&r2=239951&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp Wed Jun 17 16:50:51 2015
@@ -223,12 +223,12 @@ std::error_code ELFFile<ELFT>::createSym
     if (std::error_code ec = symbolName.getError())
       return ec;
 
-    if (isAbsoluteSymbol(&*SymI)) {
+    if (SymI->isAbsolute()) {
       ELFAbsoluteAtom<ELFT> *absAtom = createAbsoluteAtom(
           *symbolName, &*SymI, (int64_t)getSymbolValue(&*SymI));
       addAtom(*absAtom);
       _symbolToAtomMapping.insert(std::make_pair(&*SymI, absAtom));
-    } else if (isUndefinedSymbol(&*SymI)) {
+    } else if (SymI->isUndefined()) {
       if (_useWrap &&
           (_wrapSymbolMap.find(*symbolName) != _wrapSymbolMap.end())) {
         auto wrapAtom = _wrapSymbolMap.find(*symbolName);
@@ -245,7 +245,7 @@ std::error_code ELFFile<ELFT>::createSym
       commonAtom->setOrdinal(++_ordinal);
       addAtom(*commonAtom);
       _symbolToAtomMapping.insert(std::make_pair(&*SymI, commonAtom));
-    } else if (isDefinedSymbol(&*SymI)) {
+    } else if (SymI->isDefined()) {
       _sectionSymbols[section].push_back(SymI);
     } else {
       llvm::errs() << "Unable to create atom for: " << *symbolName << "\n";

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=239951&r1=239950&r2=239951&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Wed Jun 17 16:50:51 2015
@@ -197,11 +197,6 @@ protected:
     return _objFile->getSectionContents(shdr);
   }
 
-  /// Returns true if the symbol is a undefined symbol.
-  bool isUndefinedSymbol(const Elf_Sym *sym) const {
-    return (sym->st_shndx == llvm::ELF::SHN_UNDEF);
-  }
-
   /// Determines if the target wants to create an atom for a section that has no
   /// symbol references.
   bool handleSectionWithNoSymbols(const Elf_Shdr *shdr,
@@ -225,11 +220,6 @@ protected:
     return new (_readerStorage) ELFUndefinedAtom<ELFT>(*this, symName, sym);
   }
 
-  /// Returns true if the symbol is a absolute symbol.
-  bool isAbsoluteSymbol(const Elf_Sym *sym) const {
-    return (sym->st_shndx == llvm::ELF::SHN_ABS);
-  }
-
   /// Process the Absolute symbol and create an atom for it.
   ELFAbsoluteAtom<ELFT> *createAbsoluteAtom(StringRef symName,
                                             const Elf_Sym *sym, int64_t value) {
@@ -281,17 +271,6 @@ protected:
     return new (_readerStorage) ELFCommonAtom<ELFT>(*this, symName, sym);
   }
 
-  /// Returns true if the symbol is a defined symbol.
-  virtual bool isDefinedSymbol(const Elf_Sym *sym) const {
-    return (sym->getType() == llvm::ELF::STT_NOTYPE ||
-            sym->getType() == llvm::ELF::STT_OBJECT ||
-            sym->getType() == llvm::ELF::STT_FUNC ||
-            sym->getType() == llvm::ELF::STT_GNU_IFUNC ||
-            sym->getType() == llvm::ELF::STT_SECTION ||
-            sym->getType() == llvm::ELF::STT_FILE ||
-            sym->getType() == llvm::ELF::STT_TLS);
-  }
-
   /// Creates an atom for a given defined symbol.
   virtual ELFDefinedAtom<ELFT> *
   createDefinedAtom(StringRef symName, StringRef sectionName,





More information about the llvm-commits mailing list