2 # RUN: echo '.globl _start; _start: ret;' | \
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
4 # RUN: ld.lld -T %s %t.o -o %t
5 # RUN: llvm-readelf -S -l %t | FileCheck %s
7 # CHECK: Name Type Address Off Size ES Flg Lk Inf Al
8 # CHECK-NEXT: NULL 0000000000000000 000000 000000 00 0 0 0
9 # CHECK-NEXT: .text PROGBITS 0000000008000000 001000 000001 00 AX 0 0 4
10 # CHECK-NEXT: .data PROGBITS 0000000020000000 002000 000006 00 A 0 0 8
11 # CHECK-NEXT: .data2 PROGBITS 000000000800000e 00200e 000008 00 A 0 0 1
12 # CHECK-NEXT: .data3 PROGBITS 0000000020000008 002018 000000 00 A 0 0 8
13 # CHECK-NEXT: .data4 PROGBITS 0000000008000018 002018 000008 00 A 0 0 1
16 # CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
17 # CHECK-NEXT: LOAD 0x001000 0x0000000008000000 0x0000000008000000 0x000001 0x000001 R E 0x1000
18 # CHECK-NEXT: LOAD 0x002000 0x0000000020000000 0x0000000008000008 0x000006 0x000006 R 0x1000
19 # CHECK-NEXT: LOAD 0x00200e 0x000000000800000e 0x000000000800000e 0x000008 0x000008 R 0x1000
20 # CHECK-NEXT: LOAD 0x002018 0x0000000008000018 0x0000000008000018 0x000008 0x000008 R 0x1000
23 CODE (rx) : ORIGIN = 0x08000000, LENGTH = 100K
24 DATA (rw) : ORIGIN = 0x20000000, LENGTH = 100K
28 .text : { *(.text) } > CODE
29 ## Aligning the start address of .data to 8 should also increase the location counter of CODE.
30 .data : ALIGN(8) { . += 6; } > DATA AT> CODE
31 .data2 : { . += 8; } > CODE
32 ## Also an empty output section with an alignment requirement increases the location counter.
33 .data3 : ALIGN(8) { . = ALIGN(. != 0 ? 4 : 1); } > DATA AT> CODE
34 .data4 : { . += 8; } > CODE