1# REQUIRES: x86
2## Test that we can handle cases where an output section is specified by multiple
3## INSERT commands. Each output section description creates a new instance.
4## A redundant description matches no input sections and thus is a no-op.
5
6# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/insert-after.s -o %t.o
7# RUN: ld.lld -T %s %t.o -o %t
8# RUN: llvm-readelf -S -l %t | FileCheck %s
9
10# CHECK:      Name      Type     Address          Off
11# CHECK-NEXT:           NULL     0000000000000000 000000
12# CHECK-NEXT: .text     PROGBITS 00000000002011c8 0001c8
13# CHECK-NEXT: .foo.data PROGBITS 00000000002021d0 0001d0
14# CHECK-NEXT: .foo.text PROGBITS 00000000002031d8 0001d8
15# CHECK:      Type
16# CHECK-NEXT: PHDR {{.*}} R
17# CHECK-NEXT: LOAD {{.*}} R
18# CHECK-NEXT: LOAD {{.*}} R E
19# CHECK-NEXT: LOAD {{.*}} RW
20# CHECK-NEXT: LOAD {{.*}} R E
21# CHECK-NEXT: LOAD {{.*}} RW
22# CHECK-NEXT: GNU_STACK {{.*}} RW
23
24## First, move .foo.data after .foo.text
25SECTIONS { .foo.data : { *(.foo.data) } } INSERT AFTER .foo.text;
26
27## Next, move .foo.text after .foo.data
28SECTIONS { .foo.text : { *(.foo.text) } } INSERT AFTER .foo.data;
29
30## No-op. The .foo.data output section is a different instance and matches no
31## input sections.
32SECTIONS { .foo.data : { *(.foo.data) } } INSERT AFTER .foo.text;
33