1# REQUIRES: aarch64
2## Test ALIGN and its interaction with explicit output section addresses.
3
4# RUN: echo '.globl _start; _start: ret; .data.rel.ro; .balign 8; .byte 0; .data; .byte 0; \
5# RUN:   .section .data2,"aw"; .balign 8; .byte 0; .bss; .balign 32; .byte 0' | \
6# RUN:   llvm-mc -filetype=obj -triple=aarch64 - -o %t.o
7# RUN: ld.lld -T %s %t.o -o %t 2>&1 | FileCheck --check-prefix=WARN %s --implicit-check-not=warning:
8# RUN: llvm-readelf -S %t | FileCheck %s
9
10## Check we don't warn in the absence of SECTIONS.
11# RUN: ld.lld --fatal-warnings -Ttext=0x10000 %t.o -o /dev/null
12
13# WARN: warning: start of section .data.rel.ro changes from 0x10004 to 0x10010
14# WARN: warning: start of section .bss changes from 0x20009 to 0x20010
15
16# CHECK:      Name         Type     Address          Off    Size   ES Flg Lk Inf Al
17# CHECK-NEXT:              NULL     0000000000000000 000000 000000 00      0   0  0
18# CHECK-NEXT: .text        PROGBITS 0000000000010000 010000 000004 00  AX  0   0  4
19# CHECK-NEXT: .data.rel.ro PROGBITS 0000000000010010 010010 000001 00  WA  0   0 16
20# CHECK-NEXT: .data        PROGBITS 0000000000020000 020000 000001 00  WA  0   0  1
21# CHECK-NEXT: .data2       PROGBITS 0000000000020001 020001 000008 00  WA  0   0  8
22# CHECK-NEXT: .bss         NOBITS   0000000000020010 020009 000011 00  WA  0   0 32
23
24SECTIONS {
25  .text 0x10000 : { *(.text) }
26  ## sh_addr is aligned to 16.
27  .data.rel.ro . : ALIGN(16) { *(.data.rel.ro) }
28
29  .data 0x20000 : { *(.data) }
30  ## The output section address is set without ALIGN. sh_addr is set to Dot, ignoring alignment.
31  ## sh_addralign is the maximum of input section alignments, 8.
32  .data2 . : { *(.data2) }
33  ## sh_addr is aligned to 16.
34  ## The input section has a larger alignment and is thus preceded by a gap.
35  .bss . : ALIGN(16) { *(.bss) }
36}
37