|
1 | 1 | # REQUIRES: x86
|
2 | 2 | # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
3 | 3 |
|
4 |
| -# RUN: echo "SECTIONS { .text : { *(.text.bar) *(.text.foo) } }" > %t.script |
5 |
| -# RUN: ld.lld -o %t --script %t.script %t.o |
6 |
| -# RUN: llvm-objdump -s %t | FileCheck %s |
| 4 | +## Contiguous SHF_LINK_ORDER sections. |
| 5 | +# RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(3)} \ |
| 6 | +# RUN: .text : {*(.text.bar) *(.text.foo)} }' > %t.lds |
| 7 | +# RUN: ld.lld -T %t.lds %t.o -o %t |
| 8 | +# RUN: llvm-readelf -S -x .rodata -x .text %t | FileCheck %s |
7 | 9 |
|
8 |
| -# RUN: echo "SECTIONS { .text : { *(.text.foo) *(.text.bar) } }" > %t.script |
9 |
| -# RUN: ld.lld -o %t --script %t.script %t.o |
10 |
| -# RUN: llvm-objdump -s %t | FileCheck --check-prefix=INV %s |
| 10 | +# CHECK: Hex dump of section '.rodata': |
| 11 | +# CHECK-NEXT: 00020103 |
| 12 | +# CHECK: Hex dump of section '.text': |
| 13 | +# CHECK-NEXT: 0201 |
11 | 14 |
|
| 15 | +# RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(3)} \ |
| 16 | +# RUN: .text : {*(.text.foo) *(.text.bar)} }' > %t1.lds |
| 17 | +# RUN: ld.lld -T %t1.lds %t.o -o %t1 |
| 18 | +# RUN: llvm-readelf -S -x .rodata -x .text %t1 | FileCheck --check-prefix=CHECK1 %s |
12 | 19 |
|
13 |
| -# CHECK: Contents of section .rodata: |
14 |
| -# CHECK-NEXT: 02000000 00000000 01000000 00000000 |
15 |
| -# CHECK: Contents of section .text: |
16 |
| -# CHECK-NEXT: 02000000 00000000 01000000 00000000 |
| 20 | +# CHECK1: Hex dump of section '.rodata': |
| 21 | +# CHECK1-NEXT: 00010203 |
| 22 | +# CHECK1: Hex dump of section '.text': |
| 23 | +# CHECK1-NEXT: 0102 |
17 | 24 |
|
18 |
| -# INV: Contents of section .rodata: |
19 |
| -# INV-NEXT: 01000000 00000000 02000000 00000000 |
20 |
| -# INV: Contents of section .text: |
21 |
| -# INV-NEXT: 01000000 00000000 02000000 00000000 |
| 25 | +## Adjacent input sections descriptions are contiguous. |
| 26 | +## Orphan section .text.bar precedes .text.foo, so swap the order of .rodata.* |
| 27 | +# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.rodata.bar)} }' > %t2.lds |
| 28 | +# RUN: ld.lld -T %t2.lds %t.o -o %t2 |
| 29 | +# RUN: llvm-readelf -S -x .rodata %t2 | FileCheck --check-prefix=CHECK2 %s |
| 30 | + |
| 31 | +# CHECK2: [ 1] .rodata {{.*}} AL 3 |
| 32 | +# CHECK2: [ 3] .text {{.*}} AX 0 |
| 33 | +# CHECK2: Hex dump of section '.rodata': |
| 34 | +# CHECK2-NEXT: 0201 |
| 35 | + |
| 36 | +## Non-contiguous SHF_LINK_ORDER sections, separated by a BYTE. |
| 37 | +# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) BYTE(0) *(.rodata.bar)} }' > %terr1.lds |
| 38 | +# RUN: ld.lld -T %terr1.lds %t.o -o /dev/null |
| 39 | + |
| 40 | +## Non-contiguous SHF_LINK_ORDER sections, separated by a non-SHF_LINK_ORDER section. |
| 41 | +# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.text) *(.rodata.bar)} }' > %terr2.lds |
| 42 | +# RUN: not ld.lld -T %terr2.lds %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s |
| 43 | + |
| 44 | +## Non-contiguous SHF_LINK_ORDER sections, separated by a symbol assignment. |
| 45 | +# RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) a = .; *(.rodata.bar)} }' > %terr3.lds |
| 46 | +# RUN: ld.lld -T %terr3.lds %t.o -o /dev/null |
| 47 | + |
| 48 | +# ERR: error: incompatible section flags for .rodata |
22 | 49 |
|
23 | 50 | .global _start
|
24 | 51 | _start:
|
25 | 52 |
|
| 53 | +.section .ro,"a" |
| 54 | +.byte 0 |
| 55 | + |
26 | 56 | .section .text.bar,"a",@progbits
|
27 |
| -.quad 2 |
| 57 | +.byte 2 |
28 | 58 | .section .text.foo,"a",@progbits
|
29 |
| -.quad 1 |
| 59 | +.byte 1 |
30 | 60 | .section .rodata.foo,"ao",@progbits,.text.foo
|
31 |
| -.quad 1 |
| 61 | +.byte 1 |
32 | 62 | .section .rodata.bar,"ao",@progbits,.text.bar
|
33 |
| -.quad 2 |
| 63 | +.byte 2 |
0 commit comments