[lld] r255850 - ELF: Move shouldUseRela to Writer.cpp.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 16 15:33:56 PST 2015


Author: ruiu
Date: Wed Dec 16 17:33:56 2015
New Revision: 255850

URL: http://llvm.org/viewvc/llvm-project?rev=255850&view=rev
Log:
ELF: Move shouldUseRela to Writer.cpp.

The function was used only in Writer.cpp and did not depend on SymbolTable.
There is no reason to have that function in SymbolTable.cpp.

Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/SymbolTable.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=255850&r1=255849&r2=255850&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Dec 16 17:33:56 2015
@@ -28,11 +28,6 @@ using namespace lld::elf2;
 
 template <class ELFT> SymbolTable<ELFT>::SymbolTable() {}
 
-template <class ELFT> bool SymbolTable<ELFT>::shouldUseRela() const {
-  ELFKind K = cast<ELFFileBase<ELFT>>(Config->FirstElf)->getELFKind();
-  return K == ELF64LEKind || K == ELF64BEKind;
-}
-
 template <class ELFT>
 static void checkCompatibility(InputFile *FileP) {
   auto *F = dyn_cast<ELFFileBase<ELFT>>(FileP);

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=255850&r1=255849&r2=255850&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Wed Dec 16 17:33:56 2015
@@ -36,8 +36,6 @@ public:
 
   void addFile(std::unique_ptr<InputFile> File);
 
-  bool shouldUseRela() const;
-
   const llvm::MapVector<StringRef, Symbol *> &getSymbols() const {
     return Symtab;
   }

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=255850&r1=255849&r2=255850&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Dec 16 17:33:56 2015
@@ -95,6 +95,11 @@ private:
 };
 } // anonymous namespace
 
+template <class ELFT> static bool shouldUseRela() {
+  ELFKind K = cast<ELFFileBase<ELFT>>(Config->FirstElf)->getELFKind();
+  return K == ELF64LEKind || K == ELF64BEKind;
+}
+
 template <class ELFT> void lld::elf2::writeResult(SymbolTable<ELFT> *Symtab) {
   // Initialize output sections that are handled by Writer specially.
   // Don't reorder because the order of initialization matters.
@@ -127,7 +132,7 @@ template <class ELFT> void lld::elf2::wr
   GnuHashTableSection<ELFT> GnuHashTab;
   if (Config->GnuHash)
     Out<ELFT>::GnuHashTab = &GnuHashTab;
-  bool IsRela = Symtab->shouldUseRela();
+  bool IsRela = shouldUseRela<ELFT>();
   RelocationSection<ELFT> RelaDyn(IsRela ? ".rela.dyn" : ".rel.dyn", IsRela);
   Out<ELFT>::RelaDyn = &RelaDyn;
   RelocationSection<ELFT> RelaPlt(IsRela ? ".rela.plt" : ".rel.plt", IsRela);




More information about the llvm-commits mailing list