Don't crash on an empty section with an ALIGN.

llvm-svn: 308809
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 14d4c06..835706d 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -751,7 +751,7 @@
     if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base)) {
       Cmd->MemRegion = findMemoryRegion(Cmd);
       // Handle align (e.g. ".foo : ALIGN(16) { ... }").
-      if (Cmd->AlignExpr)
+      if (Cmd->AlignExpr && Cmd->Sec)
         Cmd->Sec->updateAlignment(Cmd->AlignExpr().getValue());
     }
   }
diff --git a/lld/test/ELF/linkerscript/align-section.s b/lld/test/ELF/linkerscript/align-section.s
new file mode 100644
index 0000000..d26f15c
--- /dev/null
+++ b/lld/test/ELF/linkerscript/align-section.s
@@ -0,0 +1,6 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: echo "SECTIONS { .foo : ALIGN(2M) {  } }" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o -shared
+
+# We would crash if an empty section had an ALIGN.