xref: /llvm-project/lld/test/ELF/linkerscript/section-include.test (revision f0374e7db2dd6effa9d38894522e7fcc6ebe53ac)
1# REQUIRES: x86
2
3# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
4# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
5# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
6
7## Empty include file.
8# RUN: rm -rf %t.dir && mkdir -p %t.dir
9# RUN: echo "" > %t.dir/inc.script
10# RUN: ld.lld -o %t.elf --script %s %t.o -L %t.dir
11# RUN: llvm-objdump --section-headers %t.elf | FileCheck %s --check-prefix=CHECK1
12# CHECK1:      .data         00000008 0000000000002000 DATA
13# CHECK1-NEXT: .data3        00000008 0000000000002008 DATA
14
15## Non-empty include file.
16# RUN: echo ".data2 : { QUAD(0) } > RAM" > %t.dir/inc.script
17# RUN: ld.lld -o %t.elf --script %s %t.o -L %t.dir
18# RUN: llvm-objdump --section-headers %t.elf | FileCheck %s --check-prefix=CHECK2
19# CHECK2:      .data         00000008 0000000000002000 DATA
20# CHECK2-NEXT: .data2        00000008 0000000000002008 DATA
21# CHECK2-NEXT: .data3        00000008 0000000000002010 DATA
22
23MEMORY {
24  ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
25  RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
26}
27
28SECTIONS {
29  .text : { *(.text*) } > ROM
30  .data : { *(.data*) } > RAM
31  INCLUDE "inc.script"
32  .data3 : { QUAD(0) } > RAM
33}
34