[lld] r299717 - Call updateAlignment before assignAddresses.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 6 14:40:22 PDT 2017


Author: rafael
Date: Thu Apr  6 16:40:22 2017
New Revision: 299717

URL: http://llvm.org/viewvc/llvm-project?rev=299717&view=rev
Log:
Call updateAlignment before assignAddresses.

The alignment expression cannot depend on '.', so we can compute it
early.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=299717&r1=299716&r2=299717&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Apr  6 16:40:22 2017
@@ -579,10 +579,6 @@ void LinkerScript::assignOffsets(OutputS
     LMAOffset = [=] { return Cmd->LMAExpr().getValue() - D; };
   }
 
-  // Handle align (e.g. ".foo : ALIGN(16) { ... }").
-  if (Cmd->AlignExpr)
-    Sec->updateAlignment(Cmd->AlignExpr().getValue());
-
   CurMemRegion = Cmd->MemRegion;
   if (CurMemRegion)
     Dot = CurMemRegion->Offset;
@@ -657,9 +653,14 @@ void LinkerScript::adjustSectionsAfterSo
   placeOrphanSections();
 
   // Try and find an appropriate memory region to assign offsets in.
-  for (BaseCommand *Base : Opt.Commands)
-    if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
+  for (BaseCommand *Base : Opt.Commands) {
+    if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
       Cmd->MemRegion = findMemoryRegion(Cmd);
+      // Handle align (e.g. ".foo : ALIGN(16) { ... }").
+      if (Cmd->AlignExpr)
+	Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
+    }
+  }
 
   // If output section command doesn't specify any segments,
   // and we haven't previously assigned any section to segment,




More information about the llvm-commits mailing list