1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3# RUN: echo "PHDRS { \
4# RUN:   exec PT_LOAD FLAGS(0x4 | 0x1); \
5# RUN:   rw   PT_LOAD FLAGS(0x4 | 0x2); \
6# RUN: } \
7# RUN: SECTIONS { \
8# RUN:  .text : { *(.text) } :exec \
9# RUN:  .empty : { *(.empty) } :rw \
10# RUN:  .rw : { *(.rw) } \
11# RUN: }" > %t.script
12# RUN: ld.lld -o %t --script %t.script %t.o
13# RUN: llvm-readelf -S -l %t | FileCheck %s
14
15## Check that the orphan section is placed correctly and belongs to
16## the correct segment.
17
18# CHECK: Section Headers
19# CHECK: .text
20# CHECK-NEXT: .orphan
21# CHECK-NEXT: .rw
22
23# CHECK: Segment Sections
24# CHECK-NEXT: .text .orphan
25# CHECK-NEXT: .rw
26
27.section .text,"ax"
28 ret
29
30.section .rw,"aw"
31 .quad 0
32
33.section .orphan,"ax"
34 ret
35