xref: /llvm-project/lld/test/ELF/linkerscript/empty-sections-expressions.test (revision c49f83b6e9e383ac9df02ab4d95974d7bb1e5ddc)
1# REQUIRES: x86
2# RUN: echo ".text; nop; .data; .byte 0" \
3# RUN:   | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
4# RUN: ld.lld -o %t --script %s %t.o
5# RUN: llvm-readelf -S -l %t | FileCheck %s
6
7## Check we do not remove the empty output sections used in LOADADDR/ADDR
8## expressions and hence can evaluate the correct addresses.
9
10# CHECK:      Name   Type     Address          Off    Size
11# CHECK-NEXT:        NULL     0000000000000000 000000 000000
12# CHECK-NEXT: .empty PROGBITS 0000000000080000 000158 000000
13# CHECK-NEXT: .text  PROGBITS 0000000000080000 001000 000001
14# CHECK-NEXT: .data  PROGBITS 0000000000080001 001001 000001
15
16# CHECK:      Program Headers:
17# CHECK-NEXT:  Type Offset   VirtAddr           PhysAddr
18# CHECK-NEXT:  LOAD 0x001000 0x0000000000080000 0x0000000000080000
19# CHECK-NEXT:  LOAD 0x001001 0x0000000000080001 0x0000000000082000
20
21# CHECK:      Section to Segment mapping:
22# CHECK:       00 .text {{$}}
23# CHECK-NEXT:  01 .data {{$}}
24
25SECTIONS {
26 . = 0x00080000;
27 .empty  : { *(.empty ) }
28 .text   : AT(LOADADDR(.empty) + SIZEOF(.empty)) { *(.text) }
29 .data   : AT(ADDR(.empty) + 0x2000) { *(.data) }
30}
31