1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/insert-after.s -o %t1.o
3
4## Main linker script contains .text and .data sections. Here
5## we check that can use INSERT BEFORE to insert sections .foo.data
6## and .foo.text at the right places.
7
8SECTIONS {
9  .foo.data : { *(.foo.data) }
10} INSERT BEFORE .data;
11
12SECTIONS {
13  .foo.text : { *(.foo.text) }
14} INSERT BEFORE .text;
15
16# RUN: ld.lld %t1.o -o %t1 --script %p/Inputs/insert-after.script --script %s
17# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
18# CHECK:      Sections:
19# CHECK-NEXT: Idx Name          Size     VMA         Type
20# CHECK-NEXT:   0               00000000 0000000000000000
21# CHECK-NEXT:   1 .foo.text     00000008 0000000000000000 TEXT
22# CHECK-NEXT:   2 .text         00000008 0000000000000008 TEXT
23# CHECK-NEXT:   3 .foo.data     00000008 0000000000000010 DATA
24# CHECK-NEXT:   4 .data         00000008 0000000000000018 DATA
25
26# RUN: not ld.lld %t1.o -o %t1 --script %s 2>&1 \
27# RUN:   | FileCheck %s --check-prefix=ERR
28# ERR-DAG: error: unable to INSERT AFTER/BEFORE .text: section not defined
29# ERR-DAG: error: unable to INSERT AFTER/BEFORE .data: section not defined
30