3 # RUN: split-file %s %ts
4 # RUN: llvm-mc -filetype=obj -triple=x86_64 %ts/s -o %t.o
5 # RUN: ld.lld -pie -o %t -T %ts/t %t.o
6 # RUN: llvm-readelf -l %t | FileCheck %s
8 ## Check that an orphan section '.dynamic' is added to the same segment as
9 ## its closest-rank section '.data', even though its sort rank is lower.
10 ## Adding '.dynamic' to the first segment would make the segment writable.
11 # CHECK: Program Headers:
12 # CHECK-NEXT: Type {{.*}} Flg Align
13 # CHECK-NEXT: LOAD {{.*}} R E 0x
14 # CHECK-NEXT: LOAD {{.*}} RW 0x
15 # CHECK-MEXT: LOAD {{.*}} R 0x
17 # CHECK: Segment Sections...
18 # CHECK-NEXT: 00 .text {{$}}
19 # CHECK-NEXT: 01 .data .dynamic {{$}}
20 ## Check that read-only non-PROGBITS orphan sections are placed after the
21 ## closest-rank section '.rodata' despite their sort ranks are lower.
22 # CHECK-NEXT: 02 .rodata .dynsym .gnu.hash .hash .dynstr {{$}}
41 .text : { *(.text) } : exec
42 .data : { *(.data) } : rw
43 .rodata : { *(.rodata) } : ro