File: riscv-reloc-leb128.s

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 (187 lines) | stat: -rw-r--r-- 7,365 bytes parent folder | download | duplicates (10)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# REQUIRES: riscv
# RUN: rm -rf %t && split-file %s %t && cd %t
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax a.s -o a.o
# RUN: llvm-readobj -r -x .gcc_except_table -x .debug_rnglists -x .debug_loclists a.o | FileCheck %s --check-prefix=REL
# RUN: ld.lld -shared --gc-sections --noinhibit-exec a.o -o a.so
# RUN: llvm-readelf -x .gcc_except_table -x .debug_rnglists -x .debug_loclists a.so | FileCheck %s

# REL:      .rela.debug_rnglists {
# REL-NEXT:   0x0 R_RISCV_SET_ULEB128 w1 0x82
# REL-NEXT:   0x0 R_RISCV_SUB_ULEB128 w2 0xFFFFFFFFFFFFFFFF
# REL-NEXT:   0x1 R_RISCV_SET_ULEB128 w2 0x78
# REL-NEXT:   0x1 R_RISCV_SUB_ULEB128 w1 0x0
# REL-NEXT:   0x3 R_RISCV_SET_ULEB128 w1 0x89
# REL-NEXT:   0x3 R_RISCV_SUB_ULEB128 w2 0x0
# REL-NEXT:   0x5 R_RISCV_SET_ULEB128 w2 0x3FF8
# REL-NEXT:   0x5 R_RISCV_SUB_ULEB128 w1 0x0
# REL-NEXT:   0x8 R_RISCV_SET_ULEB128 w1 0x4009
# REL-NEXT:   0x8 R_RISCV_SUB_ULEB128 w2 0x0
# REL-NEXT:   0xB R_RISCV_SET_ULEB128 w2 0x1FFFF8
# REL-NEXT:   0xB R_RISCV_SUB_ULEB128 w1 0x0
# REL-NEXT:   0xF R_RISCV_SET_ULEB128 w1 0x200009
# REL-NEXT:   0xF R_RISCV_SUB_ULEB128 w2 0x0
# REL-NEXT: }
# REL:      .rela.debug_loclists {
# REL-NEXT:   0x0 R_RISCV_SET_ULEB128 w2 0x3
# REL-NEXT:   0x0 R_RISCV_SUB_ULEB128 w1 0x4
# REL-NEXT:   0x1 R_RISCV_SET_ULEB128 x2 0x0
# REL-NEXT:   0x1 R_RISCV_SUB_ULEB128 x1 0x0
# REL-NEXT: }

# REL:        Hex dump of section '.gcc_except_table':
# REL-NEXT:   0x00000000 7b800181 01808001 81800180 80800181 {
# REL-NEXT:   0x00000010 808001                              .
# REL:        Hex dump of section '.debug_rnglists':
# REL-NEXT:   0x00000000 7b800181 01808001 81800180 80800181 {
# REL-NEXT:   0x00000010 808001                              .
# REL:        Hex dump of section '.debug_loclists':
# REL-NEXT:   0x00000000 0008                                  .

# CHECK:      Hex dump of section '.gcc_except_table':
# CHECK-NEXT: 0x[[#%x,]] 7ffc0085 01fcff00 858001fc ffff0085 .
# CHECK-NEXT: 0x[[#%x,]] 808001                              .
# CHECK:      Hex dump of section '.debug_rnglists':
# CHECK-NEXT: 0x00000000 7ffc0085 01fcff00 858001fc ffff0085 .
# CHECK-NEXT: 0x00000010 808001                              .
# CHECK:      Hex dump of section '.debug_loclists':
# CHECK-NEXT: 0x00000000 0300                                .

# RUN: ld.lld -shared --gc-sections -z dead-reloc-in-nonalloc=.debug_loclists=0x7f a.o -o a127.so
# RUN: llvm-readelf -x .debug_loclists a127.so | FileCheck %s --check-prefix=CHECK127
# CHECK127:      Hex dump of section '.debug_loclists':
# CHECK127-NEXT: 0x00000000 037f                                .

