File: riscv-relax-align.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (161 lines) | stat: -rw-r--r-- 5,225 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# REQUIRES: riscv
## Test that we can handle R_RISCV_ALIGN.

# RUN: rm -rf %t && mkdir %t && cd %t

# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax %s -o 32.o
# RUN: ld.lld -Ttext=0x10000 32.o -o 32
# RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 32 | FileCheck %s
## R_RISCV_ALIGN is handled regarldess of --no-relax.
# RUN: ld.lld -Ttext=0x10000 --no-relax 32.o -o 32.norelax
# RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 32.norelax | FileCheck %s

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o 64.o
# RUN: ld.lld -Ttext=0x10000 64.o -o 64
# RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 64 | FileCheck %s
# RUN: ld.lld -Ttext=0x10000 --no-relax 64.o -o 64.norelax
# RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 64.norelax | FileCheck %s

# RUN: ld.lld -Ttext=0x10000 --gc-sections 64.o -o 64.gc
# RUN: llvm-objdump -td --no-show-raw-insn -M no-aliases 64.gc | FileCheck %s --check-prefix=GC

## -r keeps section contents unchanged.
# RUN: ld.lld -r 64.o -o 64.r
# RUN: llvm-objdump -dr --no-show-raw-insn -M no-aliases 64.r | FileCheck %s --check-prefix=CHECKR

# CHECK-DAG: 00010004 l       .text  {{0*}}1c a
# CHECK-DAG: 00010008 l       .text  {{0*}}28 b
# CHECK-DAG: 00010014 l       .text  {{0*}}20 c
# CHECK-DAG: 00010000 g       .text  {{0*}}38 _start

# CHECK:       <_start>:
# CHECK-NEXT:            addi    a0, a0, 1
# CHECK-EMPTY:
# CHECK-NEXT:  <a>:
# CHECK-NEXT:            addi    a0, a0, 2
# CHECK-EMPTY:
# CHECK-NEXT:  <b>:
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:    10010:  addi    a0, a0, 3
# CHECK-EMPTY:
# CHECK-NEXT:  <c>:
# CHECK-NEXT:            addi    a0, a0, 4
# CHECK-NEXT:            addi    a0, a0, 5
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:    10020:  addi    a0, a0, 6
# CHECK-NEXT:            addi    a0, a0, 7
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:    10030:  addi    a0, a0, 8
# CHECK-NEXT:            addi    a0, a0, 9
# CHECK-EMPTY:
# CHECK:       <e>:
# CHECK-NEXT:            addi    a0, a0, 1
# CHECK-EMPTY:
# CHECK-NEXT:  <f>:
# CHECK-NEXT:    10044:  addi    a0, a0, 2
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:            addi    zero, zero, 0
# CHECK-NEXT:    10060:  addi    a0, a0, 3
# CHECK-EMPTY:

## _start-0x10070 = 0x10000-0x10070 = -112
# CHECK:      <.L1>:
# CHECK-NEXT:   10070:  auipc   a0, 0
# CHECK-NEXT:           addi    a0, a0, -112
# CHECK-NEXT:           addi    zero, zero, 0
# CHECK-NEXT:           addi    zero, zero, 0
# CHECK-NEXT:           auipc   a0, 0
# CHECK-NEXT:           addi    a0, a0, -112
# CHECK-EMPTY:

# GC-DAG:       00010004 l       .text  {{0*}}1c a
# GC-DAG:       00010008 l       .text  {{0*}}28 b
# GC-DAG:       00010014 l       .text  {{0*}}20 c
# GC-DAG:       00010000 g       .text  {{0*}}38 _start
# GC:           <_start>:
# GC-NOT:       <d>:

# CHECKR:       <_start>:
# CHECKR-NEXT:          addi    a0, a0, 1
# CHECKR-EMPTY:
# CHECKR-NEXT:  <a>:
# CHECKR-NEXT:          addi    a0, a0, 2
# CHECKR-EMPTY:
# CHECKR-NEXT:  <b>:
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          0000000000000008:  R_RISCV_ALIGN        *ABS*+0xc
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    a0, a0, 3
# CHECKR-EMPTY:
# CHECKR-NEXT:  <c>:
# CHECKR-NEXT:          addi    a0, a0, 4
# CHECKR-NEXT:          addi    a0, a0, 5
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          0000000000000020:  R_RISCV_ALIGN        *ABS*+0x1c
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    a0, a0, 6
# CHECKR-NEXT:          addi    a0, a0, 7
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          0000000000000044:  R_RISCV_ALIGN        *ABS*+0xc
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    zero, zero, 0
# CHECKR-NEXT:          addi    a0, a0, 8
# CHECKR-NEXT:          addi    a0, a0, 9

.global _start
_start:
  addi a0, a0, 1
a:
  addi a0, a0, 2
b:
.balign 16
  addi a0, a0, 3
c:
  addi a0, a0, 4
  addi a0, a0, 5
.balign 32
.size a, . - a
  addi a0, a0, 6
  addi a0, a0, 7
.balign 16
.size b, . - b
  addi a0, a0, 8
.size c, . - c
  addi a0, a0, 9
.size _start, . - _start

## Test another text section.
.section .text2,"ax",@progbits
d:
e:
.balign 8
  addi a0, a0, 1
f:
  addi a0, a0, 2
.balign 32
.size d, . - d
  addi a0, a0, 3
.size e, . - e
.size f, . - f

## Test that matching HI20 can be found despite deleted bytes.
.section .pcrel,"ax",@progbits
.L1:
  auipc a0, %pcrel_hi(_start)
  addi a0, a0, %pcrel_lo(.L1)
.balign 16
.L2:
  auipc a0, %pcrel_hi(_start)
  addi a0, a0, %pcrel_lo(.L1)