140 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t && split-file %s %t && cd %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux asm -o a.o4 5## Default case: abc and abx included in text.6# RUN: echo "SECTIONS { \7# RUN: .text : { *(.abc .abx) } }" > a.t8# RUN: ld.lld -o out --script a.t a.o9# RUN: llvm-objdump --section-headers out | \10# RUN: FileCheck -check-prefix=SEC-DEFAULT %s11# SEC-DEFAULT: Sections:12# SEC-DEFAULT-NEXT: Idx Name Size13# SEC-DEFAULT-NEXT: 0 0000000014# SEC-DEFAULT-NEXT: 1 .text 0000000815# SEC-DEFAULT-NEXT: 2 .abcd 0000000416# SEC-DEFAULT-NEXT: 3 .ad 0000000417# SEC-DEFAULT-NEXT: 4 .ag 0000000418# SEC-DEFAULT-NEXT: 5 .comment 00000008 {{[0-9a-f]*}}19# SEC-DEFAULT-NEXT: 6 .symtab 0000003020# SEC-DEFAULT-NEXT: 7 .shstrtab 0000003821# SEC-DEFAULT-NEXT: 8 .strtab 0000000822 23## Now replace the symbol with '?' and check that results are the same.24# RUN: echo "SECTIONS { \25# RUN: .text : { *(.abc .ab?) } }" > b.t26# RUN: ld.lld -o out -T b.t a.o27# RUN: llvm-objdump --section-headers out | \28# RUN: FileCheck -check-prefix=SEC-DEFAULT %s29 30## Now see how replacing '?' with '*' will consume whole abcd.31# RUN: echo "SECTIONS { \32# RUN: .text : { *(.abc .ab*) } }" > c.t33# RUN: ld.lld -o out --script c.t a.o34# RUN: llvm-objdump --section-headers out | \35# RUN: FileCheck -check-prefix=SEC-ALL %s36# SEC-ALL: Sections:37# SEC-ALL-NEXT: Idx Name Size38# SEC-ALL-NEXT: 0 0000000039# SEC-ALL-NEXT: 1 .text 0000000c40# SEC-ALL-NEXT: 2 .ad 0000000441# SEC-ALL-NEXT: 3 .ag 0000000442# SEC-ALL-NEXT: 4 .comment 0000000843# SEC-ALL-NEXT: 5 .symtab 0000003044# SEC-ALL-NEXT: 6 .shstrtab 0000003245# SEC-ALL-NEXT: 7 .strtab 0000000846 47## All sections started with .a are merged.48# RUN: echo "SECTIONS { \49# RUN: .text : { *(.a*) } }" > d.t50# RUN: ld.lld -o out --script d.t a.o51# RUN: llvm-objdump --section-headers out | \52# RUN: FileCheck -check-prefix=SEC-NO %s53# SEC-NO: Sections:54# SEC-NO-NEXT: Idx Name Size55# SEC-NO-NEXT: 0 0000000056# SEC-NO-NEXT: 1 .text 0000001457# SEC-NO-NEXT: 2 .comment 0000000858# SEC-NO-NEXT: 3 .symtab 0000003059# SEC-NO-NEXT: 4 .shstrtab 0000002a60# SEC-NO-NEXT: 5 .strtab 0000000861 62#--- asm63.text64.section .abc,"ax",@progbits65.long 066 67.text68.section .abx,"ax",@progbits69.long 070 71.text72.section .abcd,"ax",@progbits73.long 074 75.text76.section .ad,"ax",@progbits77.long 078 79.text80.section .ag,"ax",@progbits81.long 082 83 84.globl _start85_start:86 87#--- bracket.lds88# RUN: ld.lld -T bracket.lds a.o -o out89# RUN: llvm-objdump --section-headers out | FileCheck %s --check-prefix=SEC-DEFAULT90SECTIONS {91 .text : { *([.]abc .ab[v-y] ) }92}93 94## Test a few non-wildcard characters rejected by GNU ld.95 96#--- lbrace.lds97# RUN: not ld.lld -T lbrace.lds a.o 2>&1 | FileCheck %s --check-prefix=ERR-LBRACE --match-full-lines --strict-whitespace98# ERR-LBRACE:{{.*}}: section pattern is expected99# ERR-LBRACE-NEXT:>>> .text : { *(.a* { ) }100# ERR-LBRACE-NEXT:>>> ^101SECTIONS {102 .text : { *(.a* { ) }103}104 105#--- lbrace2.lds106# RUN: not ld.lld -T lbrace2.lds a.o 2>&1 | FileCheck %s --check-prefix=ERR-LBRACE2 --match-full-lines --strict-whitespace107# ERR-LBRACE2:{{.*}}: section pattern is expected108# ERR-LBRACE2-NEXT:>>> .text : { *(.a*{) }109# ERR-LBRACE2-NEXT:>>> ^110SECTIONS {111 .text : { *(.a*{) }112}113 114#--- lparen.lds115# RUN: not ld.lld -T lparen.lds a.o 2>&1 | FileCheck %s --check-prefix=ERR-LPAREN --match-full-lines --strict-whitespace116# ERR-LPAREN:{{.*}}: section pattern is expected117# ERR-LPAREN-NEXT:>>> .text : { *(.a* ( ) }118# ERR-LPAREN-NEXT:>>> ^119SECTIONS {120 .text : { *(.a* ( ) }121}122 123#--- rbrace.lds124# RUN: not ld.lld -T rbrace.lds a.o 2>&1 | FileCheck %s --check-prefix=ERR-RBRACE --match-full-lines --strict-whitespace125# ERR-RBRACE:{{.*}}: section pattern is expected126# ERR-RBRACE-NEXT:>>> .text : { *(.a* x = 3; } ) }127# ERR-RBRACE-NEXT:>>> ^128SECTIONS {129 .text : { *(.a* x = 3; } ) }130}131 132#--- rparen.lds133# RUN: not ld.lld -T rparen.lds a.o 2>&1 | FileCheck %s --check-prefix=ERR-RPAREN --match-full-lines --strict-whitespace134# ERR-RPAREN:{{.*}}: expected filename pattern135# ERR-RPAREN-NEXT:>>> .text : { *(.a* ) ) }136# ERR-RPAREN-NEXT:>>> ^137SECTIONS {138 .text : { *(.a* ) ) }139}140