Files
clang-p2996/lld/test/ELF/linkerscript/insert-after.test
George Rimar 9e2c8a9db1 [ELF] - Support "INSERT AFTER" statement.
This implements INSERT AFTER in a following way:

During reading scripts it collects all insert statements.
After we done and read all files it inserts statements into script commands list.

With that:
* Rest of code does know nothing about INSERT.
* Approach is straightforward and have no visible limitations.
* It is also easy to support INSERT BEFORE (was seen in clang code once).
* Should work for PR35877 and similar cases.

Cons:
* It assumes we have "main" scripts that describes sections.

Differential revision: https://reviews.llvm.org/D43468

llvm-svn: 327003
2018-03-08 14:54:38 +00:00

30 lines
1.2 KiB
Plaintext

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/insert-after.s -o %t1.o
## Main linker script contains .text and .data sections. Here
## we check that can use INSERT AFTER to insert sections .foo.data
## and .foo.text at the right places.
SECTIONS {
.foo.data : { *(.foo.data) }
} INSERT AFTER .data;
SECTIONS {
.foo.text : { *(.foo.text) }
} INSERT AFTER .text;
# RUN: ld.lld %t1.o -o %t1 --script %p/Inputs/insert-after.script --script %s
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
# CHECK: Sections:
# CHECK-NEXT: Idx Name Size Address Type
# CHECK-NEXT: 0 00000000 0000000000000000
# CHECK-NEXT: 1 .text 00000008 0000000000000000 TEXT DATA
# CHECK-NEXT: 2 .foo.text 00000008 0000000000000008 TEXT DATA
# CHECK-NEXT: 3 .data 00000008 0000000000000010 DATA
# CHECK-NEXT: 4 .foo.data 00000008 0000000000000018 DATA
# RUN: not ld.lld %t1.o -o %t1 --script %s 2>&1 \
# RUN: | FileCheck %s --check-prefix=ERR
# ERR-DAG: error: unable to INSERT AFTER .text: section not defined
# ERR-DAG: error: unable to INSERT AFTER .data: section not defined