[lld] 5ff3f66 - [ELF] Improve wildcard tests for input section descriptions
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 5 23:39:24 PST 2024
Author: Fangrui Song
Date: 2024-03-05T23:39:19-08:00
New Revision: 5ff3f6604b3a060376db74e454b5609de35b75e1
URL: https://github.com/llvm/llvm-project/commit/5ff3f6604b3a060376db74e454b5609de35b75e1
DIFF: https://github.com/llvm/llvm-project/commit/5ff3f6604b3a060376db74e454b5609de35b75e1.diff
LOG: [ELF] Improve wildcard tests for input section descriptions
Added:
Modified:
lld/test/ELF/linkerscript/wildcards.s
Removed:
################################################################################
diff --git a/lld/test/ELF/linkerscript/wildcards.s b/lld/test/ELF/linkerscript/wildcards.s
index c7fbcab4487733..84a3bf2887f0db 100644
--- a/lld/test/ELF/linkerscript/wildcards.s
+++ b/lld/test/ELF/linkerscript/wildcards.s
@@ -1,12 +1,12 @@
# REQUIRES: x86
-# RUN: split-file %s %t
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/asm -o %t.o
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/asm -o a.o
## Default case: abc and abx included in text.
# RUN: echo "SECTIONS { \
# RUN: .text : { *(.abc .abx) } }" > %t.script
-# RUN: ld.lld -o %t.out --script %t.script %t.o
-# RUN: llvm-objdump --section-headers %t.out | \
+# RUN: ld.lld -o out --script %t.script a.o
+# RUN: llvm-objdump --section-headers out | \
# RUN: FileCheck -check-prefix=SEC-DEFAULT %s
# SEC-DEFAULT: Sections:
# SEC-DEFAULT-NEXT: Idx Name Size
@@ -23,15 +23,15 @@
## Now replace the symbol with '?' and check that results are the same.
# RUN: echo "SECTIONS { \
# RUN: .text : { *(.abc .ab?) } }" > %t.script
-# RUN: ld.lld -o %t.out --script %t.script %t.o
-# RUN: llvm-objdump --section-headers %t.out | \
+# RUN: ld.lld -o out --script %t.script a.o
+# RUN: llvm-objdump --section-headers out | \
# RUN: FileCheck -check-prefix=SEC-DEFAULT %s
## Now see how replacing '?' with '*' will consume whole abcd.
# RUN: echo "SECTIONS { \
# RUN: .text : { *(.abc .ab*) } }" > %t.script
-# RUN: ld.lld -o %t.out --script %t.script %t.o
-# RUN: llvm-objdump --section-headers %t.out | \
+# RUN: ld.lld -o out --script %t.script a.o
+# RUN: llvm-objdump --section-headers out | \
# RUN: FileCheck -check-prefix=SEC-ALL %s
# SEC-ALL: Sections:
# SEC-ALL-NEXT: Idx Name Size
@@ -47,8 +47,8 @@
## All sections started with .a are merged.
# RUN: echo "SECTIONS { \
# RUN: .text : { *(.a*) } }" > %t.script
-# RUN: ld.lld -o %t.out --script %t.script %t.o
-# RUN: llvm-objdump --section-headers %t.out | \
+# RUN: ld.lld -o out --script %t.script a.o
+# RUN: llvm-objdump --section-headers out | \
# RUN: FileCheck -check-prefix=SEC-NO %s
# SEC-NO: Sections:
# SEC-NO-NEXT: Idx Name Size
@@ -84,10 +84,40 @@
.globl _start
_start:
+#--- bracket.lds
+# RUN: ld.lld -T bracket.lds a.o -o out
+# RUN: llvm-objdump --section-headers out | FileCheck %s --check-prefix=SEC-DEFAULT
+SECTIONS {
+ .text : { *([.]abc .ab[v-y] ) }
+}
+
+## Test a few non-wildcard meta characters rejected by GNU ld.
+
+#--- lbrace.lds
+# RUN: ld.lld -T lbrace.lds a.o -o out
+SECTIONS {
+ .text : { *(.a* { ) }
+}
+
#--- lparen.lds
## ( is recognized as a section name pattern. Note, ( is rejected by GNU ld.
-# RUN: ld.lld -T %t/lparen.lds %t.o -o %t.out
-# RUN: llvm-objdump --section-headers %t.out | FileCheck --check-prefix=SEC-NO %s
+# RUN: ld.lld -T lparen.lds a.o -o out
+# RUN: llvm-objdump --section-headers out | FileCheck --check-prefix=SEC-NO %s
SECTIONS {
.text : { *(.a* ( ) }
}
+
+#--- rbrace.lds
+# RUN: ld.lld -T rbrace.lds a.o -o out
+SECTIONS {
+ .text : { *(.a* } ) }
+}
+
+#--- rparen.lds
+# RUN: not ld.lld -T rparen.lds %t.o 2>&1 | FileCheck %s --check-prefix=ERR-RPAREN --match-full-lines --strict-whitespace
+# ERR-RPAREN:{{.*}}: expected filename pattern
+# ERR-RPAREN-NEXT:>>> .text : { *(.a* ) ) }
+# ERR-RPAREN-NEXT:>>> ^
+SECTIONS {
+ .text : { *(.a* ) ) }
+}
More information about the llvm-commits
mailing list