[lld] r308809 - Don't crash on an empty section with an ALIGN.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 17:00:51 PDT 2017
Author: rafael
Date: Fri Jul 21 17:00:51 2017
New Revision: 308809
URL: http://llvm.org/viewvc/llvm-project?rev=308809&view=rev
Log:
Don't crash on an empty section with an ALIGN.
Added:
lld/trunk/test/ELF/linkerscript/align-section.s
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=308809&r1=308808&r2=308809&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Jul 21 17:00:51 2017
@@ -751,7 +751,7 @@ void LinkerScript::adjustSectionsAfterSo
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());
}
}
Added: lld/trunk/test/ELF/linkerscript/align-section.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/align-section.s?rev=308809&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/align-section.s (added)
+++ lld/trunk/test/ELF/linkerscript/align-section.s Fri Jul 21 17:00:51 2017
@@ -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.
More information about the llvm-commits
mailing list