diff --git a/lld/test/ELF/linkerscript/wildcards.s b/lld/test/ELF/linkerscript/wildcards.s index c7fbcab448773..84a3bf2887f0d 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* ) ) } +}