File: subalign.s

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (60 lines) | stat: -rw-r--r-- 2,229 bytes parent folder | download | duplicates (5)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o

# RUN: echo "SECTIONS { .aaa : { *(.aaa.*) } }" > %t1.script
# RUN: ld.lld -o %t1 --script %t1.script %t1.o
# RUN: llvm-objdump -s %t1 | FileCheck -check-prefix=NOALIGN %s
# NOALIGN:      Contents of section .aaa:
# NOALIGN-NEXT:   01000000 00000000 00000000 00000000
# NOALIGN-NEXT:   00000000 00000000 00000000 00000000
# NOALIGN-NEXT:   02000000 00000000 00000000 00000000
# NOALIGN-NEXT:   00000000 00000000 00000000 00000000
# NOALIGN-NEXT:   03000000 00000000 00000000 00000000
# NOALIGN-NEXT:   00000000 00000000 00000000 00000000
# NOALIGN-NEXT:   00000000 00000000 00000000 00000000
# NOALIGN-NEXT:   00000000 00000000 00000000 00000000
# NOALIGN-NEXT:   04000000 00000000

# RUN: echo "SECTIONS { .aaa : SUBALIGN(1) { *(.aaa.*) } }" > %t2.script
# RUN: ld.lld -o %t2 --script %t2.script %t1.o
# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=SUBALIGN %s
# SUBALIGN: Contents of section .aaa:
# SUBALIGN:   01000000 00000000 02000000 00000000
# SUBALIGN:   03000000 00000000 04000000 00000000

## Test we do not assert or crash when dot(.) is used inside SUBALIGN.
## ld.bfd does not allow to use dot in such expressions, our behavior is
## different for simplicity of implementation. Value of dot is undefined.
# RUN: echo "SECTIONS { . = 0x32; .aaa : SUBALIGN(.) { *(.aaa*) } }" > %t3.script
# RUN: ld.lld %t1.o --script %t3.script -o %t3
# RUN: llvm-objdump -s %t3 > /dev/null

## Test we are able to link with zero alignment, this is consistent with bfd 2.26.1.
# RUN: echo "SECTIONS { .aaa : SUBALIGN(0) { *(.aaa*) } }" > %t4.script
# RUN: ld.lld %t1.o --script %t4.script -o %t4
# RUN: llvm-objdump -s %t4 | FileCheck -check-prefix=SUBALIGN %s

## Test we fail gracefuly when alignment value is not a power of 2.
# RUN: echo "SECTIONS { .aaa : SUBALIGN(3) { *(.aaa*) } }" > %t5.script
# RUN: not ld.lld %t1.o --script %t5.script -o /dev/null 2>&1 | FileCheck -check-prefix=ERR %s
# ERR: {{.*}}.script:1: alignment must be power of 2

.global _start
_start:
 nop

.section .aaa.1, "a"
.align 16
.quad 1

.section .aaa.2, "a"
.align 32
.quad 2

.section .aaa.3, "a"
.align 64
.quad 3

.section .aaa.4, "a"
.align 128
.quad 4