[lld] [LLD] Fix crash on parsing ':ALIGN' in linker script (PR #146723)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 5 09:48:39 PDT 2025


================
@@ -1,7 +1,24 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o %t.o
-# RUN: ld.lld -o %t --script %s %t.o -shared
+# RUN: rm -rf %t && split-file %s %t && cd %t
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux /dev/null -o a.o
+# RUN: ld.lld --script a.t a.o -shared
 
 # lld shouldn't crash.
 
+#--- a.t
 SECTIONS { .foo : ALIGN(2M) {} }
+
+# RUN: not ld.lld --script b.t 2>&1 | FileCheck %s
+
+# lld should not crash and report the error properly.
+
+# CHECK: error: b.t:3: malformed number: :
+# CHECK: >>>   S :ALIGN(4096) {}
+# CHECK: >>>     ^
----------------
MaskRay wrote:

FileCheck ignores consecutive spaces by default. The `^` anchor does not check what it was intended.

We need ` --match-full-lines --strict-whitespace` and use the pattern as used in diag.test

https://github.com/llvm/llvm-project/pull/146723


More information about the llvm-commits mailing list