1
1
# REQUIRES: riscv
2
2
# RUN: rm -rf %t && split-file %s %t && cd %t
3
3
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax a.s -o a.o
4
- # RUN: llvm-readobj -r -x .debug_rnglists -x .debug_loclists a.o | FileCheck %s --check-prefix=REL
5
- # RUN: ld.lld -shared --gc-sections a.o -o a.so
6
- # RUN: llvm-readelf -x .debug_rnglists -x .debug_loclists a.so | FileCheck %s
4
+ # RUN: llvm-readobj -r -x .gcc_except_table -x . debug_rnglists -x .debug_loclists a.o | FileCheck %s --check-prefix=REL
5
+ # RUN: ld.lld -shared --gc-sections --noinhibit-exec a.o -o a.so
6
+ # RUN: llvm-readelf -x .gcc_except_table -x . debug_rnglists -x .debug_loclists a.so | FileCheck %s
7
7
8
8
# REL: .rela.debug_rnglists {
9
- # REL-NEXT: 0x0 R_RISCV_SET_ULEB128 w1 0x83
10
- # REL-NEXT: 0x0 R_RISCV_SUB_ULEB128 w2 0x0
9
+ # REL-NEXT: 0x0 R_RISCV_SET_ULEB128 w1 0x82
10
+ # REL-NEXT: 0x0 R_RISCV_SUB_ULEB128 w2 0xFFFFFFFFFFFFFFFF
11
11
# REL-NEXT: 0x1 R_RISCV_SET_ULEB128 w2 0x78
12
12
# REL-NEXT: 0x1 R_RISCV_SUB_ULEB128 w1 0x0
13
13
# REL-NEXT: 0x3 R_RISCV_SET_ULEB128 w1 0x89
28
28
# REL-NEXT: 0x1 R_RISCV_SUB_ULEB128 x1 0x0
29
29
# REL-NEXT: }
30
30
31
+ # REL: Hex dump of section '.gcc_except_table':
32
+ # REL-NEXT: 0x00000000 7b800181 01808001 81800180 80800181 {
33
+ # REL-NEXT: 0x00000010 808001 .
31
34
# REL: Hex dump of section '.debug_rnglists':
32
35
# REL-NEXT: 0x00000000 7b800181 01808001 81800180 80800181 {
33
36
# REL-NEXT: 0x00000010 808001 .
34
37
# REL: Hex dump of section '.debug_loclists':
35
38
# REL-NEXT: 0x00000000 0008 .
36
39
40
+ # CHECK: Hex dump of section '.gcc_except_table':
41
+ # CHECK-NEXT: 0x[[#%x,]] 7ffc0085 01fcff00 858001fc ffff0085 .
42
+ # CHECK-NEXT: 0x[[#%x,]] 808001 .
37
43
# CHECK: Hex dump of section '.debug_rnglists':
38
44
# CHECK-NEXT: 0x00000000 7ffc0085 01fcff00 858001fc ffff0085 .
39
45
# CHECK-NEXT: 0x00000010 808001 .
50
56
51
57
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax sub.s -o sub.o
52
58
# RUN: not ld.lld -shared sub.o 2>&1 | FileCheck %s --check-prefix=SUB
53
- # SUB: error: sub.o:(.debug_rnglists+0x8): unknown relocation (61) against symbol w2
59
+ # SUB: error: sub.o:(.debug_rnglists+0x8): has non-ABS relocation R_RISCV_SUB_ULEB128 against symbol 'w2'
54
60
55
61
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired1.s -o unpaired1.o
56
- # RUN: not ld.lld -shared unpaired1.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
62
+ # RUN: not ld.lld -shared --threads=1 unpaired1.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
57
63
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired2.s -o unpaired2.o
58
- # RUN: not ld.lld -shared unpaired2.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
64
+ # RUN: not ld.lld -shared --threads=1 unpaired2.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
59
65
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax unpaired3.s -o unpaired3.o
60
- # RUN: not ld.lld -shared unpaired3.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
66
+ # RUN: not ld.lld -shared --threads=1 unpaired3.o 2>&1 | FileCheck %s --check-prefix=UNPAIRED
67
+ # UNPAIRED: error: {{.*}}.o:(.alloc+0x8): R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128
61
68
# UNPAIRED: error: {{.*}}.o:(.debug_rnglists+0x8): R_RISCV_SET_ULEB128 not paired with R_RISCV_SUB_SET128
62
69
63
70
# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax overflow.s -o overflow.o
64
- # RUN: not ld.lld -shared overflow.o 2>&1 | FileCheck %s --check-prefix=OVERFLOW
71
+ # RUN: not ld.lld -shared --threads=1 overflow.o 2>&1 | FileCheck %s --check-prefix=OVERFLOW
72
+ # OVERFLOW: error: overflow.o:(.alloc+0x8): ULEB128 value 128 exceeds available space; references 'w2'
65
73
# OVERFLOW: error: overflow.o:(.debug_rnglists+0x8): ULEB128 value 128 exceeds available space; references 'w2'
66
74
75
+ # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax preemptable.s -o preemptable.o
76
+ # RUN: not ld.lld -shared --threads=1 preemptable.o 2>&1 | FileCheck %s --check-prefix=PREEMPTABLE --implicit-check-not=error:
77
+ # PREEMPTABLE: error: relocation R_RISCV_SET_ULEB128 cannot be used against symbol 'w2'; recompile with -fPIC
78
+ # PREEMPTABLE: error: relocation R_RISCV_SUB_ULEB128 cannot be used against symbol 'w1'; recompile with -fPIC
79
+
67
80
#--- a.s
81
+ .cfi_startproc
82
+ .cfi_lsda 0x1b ,.LLSDA0
83
+ .cfi_endproc
84
+
68
85
.section .text .w,"axR"
69
86
w1:
70
87
call foo # 4 bytes after relaxation
75
92
call foo # 4 bytes after relaxation
76
93
x2:
77
94
95
+ .section .gcc_except_table,"a"
96
+ .LLSDA0:
97
+ .reloc ., R_RISCV_SET_ULEB128, w1+130
98
+ .reloc ., R_RISCV_SUB_ULEB128, w2-1 # non-zero addend for SUB
99
+ .byte 0x7b
100
+ .uleb128 w2-w1+120 # initial value: 0x0180
101
+ .uleb128 w1-w2+137 # initial value: 0x0181
102
+ .uleb128 w2-w1+16376 # initial value: 0x018080
103
+ .uleb128 w1-w2+16393 # initial value: 0x018081
104
+ .uleb128 w2-w1+2097144 # initial value: 0x01808080
105
+ .uleb128 w1-w2+2097161 # initial value: 0x01808081
106
+
78
107
.section .debug_rnglists
79
- .uleb128 w1-w2+131 # initial value: 0x7b
108
+ .reloc ., R_RISCV_SET_ULEB128, w1+130
109
+ .reloc ., R_RISCV_SUB_ULEB128, w2-1 # non-zero addend for SUB
110
+ .byte 0x7b
80
111
.uleb128 w2-w1+120 # initial value: 0x0180
81
112
.uleb128 w1-w2+137 # initial value: 0x0181
82
113
.uleb128 w2-w1+16376 # initial value: 0x018080
@@ -99,13 +130,22 @@ w1: call foo; w2:
99
130
100
131
#--- unpaired1.s
101
132
w1: call foo; w2:
133
+ .section .alloc,"a"
134
+ .quad 0
135
+ .reloc ., R_RISCV_SET_ULEB128, w2+120
136
+ .byte 0x7f
102
137
.section .debug_rnglists
103
138
.quad 0 ;
104
139
.reloc ., R_RISCV_SET_ULEB128, w2+120
105
140
.byte 0x7f
106
141
107
142
#--- unpaired2.s
108
143
w1: call foo; w2:
144
+ .section .alloc,"a"
145
+ .quad 0
146
+ .reloc ., R_RISCV_SET_ULEB128, w2+120
147
+ .reloc .+1 , R_RISCV_SUB_ULEB128, w1
148
+ .byte 0x7f
109
149
.section .debug_rnglists
110
150
.quad 0
111
151
.reloc ., R_RISCV_SET_ULEB128, w2+120
@@ -114,6 +154,11 @@ w1: call foo; w2:
114
154
115
155
#--- unpaired3.s
116
156
w1: call foo; w2:
157
+ .section .alloc,"a"
158
+ .quad 0
159
+ .reloc ., R_RISCV_SET_ULEB128, w2+120
160
+ .reloc ., R_RISCV_SUB64, w1
161
+ .byte 0x7f
117
162
.section .debug_rnglists
118
163
.quad 0
119
164
.reloc ., R_RISCV_SET_ULEB128, w2+120
@@ -122,8 +167,21 @@ w1: call foo; w2:
122
167
123
168
#--- overflow.s
124
169
w1: call foo; w2:
170
+ .section .alloc,"a"
171
+ .quad 0
172
+ .reloc ., R_RISCV_SET_ULEB128, w2+124
173
+ .reloc ., R_RISCV_SUB_ULEB128, w1
174
+ .byte 0x7f
125
175
.section .debug_rnglists
126
176
.quad 0
127
177
.reloc ., R_RISCV_SET_ULEB128, w2+124
128
178
.reloc ., R_RISCV_SUB_ULEB128, w1
129
179
.byte 0x7f
180
+
181
+ #--- preemptable.s
182
+ .globl w1, w2
183
+ w1: call foo; w2:
184
+ .section .alloc,"a"
185
+ .uleb128 w2-w1
186
+ .section .debug_rnglists
187
+ .uleb128 w2-w1
0 commit comments