So I enabled the unmapping of the early bootstrap code on arm64.  That
seemed to work, until I saw some random crashes with a previously
"working" kernel.  Of course the kernels are being relinked, so
they're never quite the same.

Looking at a failing kernel I noticed that the endboot symbol wasn't
page-aligned.  As a result the unmapping code may be unmapping some
code that is actually needed by the running kernel.  It all depends on
how much random padding is inserted before and after endboot.

Turns out ldd is not obeying the ALIGN on a section in a linker script
if the -r option is specified.  Diff below fixes that.  The diff is a
bit ugly, but this code changed upstream anyway.  I'm working on a
proper fix there.

ok?


Index: gnu/llvm/tools/lld/ELF/LinkerScript.cpp
===================================================================
RCS file: /cvs/src/gnu/llvm/tools/lld/ELF/LinkerScript.cpp,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 LinkerScript.cpp
--- gnu/llvm/tools/lld/ELF/LinkerScript.cpp     4 Oct 2017 20:27:35 -0000       
1.1.1.4
+++ gnu/llvm/tools/lld/ELF/LinkerScript.cpp     27 Dec 2017 13:44:01 -0000
@@ -732,6 +732,10 @@ void LinkerScript::adjustSectionsBeforeS
       continue;
     if (OutputSection *Sec = Cmd->Sec) {
       Flags = Sec->Flags;
+
+      // Handle align (e.g. ".foo : ALIGN(16) { ... }").
+      if (Cmd->AlignExpr)
+        Sec->updateAlignment(Cmd->AlignExpr().getValue());
       continue;
     }
 
@@ -742,18 +746,18 @@ void LinkerScript::adjustSectionsBeforeS
     OutSec->SectionIndex = I;
     Cmd->Sec = OutSec;
     SecToCommand[OutSec] = Cmd;
+
+    // Handle align (e.g. ".foo : ALIGN(16) { ... }").
+    if (Cmd->AlignExpr)
+      Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
   }
 }
 
 void LinkerScript::adjustSectionsAfterSorting() {
   // Try and find an appropriate memory region to assign offsets in.
   for (BaseCommand *Base : Opt.Commands) {
-    if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
+    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,

Reply via email to