|
7 | 7 | # CHECK-NEXT: 01020304 |
8 | 8 |
|
9 | 9 | ## --shuffle-sections= shuffles input sections. |
10 | | -# RUN: ld.lld --shuffle-sections=1 %t.o -o %t1.out |
| 10 | +# RUN: ld.lld --shuffle-sections='*=1' %t.o -o %t1.out |
11 | 11 | # RUN: llvm-readelf -x .text %t1.out | FileCheck %s --check-prefix=SHUFFLE1 |
12 | 12 | # SHUFFLE1: Hex dump of section '.text': |
13 | | -# SHUFFLE1-NEXT: 0204cccc 0103 |
| 13 | +# SHUFFLE1-NEXT: 0203cccc 0104 |
14 | 14 |
|
15 | 15 | ## Test that --shuffle-sections= can be used with --symbol-ordering-file |
16 | 16 | # RUN: echo "foo" > %t_order.txt |
17 | 17 | # RUN: echo "_start " >> %t_order.txt |
18 | 18 |
|
19 | | -# RUN: ld.lld --symbol-ordering-file %t_order.txt --shuffle-sections=2 %t.o -o %t2.out |
| 19 | +# RUN: ld.lld --symbol-ordering-file %t_order.txt --shuffle-sections='*=2' %t.o -o %t2.out |
20 | 20 | # RUN: llvm-readelf -x .text %t2.out | FileCheck %s --check-prefix=SHUFFLE2 |
21 | 21 | # SHUFFLE2: Hex dump of section '.text': |
22 | | -# SHUFFLE2-NEXT: 02cccccc 010304 |
| 22 | +# SHUFFLE2-NEXT: 02cccccc 010403 |
23 | 23 |
|
24 | | -# RUN: ld.lld --symbol-ordering-file %t_order.txt --shuffle-sections=3 %t.o -o %t3.out |
| 24 | +# RUN: ld.lld --symbol-ordering-file %t_order.txt --shuffle-sections='*=3' %t.o -o %t3.out |
25 | 25 | # RUN: llvm-readelf -x .text %t3.out | FileCheck %s --check-prefix=SHUFFLE3 |
26 | 26 | # SHUFFLE3: Hex dump of section '.text': |
27 | 27 | # SHUFFLE3-NEXT: 02cccccc 010403 |
28 | 28 |
|
29 | 29 | ## As a special case, -1 reverses sections as a stable transform. |
30 | | -# RUN: ld.lld --shuffle-sections=-1 %t.o -o %t-1.out |
| 30 | +# RUN: ld.lld --shuffle-sections '*=-1' %t.o -o %t-1.out |
31 | 31 | # RUN: llvm-readelf -x .text %t-1.out | FileCheck %s --check-prefix=SHUFFLE-1 |
32 | 32 | # SHUFFLE-1: Hex dump of section '.text': |
33 | 33 | # SHUFFLE-1-NEXT: 040302cc 01 |
34 | 34 |
|
| 35 | +## .text does not change its order while .text.{foo,bar,zed} are reversed. |
| 36 | +# RUN: ld.lld --shuffle-sections '.text.*=-1' %t.o -o %t4.out |
| 37 | +# RUN: llvm-readelf -x .text %t4.out | FileCheck %s --check-prefix=SHUFFLE4 |
| 38 | +# SHUFFLE4: Hex dump of section '.text': |
| 39 | +# SHUFFLE4-NEXT: 01040302 |
| 40 | + |
| 41 | +## Reversing twice restores the original order. |
| 42 | +# RUN: ld.lld --shuffle-sections '.text.*=-1' --shuffle-sections '.text.*=-1' %t.o -o %t.out |
| 43 | +# RUN: llvm-readelf -x .text %t.out | FileCheck %s |
| 44 | + |
| 45 | +## Test all possible invalid cases. |
| 46 | +# RUN: not ld.lld --shuffle-sections= 2>&1 | FileCheck %s --check-prefix=USAGE -DV= |
| 47 | +# RUN: not ld.lld --shuffle-sections=a= 2>&1 | FileCheck %s --check-prefix=USAGE -DV=a= |
| 48 | +# RUN: not ld.lld --shuffle-sections==0 2>&1 | FileCheck %s --check-prefix=USAGE -DV==0 |
| 49 | +# RUN: not ld.lld --shuffle-sections=a 2>&1 | FileCheck %s --check-prefix=USAGE -DV=a |
| 50 | + |
| 51 | +# USAGE: error: --shuffle-sections=: expected <section_glob>=<seed>, but got '[[V]]' |
| 52 | + |
| 53 | +# RUN: not ld.lld --shuffle-sections='['=0 2>&1 | FileCheck %s --check-prefix=INVALID |
| 54 | + |
| 55 | +# INVALID: error: --shuffle-sections=: invalid glob pattern: [ |
| 56 | + |
35 | 57 | ## .text has an alignment of 4. |
36 | 58 | .global _start |
37 | 59 | _start: |
|
0 commit comments