File: lma-align.test

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (36 lines) | stat: -rw-r--r-- 1,984 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# REQUIRES: x86
# RUN: echo '.globl _start; _start: ret; .data.rel.ro; .balign 16; .byte 0; \
# RUN:   .data; .balign 32; .byte 0; .bss; .byte 0' | \
# RUN:   llvm-mc -filetype=obj -triple=x86_64 - -o %t.o
# RUN: ld.lld -T %s %t.o -o %t 2>&1 | FileCheck --check-prefix=WARN %s --implicit-check-not=warning:
# RUN: llvm-readelf -S -l %t | FileCheck %s

# WARN: warning: address (0x11001) of section .data is not a multiple of alignment (32)
# WARN: warning: address (0x11021) of section .bss is not a multiple of alignment (64)

# CHECK:      Name         Type     Address          Off    Size   ES Flg Lk Inf Al
# CHECK-NEXT:              NULL     0000000000000000 000000 000000 00      0   0  0
# CHECK-NEXT: .text        PROGBITS 0000000000001000 001000 000001 00  AX  0   0  4
# CHECK-NEXT: .data.rel.ro PROGBITS 0000000000011000 002000 000001 00  WA  0   0 16
# CHECK-NEXT: .data        PROGBITS 0000000000011001 002001 000020 00  WA  0   0 32
# CHECK-NEXT: .bss         NOBITS   0000000000011021 002021 000001 00  WA  0   0 64

# CHECK:      Type  Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
# CHECK-NEXT: LOAD  0x001000 0x0000000000001000 0x0000000000001000 0x000001 0x000001 R E 0x1000
# CHECK-NEXT: LOAD  0x002000 0x0000000000011000 0x0000000000001010 0x000001 0x000001 RW  0x1000
# CHECK-NEXT: LOAD  0x002001 0x0000000000011001 0x0000000000001020 0x000020 0x000020 RW  0x1000
# CHECK-NEXT: LOAD  0x002021 0x0000000000011021 0x0000000000011021 0x000000 0x000001 RW  0x1000

MEMORY {
  ROM : ORIGIN = 0x1000, LENGTH = 1K
  RAM : ORIGIN = 0x11000, LENGTH = 1K
}
SECTIONS {
  .text 0x1000 : { *(.text*) } >ROM
  ## Input section alignment decides output section alignment.
  .data.rel.ro 0x11000 : { *(.data.rel.ro) } >RAM AT>ROM
  ## ALIGN decides output section alignment.
  .data . : ALIGN(16) { *(.data*) } >RAM AT>ROM
  ## Start a new PT_LOAD because the LMA region is different from the previous one.
  .bss . : ALIGN(64) { *(.bss*) } >RAM
}