2 # RUN: split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/asm -o %t.o
5 ## Default case: abc and abx included in text.
6 # RUN: echo "SECTIONS { \
7 # RUN: .text : { *(.abc .abx) } }" > %t.script
8 # RUN: ld.lld -o %t.out --script %t.script %t.o
9 # RUN: llvm-objdump --section-headers %t.out | \
10 # RUN: FileCheck -check-prefix=SEC-DEFAULT %s
11 # SEC-DEFAULT: Sections:
12 # SEC-DEFAULT-NEXT: Idx Name Size
13 # SEC-DEFAULT-NEXT: 0 00000000
14 # SEC-DEFAULT-NEXT: 1 .text 00000008
15 # SEC-DEFAULT-NEXT: 2 .abcd 00000004
16 # SEC-DEFAULT-NEXT: 3 .ad 00000004
17 # SEC-DEFAULT-NEXT: 4 .ag 00000004
18 # SEC-DEFAULT-NEXT: 5 .comment 00000008 {{[0-9a-f]*}}
19 # SEC-DEFAULT-NEXT: 6 .symtab 00000030
20 # SEC-DEFAULT-NEXT: 7 .shstrtab 00000038
21 # SEC-DEFAULT-NEXT: 8 .strtab 00000008
23 ## Now replace the symbol with '?' and check that results are the same.
24 # RUN: echo "SECTIONS { \
25 # RUN: .text : { *(.abc .ab?) } }" > %t.script
26 # RUN: ld.lld -o %t.out --script %t.script %t.o
27 # RUN: llvm-objdump --section-headers %t.out | \
28 # RUN: FileCheck -check-prefix=SEC-DEFAULT %s
30 ## Now see how replacing '?' with '*' will consume whole abcd.
31 # RUN: echo "SECTIONS { \
32 # RUN: .text : { *(.abc .ab*) } }" > %t.script
33 # RUN: ld.lld -o %t.out --script %t.script %t.o
34 # RUN: llvm-objdump --section-headers %t.out | \
35 # RUN: FileCheck -check-prefix=SEC-ALL %s
37 # SEC-ALL-NEXT: Idx Name Size
38 # SEC-ALL-NEXT: 0 00000000
39 # SEC-ALL-NEXT: 1 .text 0000000c
40 # SEC-ALL-NEXT: 2 .ad 00000004
41 # SEC-ALL-NEXT: 3 .ag 00000004
42 # SEC-ALL-NEXT: 4 .comment 00000008
43 # SEC-ALL-NEXT: 5 .symtab 00000030
44 # SEC-ALL-NEXT: 6 .shstrtab 00000032
45 # SEC-ALL-NEXT: 7 .strtab 00000008
47 ## All sections started with .a are merged.
48 # RUN: echo "SECTIONS { \
49 # RUN: .text : { *(.a*) } }" > %t.script
50 # RUN: ld.lld -o %t.out --script %t.script %t.o
51 # RUN: llvm-objdump --section-headers %t.out | \
52 # RUN: FileCheck -check-prefix=SEC-NO %s
54 # SEC-NO-NEXT: Idx Name Size
55 # SEC-NO-NEXT: 0 00000000
56 # SEC-NO-NEXT: 1 .text 00000014
57 # SEC-NO-NEXT: 2 .comment 00000008
58 # SEC-NO-NEXT: 3 .symtab 00000030
59 # SEC-NO-NEXT: 4 .shstrtab 0000002a
60 # SEC-NO-NEXT: 5 .strtab 00000008
64 .section .abc,"ax",@progbits
68 .section .abx,"ax",@progbits
72 .section .abcd,"ax",@progbits
76 .section .ad,"ax",@progbits
80 .section .ag,"ax",@progbits
88 ## ( is recognized as a section name pattern. Note, ( is rejected by GNU ld.
89 # RUN: ld.lld -T %t/lparen.lds %t.o -o %t.out
90 # RUN: llvm-objdump --section-headers %t.out | FileCheck --check-prefix=SEC-NO %s