2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
4 ## Contiguous SHF_LINK_ORDER sections.
5 # RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(4)} \
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
10 # CHECK: [ 1] .rodata {{.*}} AL 3
11 # CHECK: [ 3] .text {{.*}} AX 0
12 # CHECK: Hex dump of section '.rodata':
13 # CHECK-NEXT: 00030102 04
14 # CHECK: Hex dump of section '.text':
17 # RUN: echo 'SECTIONS { .rodata : {BYTE(0) *(.rodata*) BYTE(4)} \
18 # RUN: .text : {*(.text.foo) *(.text.bar)} }' > %t1.lds
19 # RUN: ld.lld -T %t1.lds %t.o -o %t1
20 # RUN: llvm-readelf -S -x .rodata -x .text %t1 | FileCheck --check-prefix=CHECK1 %s
22 # CHECK1: [ 1] .rodata {{.*}} AL 3
23 # CHECK1: [ 3] .text {{.*}} AX 0
24 # CHECK1: Hex dump of section '.rodata':
25 # CHECK1-NEXT: 00010302 04
26 # CHECK1: Hex dump of section '.text':
29 ## Adjacent input sections descriptions are contiguous.
30 ## Orphan section .text.bar precedes .text.foo. However, don't swap the order of .rodata.*
31 ## because they are in different InputSectionDescriptions.
32 # RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.rodata.bar)} }' > %t2.lds
33 # RUN: ld.lld -T %t2.lds %t.o -o %t2
34 # RUN: llvm-readelf -S -x .rodata %t2 | FileCheck --check-prefix=CHECK2 %s
36 # CHECK2: [ 1] .rodata {{.*}} AL 5
37 # CHECK2: [ 4] .text.bar {{.*}} AX 0
38 # CHECK2-NEXT: [ 5] .text.foo {{.*}} AX 0
39 # CHECK2: Hex dump of section '.rodata':
42 ## Non-contiguous SHF_LINK_ORDER sections, separated by a BYTE.
43 # RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) BYTE(0) *(.rodata.bar)} }' > %t3.lds
44 # RUN: ld.lld -T %t3.lds %t.o -o %t3
45 # RUN: llvm-readelf -S -x .rodata %t3 | FileCheck --check-prefix=CHECK3 %s
47 # CHECK3: [ 1] .rodata {{.*}} AL 5
48 # CHECK3: [ 4] .text.bar {{.*}} AX 0
49 # CHECK3: [ 5] .text.foo {{.*}} AX 0
50 # CHECK3: Hex dump of section '.rodata':
51 # CHECK3-NEXT: 01000302
53 ## Non-contiguous SHF_LINK_ORDER sections, separated by a non-SHF_LINK_ORDER section.
54 # RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) *(.text) *(.rodata.bar)} }' > %t4.lds
55 # RUN: ld.lld -T %t4.lds %t.o -o %t4
56 # RUN: llvm-readelf -x .rodata %t4 | FileCheck --check-prefix=CHECK4 %s
58 # CHECK4: Hex dump of section '.rodata':
59 # CHECK4-NEXT: 01cccccc 0302
61 ## Non-contiguous SHF_LINK_ORDER sections, separated by a symbol assignment.
62 # RUN: echo 'SECTIONS { .rodata : {*(.rodata.foo) a = .; *(.rodata.bar)} }' > %t5.lds
63 # RUN: ld.lld -T %t5.lds %t.o -o %t5
64 # RUN: llvm-readelf -S -x .rodata %t5 | FileCheck --check-prefix=CHECK2 %s
72 .section .text.bar,"a",@progbits
74 .section .text.foo,"a",@progbits
76 .section .rodata.foo,"ao",@progbits,.text.foo
78 ## If the two .rodata.bar sections are in the same InputSectionDescription,
79 ## 03 (sh_link!=0) will be ordered before 02 (sh_link=0).
80 .section .rodata.bar,"a",@progbits
82 .section .rodata.bar,"ao",@progbits,.text.bar