File: section-address-align.test

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (34 lines) | stat: -rw-r--r-- 1,579 bytes parent folder | download | duplicates (21)
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
# REQUIRES: x86
## Test ALIGN when specifying the output section address.

# RUN: echo '.globl _start; _start: ret; \
# RUN:   .data.rel.ro; .balign 8; .byte 0; \
# RUN:   .data; .byte 0; \
# RUN:   .bss; .balign 32; .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 %t | FileCheck %s

# WARN: warning: address (0x10004) of section .data.rel.ro is not a multiple of alignment (8)
# WARN: warning: address (0x20008) of section .bss is not a multiple of alignment (32)

# 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 0000000000010000 001000 000001 00  AX  0   0  4
# CHECK-NEXT: .data.rel.ro PROGBITS 0000000000010004 001004 000005 00  WA  0   0  8
# CHECK-NEXT: .data        PROGBITS 0000000000020000 002000 000001 00  WA  0   0  1
# CHECK-NEXT: .bss         NOBITS   0000000000020008 002001 000019 00  WA  0   0 32

SECTIONS {
  .text 0x10000 : { *(.text) }
  ## The output .data.rel.ro starts at 0x10004.
  ## The input .data.rel.ro starts at 0x10008 and ends at 0x10009.
  ## sh_size(.data.rel.ro) = 0x10009-0x10004 = 0x5.
  .data.rel.ro ALIGN(4) : { *(.data.rel.ro) }

  .data 0x20000 : { *(.data) }
  ## The output .bss starts at 0x20008.
  ## The input .bss starts at 0x20020 and ends at 0x20021.
  ## sh_size(.bss) = 0x20021-0x20008 = 0x19.
  .bss ALIGN(8) : { *(.bss) }
}