[lld] [ELF] Reject error-prone meta characters in input section description (PR #84130)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 02:15:04 PST 2024


================
@@ -91,24 +91,31 @@ SECTIONS {
   .text : { *([.]abc .ab[v-y] ) }
 }
 
-## Test a few non-wildcard meta characters rejected by GNU ld.
+## Test a few non-wildcard characters rejected by GNU ld.
 
 #--- lbrace.lds
-# RUN: ld.lld -T lbrace.lds a.o -o out
+# RUN: not ld.lld -T lbrace.lds a.o 2>&1 | FileCheck %s --check-prefix=ERR-LBRACE --match-full-lines --strict-whitespace
+#      ERR-LBRACE:{{.*}}: section pattern is expected
+# ERR-LBRACE-NEXT:>>>   .text : { *(.a* { ) }
----------------
smithp35 wrote:

Is it worth adding a case when there is no space between the disallowed character for example `.text : { *(.a*{)` as I understand it (,),{,} are lexed as a single token so the spaces shouldn't matter. 

>From reading the line and the tests all having the character separated by spaces, it made me double check that we could catch more than just a single isolated character.
```
if (s.size() == 1 && strchr("(){}", s[0]))
```

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


More information about the llvm-commits mailing list