[PATCH] D125523: [ELF] Disallow input section description without a filename
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 13 11:06:11 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG177fd72f5f22: [ELF] Disallow input section description without a filename (authored by MaskRay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125523/new/
https://reviews.llvm.org/D125523
Files:
lld/ELF/ScriptParser.cpp
lld/test/ELF/linkerscript/no-filename-spec.s
Index: lld/test/ELF/linkerscript/no-filename-spec.s
===================================================================
--- lld/test/ELF/linkerscript/no-filename-spec.s
+++ lld/test/ELF/linkerscript/no-filename-spec.s
@@ -1,4 +1,5 @@
# REQUIRES: x86
+# RUN: rm -rf %t && split-file %s %t
# RUN: echo '.section .bar, "a"; .quad 1;' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %tfile1.o
# RUN: echo '.section .zed, "a"; .quad 2;' | \
@@ -6,12 +7,28 @@
## We have a file name and no input sections description. In that case, all
## sections from the file specified should be included. Check that.
-# RUN: ld.lld -o %t --script %s %tfile1.o %tfile2.o
-# RUN: llvm-objdump -s %t | FileCheck %s
+# RUN: ld.lld -o %t/a -T %t/a.t %tfile1.o %tfile2.o
+# RUN: llvm-objdump -s %t/a | FileCheck %s
# CHECK: Contents of section .foo:
# CHECK-NEXT: 01000000 00000000 02000000 00000000
+# RUN: not ld.lld -o /dev/null -T %t/b.t %tfile1.o 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not ld.lld -o /dev/null -T %t/c.t %tfile1.o 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not ld.lld -o /dev/null -T %t/d.t %tfile1.o 2>&1 | FileCheck %s --check-prefix=ERR
+
+# ERR: error: {{.*}}.t:1: expected filename pattern
+
+#--- a.t
SECTIONS {
.foo : { *file1.o *file2.o }
}
+
+#--- b.t
+SECTIONS { .foo : { (*foo) } }
+
+#--- c.t
+SECTIONS { .foo : { (*(foo)) } }
+
+#--- d.t
+SECTIONS { .foo : { )(*foo) } }
Index: lld/ELF/ScriptParser.cpp
===================================================================
--- lld/ELF/ScriptParser.cpp
+++ lld/ELF/ScriptParser.cpp
@@ -945,6 +945,8 @@
readSort();
} else if (tok == "INCLUDE") {
readInclude();
+ } else if (tok == "(" || tok == ")") {
+ setError("expected filename pattern");
} else if (peek() == "(") {
osec->commands.push_back(readInputSectionDescription(tok));
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125523.429298.patch
Type: text/x-patch
Size: 1891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220513/dfe69cf7/attachment.bin>
More information about the llvm-commits
mailing list