1# REQUIRES: x86
2## Document the behavior when an output section is specified by multiple
3## INSERT commands. It is discouraged in the real world.
4
5# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/insert-after.s -o %t.o
6# RUN: ld.lld -T %s %t.o -o %t
7# RUN: llvm-readelf -S -l %t | FileCheck %s
8
9# CHECK:      Name      Type     Address          Off
10# CHECK-NEXT:           NULL     0000000000000000 000000
11# CHECK-NEXT: .text     PROGBITS 0000000000201158 000158
12# CHECK-NEXT: .foo.text PROGBITS 0000000000201160 000160
13# CHECK-NEXT: .foo.data PROGBITS 0000000000202168 000168
14# CHECK:      Type
15# CHECK-NEXT: PHDR {{.*}} R
16# CHECK-NEXT: LOAD {{.*}} R
17# CHECK-NEXT: LOAD {{.*}} R E
18# CHECK-NEXT: LOAD {{.*}} RW
19# CHECK-NEXT: GNU_STACK {{.*}} RW
20
21## First, move .foo.data after .foo.text
22SECTIONS { .foo.data : { *(.foo.data) } } INSERT AFTER .foo.text;
23
24## Next, move .foo.text after .foo.data
25SECTIONS { .foo.text : { *(.foo.text) } } INSERT AFTER .foo.data;
26
27## Then, move .foo.data after .foo.text again.
28SECTIONS { .foo.data : { *(.foo.data) } } INSERT AFTER .foo.text;
29