[lld] r276300 - [ELF] - Cleanup of LinkerScript<ELFT>::assignAddresses()

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 09:07:41 PDT 2016


Author: grimar
Date: Thu Jul 21 11:07:40 2016
New Revision: 276300

URL: http://llvm.org/viewvc/llvm-project?rev=276300&view=rev
Log:
[ELF] - Cleanup of LinkerScript<ELFT>::assignAddresses()

LinkerScript<ELFT>::assignAddresses is becoming larger and looks 
it can be good time for splitting. I expect to can more SectionsCommand's there, 
and dispatching some of them separatelly can help to keep method smaller either.

Differential revision: https://reviews.llvm.org/D22506

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/LinkerScript.h

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=276300&r1=276299&r2=276300&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Jul 21 11:07:40 2016
@@ -277,6 +277,17 @@ LinkerScript<ELFT>::createSections(Outpu
 }
 
 template <class ELFT>
+void LinkerScript<ELFT>::dispatchAssignment(SymbolAssignment *Cmd) {
+  uint64_t Val = evalExpr(Cmd->Expr, Dot);
+  if (Cmd->Name == ".") {
+    Dot = Val;
+  } else {
+    auto *D = cast<DefinedRegular<ELFT>>(Symtab<ELFT>::X->find(Cmd->Name));
+    D->Value = Val;
+  }
+}
+
+template <class ELFT>
 void LinkerScript<ELFT>::assignAddresses(
     ArrayRef<OutputSectionBase<ELFT> *> Sections) {
   // Orphan sections are sections present in the input files which
@@ -297,14 +308,7 @@ void LinkerScript<ELFT>::assignAddresses
 
   for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
     if (auto *Cmd = dyn_cast<SymbolAssignment>(Base.get())) {
-      uint64_t Val = evalExpr(Cmd->Expr, Dot);
-      if (Cmd->Name == ".") {
-
-        Dot = Val;
-      } else {
-        auto *D = cast<DefinedRegular<ELFT>>(Symtab<ELFT>::X->find(Cmd->Name));
-        D->Value = Val;
-      }
+      dispatchAssignment(Cmd);
       continue;
     }
 

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=276300&r1=276299&r2=276300&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Thu Jul 21 11:07:40 2016
@@ -121,6 +121,7 @@ private:
 
   int getSectionIndex(StringRef Name);
   std::vector<size_t> getPhdrIndicesForSection(StringRef Name);
+  void dispatchAssignment(SymbolAssignment *Cmd);
 
   uintX_t Dot;
 };




More information about the llvm-commits mailing list