[PATCH] D22506: [ELF] - Cleanup of LinkerScript<ELFT>::assignAddresses()

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


grimar updated this revision to Diff 64908.
grimar added a comment.

- Made dispatchAssignment as member to simplify.


https://reviews.llvm.org/D22506

Files:
  LinkerScript.cpp
  LinkerScript.h

Index: LinkerScript.h
===================================================================
--- LinkerScript.h
+++ LinkerScript.h
@@ -121,6 +121,7 @@
 
   int getSectionIndex(StringRef Name);
   std::vector<size_t> getPhdrIndicesForSection(StringRef Name);
+  void dispatchAssignment(SymbolAssignment *Cmd);
 
   uintX_t Dot;
 };
Index: LinkerScript.cpp
===================================================================
--- LinkerScript.cpp
+++ LinkerScript.cpp
@@ -277,6 +277,17 @@
 }
 
 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 @@
 
   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;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22506.64908.patch
Type: text/x-patch
Size: 1457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160721/cbd95adb/attachment.bin>


More information about the llvm-commits mailing list