# RUN: not ld.lld -shared --gc-sections -z dead-reloc-in-nonalloc=.debug_loclists=0x80 a.o 2>&1 | FileCheck %s --check-prefix=CHECK128
# CHECK128: error: a.o:(.debug_loclists+0x1): ULEB128 value 128 exceeds available space; references 'x2'

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax sub.s -o sub.o
# RUN: not ld.lld -shared sub.o 2>&1 | FileCheck %s --check-prefix=SUB
# SUB: error: sub.o:(.debug_rnglists+0x8): has non-ABS relocation R_RISCV_SUB_ULEB128 against symbol 'w2'

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired1.s -o unpaired1.o
# RUN: not ld.lld -shared --threads=1 unpaired1.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired2.s -o unpaired2.o
# RUN: not ld.lld -shared --threads=1 unpaired2.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired3.s -o unpaired3.o
# RUN: not ld.lld -shared --threads=1 unpaired3.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
# UNPAIRED: error: {{.*}}.o:(.alloc+0x8): R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128
# UNPAIRED: error: {{.*}}.o:(.debug_rnglists+0x8): R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax overflow.s -o overflow.o
# RUN: not ld.lld -shared --threads=1 overflow.o 2>&1 | FileCheck %s --check-prefix=OVERFLOW
# OVERFLOW: error: overflow.o:(.alloc+0x8): ULEB128 value 128 exceeds available space; references 'w2'
# OVERFLOW: error: overflow.o:(.debug_rnglists+0x8): ULEB128 value 128 exceeds available space; references 'w2'

# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax preemptable.s -o preemptable.o
# RUN: not ld.lld -shared --threads=1 preemptable.o 2>&1 | FileCheck %s --check-prefix=PREEMPTABLE --implicit-check-not=error:
# PREEMPTABLE: error: relocation R_RISCV_SET_ULEB128 cannot be used against symbol 'w2'; recompile with -fPIC
# PREEMPTABLE: error: relocation R_RISCV_SUB_ULEB128 cannot be used against symbol 'w1'; recompile with -fPIC

#--- a.s
.cfi_startproc
.cfi_lsda 0x1b,.LLSDA0
.cfi_endproc

.section .text.w,"axR"
w1:
  call foo    # 4 bytes after relaxation
w2:

.section .text.x,"ax"
x1:
  call foo    # 4 bytes after relaxation
x2:

.section .gcc_except_table,"a"
.LLSDA0:
.reloc ., R_RISCV_SET_ULEB128, w1+130
.reloc ., R_RISCV_SUB_ULEB128, w2-1  # non-zero addend for SUB
.byte 0x7b
.uleb128 w2-w1+120                   # initial value: 0x0180
.uleb128 w1-w2+137                   # initial value: 0x0181
.uleb128 w2-w1+16376                 # initial value: 0x018080
.uleb128 w1-w2+16393                 # initial value: 0x018081
.uleb128 w2-w1+2097144               # initial value: 0x01808080
.uleb128 w1-w2+2097161               # initial value: 0x01808081

.section .debug_rnglists
.reloc ., R_RISCV_SET_ULEB128, w1+130
.reloc ., R_RISCV_SUB_ULEB128, w2-1  # non-zero addend for SUB
.byte 0x7b
.uleb128 w2-w1+120                   # initial value: 0x0180
.uleb128 w1-w2+137                   # initial value: 0x0181
.uleb128 w2-w1+16376                 # initial value: 0x018080
.uleb128 w1-w2+16393                 # initial value: 0x018081
.uleb128 w2-w1+2097144               # initial value: 0x01808080
.uleb128 w1-w2+2097161               # initial value: 0x01808081

.section .debug_loclists
.reloc ., R_RISCV_SET_ULEB128, w2+3
.reloc ., R_RISCV_SUB_ULEB128, w1+4  # SUB with a non-zero addend
.byte 0
.uleb128 x2-x1                       # references discarded symbols

#--- sub.s
w1: call foo; w2:
.section .debug_rnglists
.quad 0;
.reloc ., R_RISCV_SUB_ULEB128, w2+120
.byte 0x7f

#--- unpaired1.s
w1: call foo; w2:
.section .alloc,"a"
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+120
.byte 0x7f
.section .debug_rnglists
.quad 0;
.reloc ., R_RISCV_SET_ULEB128, w2+120
.byte 0x7f

#--- unpaired2.s
w1: call foo; w2:
.section .alloc,"a"
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+120
.reloc .+1, R_RISCV_SUB_ULEB128, w1
.byte 0x7f
.section .debug_rnglists
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+120
.reloc .+1, R_RISCV_SUB_ULEB128, w1
.byte 0x7f

#--- unpaired3.s
w1: call foo; w2:
.section .alloc,"a"
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+120
.reloc ., R_RISCV_SUB64, w1
.byte 0x7f
.section .debug_rnglists
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+120
.reloc ., R_RISCV_SUB64, w1
.byte 0x7f

#--- overflow.s
w1: call foo; w2:
.section .alloc,"a"
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+124
.reloc ., R_RISCV_SUB_ULEB128, w1
.byte 0x7f
.section .debug_rnglists
.quad 0
.reloc ., R_RISCV_SET_ULEB128, w2+124
.reloc ., R_RISCV_SUB_ULEB128, w1
.byte 0x7f

#--- preemptable.s
.globl w1, w2
w1: call foo; w2:
.section .alloc,"a"
.uleb128 w2-w1
.section .debug_rnglists
.uleb128 w2-w1