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 8# RUN: ld.lld %t1.o -o %t1 --script %p/Inputs/insert-after.script --script %s 9# RUN: llvm-readelf -S -l %t1 | FileCheck %s 10# CHECK: Name Type Address Off 11# CHECK-NEXT: NULL 0000000000000000 000000 12# CHECK-NEXT: .foo.text PROGBITS 0000000000000000 001000 13# CHECK-NEXT: .text PROGBITS 0000000000000008 001008 14# CHECK-NEXT: .foo.data PROGBITS 0000000000000010 001010 15# CHECK-NEXT: .data PROGBITS 0000000000000018 001018 16# CHECK: Type 17# CHECK-NEXT: LOAD {{.*}} R E 18# CHECK-NEXT: LOAD {{.*}} RW 19# CHECK-NEXT: GNU_STACK {{.*}} RW 20 21## There is no main linker script. INSERT BEFORE just reorders output sections, 22## without making more layout changes. Address/offset assignments are different 23## with a main linker script. 24 25# RUN: ld.lld --script %s %t1.o -o %t2 26# RUN: llvm-readelf -S -l %t2 | FileCheck --check-prefix=CHECK2 %s 27# CHECK2: Name Type Address Off 28# CHECK2-NEXT: NULL 0000000000000000 000000 29# CHECK2-NEXT: .foo.text PROGBITS 0000000000201158 000158 30# CHECK2-NEXT: .text PROGBITS 0000000000201160 000160 31# CHECK2-NEXT: .foo.data PROGBITS 0000000000202168 000168 32# CHECK2-NEXT: .data PROGBITS 0000000000202170 000170 33# CHECK2: Type 34# CHECK2-NEXT: PHDR {{.*}} R 35# CHECK2-NEXT: LOAD {{.*}} R 36# CHECK2-NEXT: LOAD {{.*}} R E 37# CHECK2-NEXT: LOAD {{.*}} RW 38 39SECTIONS { .foo.data : { *(.foo.data) } } INSERT BEFORE .data; 40 41## The input section .foo.text is an orphan. It will be placed in .foo.text 42SECTIONS { .foo.text : {} } INSERT BEFORE .text; 43