1 // RUN
: llvm-mc
-triple
=arm64-linux-gnu
-o
- < %s | FileCheck
%s
2 // RUN
: llvm-mc
-triple
=arm64-linux-gnu
-show-encoding
-o
- < %s | \
3 // RUN
: FileCheck
--check-prefix
=CHECK-ENCODING
%s
4 // RUN
: llvm-mc
-triple
=arm64-linux-gnu
-filetype
=obj
< %s | \
5 // RUN
: llvm-objdump
-triple
=arm64-linux-gnu
- -r | \
6 // RUN
: FileCheck
%s
--check-prefix
=CHECK-OBJ-LP64
9 add x0
, x2
, #:lo12:sym+12
10 add x0
, x2
, #:lo12:sym-3
11 // CHECK
: add x0
, x2
, :lo12
:sym
12 // CHECK
: add x0
, x2
, :lo12
:sym+
12
13 // CHECK
: add x0
, x2
, :lo12
:sym-
3
14 // CHECK-OBJ-LP64
: 0 R_AARCH64_ADD_ABS_LO12_NC sym
15 // CHECK-OBJ-LP64
: 4 R_AARCH64_ADD_ABS_LO12_NC sym+
12
16 // CHECK-OBJ-LP64
: 8 R_AARCH64_ADD_ABS_LO12_NC sym-
3
18 add x5
, x7
, #:dtprel_lo12:sym
19 // CHECK
: add x5
, x7
, :dtprel_lo12
:sym
20 // CHECK-OBJ-LP64
: c R_AARCH64_TLSLD_ADD_DTPREL_LO12 sym
22 add x9
, x12
, #:dtprel_lo12_nc:sym
23 // CHECK
: add x9
, x12
, :dtprel_lo12_nc
:sym
24 // CHECK-OBJ-LP64
: 10 R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC sym
26 add x20
, x30
, #:tprel_lo12:sym
27 // CHECK
: add x20
, x30
, :tprel_lo12
:sym
28 // CHECK-OBJ-LP64
: 14 R_AARCH64_TLSLE_ADD_TPREL_LO12 sym
30 add x9
, x12
, #:tprel_lo12_nc:sym
31 // CHECK
: add x9
, x12
, :tprel_lo12_nc
:sym
32 // CHECK-OBJ-LP64
: 18 R_AARCH64_TLSLE_ADD_TPREL_LO12_NC sym
34 add x5
, x0
, #:tlsdesc_lo12:sym
35 // CHECK
: add x5
, x0
, :tlsdesc_lo12
:sym
36 // CHECK-OBJ-LP64
: 1c R_AARCH64_TLSDESC_ADD_LO12 sym
38 add x0
, x2
, #:lo12:sym+8
39 // CHECK
: add x0
, x2
, :lo12
:sym
40 // CHECK-OBJ-LP64
: 20 R_AARCH64_ADD_ABS_LO12_NC sym+
8
42 add x5
, x7
, #:dtprel_lo12:sym+1
43 // CHECK
: add x5
, x7
, :dtprel_lo12
:sym+
1
44 // CHECK-OBJ-LP64
: 24 R_AARCH64_TLSLD_ADD_DTPREL_LO12 sym+
1
46 add x9
, x12
, #:dtprel_lo12_nc:sym+2
47 // CHECK
: add x9
, x12
, :dtprel_lo12_nc
:sym+
2
48 // CHECK-OBJ-LP64
: 28 R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC sym+
2
50 add x20
, x30
, #:tprel_lo12:sym+12
51 // CHECK
: add x20
, x30
, :tprel_lo12
:sym+
12
52 // CHECK-OBJ-LP64
: 2c R_AARCH64_TLSLE_ADD_TPREL_LO12 sym+
12
54 add x9
, x12
, #:tprel_lo12_nc:sym+54
55 // CHECK
: add x9
, x12
, :tprel_lo12_nc
:sym+
54
56 // CHECK-OBJ-LP64
: 30 R_AARCH64_TLSLE_ADD_TPREL_LO12_NC sym+
54
58 add x5
, x0
, #:tlsdesc_lo12:sym+70
59 // CHECK
: add x5
, x0
, :tlsdesc_lo12
:sym+
70
60 // CHECK-OBJ-LP64
: 34 R_AARCH64_TLSDESC_ADD_LO12 sym+
70
63 // CHECK-OBJ-LP64
: 38 R_AARCH64_PREL16 sym+
4
65 // CHECK-OBJ-LP64
: 3a R_AARCH64_PREL32 sym+
8
67 // CHECK-OBJ-LP64
: 3e R_AARCH64_PREL64 sym
{{$
}}
70 // CHECK-OBJ-LP64
: 46 R_AARCH64_ABS16 sym
72 // CHECK-OBJ-LP64
: 48 R_AARCH64_ABS32 sym+
1
74 // CHECK-OBJ-LP64
: 4c R_AARCH64_ABS64 sym+
16
77 // CHECK
: adrp x0
, sym
78 // CHECK-OBJ-LP64
: 54 R_AARCH64_ADR_PREL_PG_HI21 sym
81 // CHECK
: adrp x15
, :got
:sym
82 // CHECK-OBJ-LP64
: 58 R_AARCH64_ADR_GOT_PAGE sym
84 adrp x29
, :gottprel
:sym
85 // CHECK
: adrp x29
, :gottprel
:sym
86 // CHECK-OBJ-LP64
: 5c R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 sym
89 // CHECK
: adrp x2
, :tlsdesc
:sym
90 // CHECK-OBJ-LP64
: 60 R_AARCH64_TLSDESC_ADR_PAGE21 sym
92 // LLVM is
not competent enough to do this relocation because the
93 // page boundary could occur anywhere after linking.
A relocation
95 adrp x3
, trickQuestion
98 // CHECK
: adrp x3
, trickQuestion
99 // CHECK-OBJ-LP64
: 64 R_AARCH64_ADR_PREL_PG_HI21 trickQuestion
101 ldrb w2
, [x3
, :lo12
:sym
]
102 ldrsb w5
, [x7
, #:lo12:sym]
103 ldrsb x11
, [x13
, :lo12
:sym
]
104 ldr b17
, [x19
, #:lo12:sym]
105 ldrb w2
, [x3
, :lo12
:sym+
15]
106 ldrsb w5
, [x7
, #:lo12:sym-2]
107 ldr b17
, [x19
, #:lo12:sym+4]
108 // CHECK
: ldrb w2
, [x3
, :lo12
:sym
]
109 // CHECK
: ldrsb w5
, [x7
, :lo12
:sym
]
110 // CHECK
: ldrsb x11
, [x13
, :lo12
:sym
]
111 // CHECK
: ldr b17
, [x19
, :lo12
:sym
]
112 // CHECK
: ldrb w2
, [x3
, :lo12
:sym+
15]
113 // CHECK
: ldrsb w5
, [x7
, :lo12
:sym-
2]
114 // CHECK
: ldr b17
, [x19
, :lo12
:sym+
4]
115 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym
116 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym
117 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym
118 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym
119 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym+
15
120 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym-
2
121 // CHECK-OBJ-LP64
: R_AARCH64_LDST8_ABS_LO12_NC sym+
4
123 ldrb w23
, [x29
, #:dtprel_lo12_nc:sym]
124 ldrsb w23
, [x19
, #:dtprel_lo12:sym]
125 ldrsb x17
, [x13
, :dtprel_lo12_nc
:sym
]
126 ldr b11
, [x7
, #:dtprel_lo12:sym]
127 ldrb w23
, [x29
, #:dtprel_lo12_nc:sym+2]
128 // CHECK
: ldrb w23
, [x29
, :dtprel_lo12_nc
:sym
]
129 // CHECK
: ldrsb w23
, [x19
, :dtprel_lo12
:sym
]
130 // CHECK
: ldrsb x17
, [x13
, :dtprel_lo12_nc
:sym
]
131 // CHECK
: ldr b11
, [x7
, :dtprel_lo12
:sym
]
132 // CHECK
: ldrb w23
, [x29
, :dtprel_lo12_nc
:sym+
2]
133 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC sym
134 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST8_DTPREL_LO12 sym
135 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC sym
136 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST8_DTPREL_LO12 sym
137 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC sym+
2
139 ldrb w1
, [x2
, :tprel_lo12
:sym
]
140 ldrsb w3
, [x4
, #:tprel_lo12_nc:sym]
141 ldrsb x5
, [x6
, :tprel_lo12
:sym
]
142 ldr b7
, [x8
, #:tprel_lo12_nc:sym]
143 // CHECK
: ldrb w1
, [x2
, :tprel_lo12
:sym
]
144 // CHECK
: ldrsb w3
, [x4
, :tprel_lo12_nc
:sym
]
145 // CHECK
: ldrsb x5
, [x6
, :tprel_lo12
:sym
]
146 // CHECK
: ldr b7
, [x8
, :tprel_lo12_nc
:sym
]
147 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST8_TPREL_LO12 sym
148 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC sym
149 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST8_TPREL_LO12 sym
150 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC sym
152 ldrh w2
, [x3
, #:lo12:sym]
153 ldrsh w5
, [x7
, :lo12
:sym
]
154 ldrsh x11
, [x13
, #:lo12:sym]
155 ldr h17
, [x19
, :lo12
:sym
]
156 ldrh w2
, [x3
, #:lo12:sym+4]
157 // CHECK
: ldrh w2
, [x3
, :lo12
:sym
]
158 // CHECK
: ldrsh w5
, [x7
, :lo12
:sym
]
159 // CHECK
: ldrsh x11
, [x13
, :lo12
:sym
]
160 // CHECK
: ldr h17
, [x19
, :lo12
:sym
]
161 // CHECK
: ldrh w2
, [x3
, :lo12
:sym+
4]
162 // CHECK-OBJ-LP64
: R_AARCH64_LDST16_ABS_LO12_NC sym
163 // CHECK-OBJ-LP64
: R_AARCH64_LDST16_ABS_LO12_NC sym
164 // CHECK-OBJ-LP64
: R_AARCH64_LDST16_ABS_LO12_NC sym
165 // CHECK-OBJ-LP64
: R_AARCH64_LDST16_ABS_LO12_NC sym
166 // CHECK-OBJ-LP64
: R_AARCH64_LDST16_ABS_LO12_NC sym+
4
168 ldrh w23
, [x29
, #:dtprel_lo12_nc:sym]
169 ldrsh w23
, [x19
, :dtprel_lo12
:sym
]
170 ldrsh x17
, [x13
, :dtprel_lo12_nc
:sym
]
171 ldr h11
, [x7
, #:dtprel_lo12:sym]
172 // CHECK
: ldrh w23
, [x29
, :dtprel_lo12_nc
:sym
]
173 // CHECK
: ldrsh w23
, [x19
, :dtprel_lo12
:sym
]
174 // CHECK
: ldrsh x17
, [x13
, :dtprel_lo12_nc
:sym
]
175 // CHECK
: ldr h11
, [x7
, :dtprel_lo12
:sym
]
176 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC sym
177 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST16_DTPREL_LO12 sym
178 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC sym
179 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST16_DTPREL_LO12 sym
181 ldrh w1
, [x2
, :tprel_lo12
:sym
]
182 ldrsh w3
, [x4
, #:tprel_lo12_nc:sym]
183 ldrsh x5
, [x6
, :tprel_lo12
:sym
]
184 ldr h7
, [x8
, #:tprel_lo12_nc:sym]
185 // CHECK
: ldrh w1
, [x2
, :tprel_lo12
:sym
]
186 // CHECK
: ldrsh w3
, [x4
, :tprel_lo12_nc
:sym
]
187 // CHECK
: ldrsh x5
, [x6
, :tprel_lo12
:sym
]
188 // CHECK
: ldr h7
, [x8
, :tprel_lo12_nc
:sym
]
189 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST16_TPREL_LO12 sym
190 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC sym
191 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST16_TPREL_LO12 sym
192 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC sym
194 ldr w1
, [x2
, #:lo12:sym]
195 ldrsw x3
, [x4
, #:lo12:sym]
196 ldr s4
, [x5
, :lo12
:sym
]
197 // CHECK
: ldr w1
, [x2
, :lo12
:sym
]
198 // CHECK
: ldrsw x3
, [x4
, :lo12
:sym
]
199 // CHECK
: ldr s4
, [x5
, :lo12
:sym
]
200 // CHECK-OBJ-LP64
: R_AARCH64_LDST32_ABS_LO12_NC sym
201 // CHECK-OBJ-LP64
: R_AARCH64_LDST32_ABS_LO12_NC sym
202 // CHECK-OBJ-LP64
: R_AARCH64_LDST32_ABS_LO12_NC sym
204 ldr w1
, [x2
, :dtprel_lo12
:sym
]
205 ldrsw x3
, [x4
, #:dtprel_lo12_nc:sym]
206 ldr s4
, [x5
, #:dtprel_lo12_nc:sym]
207 // CHECK
: ldr w1
, [x2
, :dtprel_lo12
:sym
]
208 // CHECK
: ldrsw x3
, [x4
, :dtprel_lo12_nc
:sym
]
209 // CHECK
: ldr s4
, [x5
, :dtprel_lo12_nc
:sym
]
210 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST32_DTPREL_LO12 sym
211 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC sym
212 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC sym
215 ldr w1
, [x2
, #:tprel_lo12:sym]
216 ldrsw x3
, [x4
, :tprel_lo12_nc
:sym
]
217 ldr s4
, [x5
, :tprel_lo12_nc
:sym
]
218 // CHECK
: ldr w1
, [x2
, :tprel_lo12
:sym
]
219 // CHECK
: ldrsw x3
, [x4
, :tprel_lo12_nc
:sym
]
220 // CHECK
: ldr s4
, [x5
, :tprel_lo12_nc
:sym
]
221 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST32_TPREL_LO12 sym
222 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC sym
223 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC sym
225 ldr x28
, [x27
, :lo12
:sym
]
226 ldr d26
, [x25
, #:lo12:sym]
227 ldr x28
, [x27
, :lo12
:sym+
10]
228 ldr x28
, [x27
, :lo12
:sym-
15]
229 // CHECK
: ldr x28
, [x27
, :lo12
:sym
]
230 // CHECK
: ldr d26
, [x25
, :lo12
:sym
]
231 // CHECK
: ldr x28
, [x27
, :lo12
:sym+
10]
232 // CHECK
: ldr x28
, [x27
, :lo12
:sym-
15]
233 // CHECK-OBJ-LP64
: R_AARCH64_LDST64_ABS_LO12_NC sym
234 // CHECK-OBJ-LP64
: R_AARCH64_LDST64_ABS_LO12_NC sym
235 // CHECK-OBJ-LP64
: R_AARCH64_LDST64_ABS_LO12_NC sym+
10
236 // CHECK-OBJ-LP64
: R_AARCH64_LDST64_ABS_LO12_NC sym-
15
238 ldr x24
, [x23
, #:got_lo12:sym]
239 ldr d22
, [x21
, :got_lo12
:sym
]
240 ldr x24
, [x23
, :got_lo12
:sym+
7]
241 // CHECK
: ldr x24
, [x23
, :got_lo12
:sym
]
242 // CHECK
: ldr d22
, [x21
, :got_lo12
:sym
]
243 // CHECK
: ldr x24
, [x23
, :got_lo12
:sym+
7]
244 // CHECK-OBJ-LP64
: R_AARCH64_LD64_GOT_LO12_NC sym
245 // CHECK-OBJ-LP64
: R_AARCH64_LD64_GOT_LO12_NC sym
246 // CHECK-OBJ-LP64
: R_AARCH64_LD64_GOT_LO12_NC sym+
7
248 ldr x24
, [x23
, :dtprel_lo12_nc
:sym
]
249 ldr d22
, [x21
, #:dtprel_lo12:sym]
250 // CHECK
: ldr x24
, [x23
, :dtprel_lo12_nc
:sym
]
251 // CHECK
: ldr d22
, [x21
, :dtprel_lo12
:sym
]
252 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC sym
253 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST64_DTPREL_LO12 sym
255 ldr q24
, [x23
, :dtprel_lo12_nc
:sym
]
256 ldr q22
, [x21
, #:dtprel_lo12:sym]
257 // CHECK
: ldr q24
, [x23
, :dtprel_lo12_nc
:sym
]
258 // CHECK
: ldr q22
, [x21
, :dtprel_lo12
:sym
]
259 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC sym
260 // CHECK-OBJ-LP64
: R_AARCH64_TLSLD_LDST128_DTPREL_LO12 sym
262 ldr x24
, [x23
, #:tprel_lo12:sym]
263 ldr d22
, [x21
, :tprel_lo12_nc
:sym
]
264 // CHECK
: ldr x24
, [x23
, :tprel_lo12
:sym
]
265 // CHECK
: ldr d22
, [x21
, :tprel_lo12_nc
:sym
]
266 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST64_TPREL_LO12 sym
267 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC sym
269 ldr q24
, [x23
, #:tprel_lo12:sym]
270 ldr q22
, [x21
, :tprel_lo12_nc
:sym
]
271 // CHECK
: ldr q24
, [x23
, :tprel_lo12
:sym
]
272 // CHECK
: ldr q22
, [x21
, :tprel_lo12_nc
:sym
]
273 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST128_TPREL_LO12 sym
274 // CHECK-OBJ-LP64
: R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC sym
276 ldr x24
, [x23
, :gottprel_lo12
:sym
]
277 ldr d22
, [x21
, #:gottprel_lo12:sym]
278 // CHECK
: ldr x24
, [x23
, :gottprel_lo12
:sym
]
279 // CHECK
: ldr d22
, [x21
, :gottprel_lo12
:sym
]
280 // CHECK-OBJ-LP64
: R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC sym
281 // CHECK-OBJ-LP64
: R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC sym
283 ldr x24
, [x23
, #:tlsdesc_lo12:sym]
284 ldr d22
, [x21
, :tlsdesc_lo12
:sym
]
285 // CHECK
: ldr x24
, [x23
, :tlsdesc_lo12
:sym
]
286 // CHECK
: ldr d22
, [x21
, :tlsdesc_lo12
:sym
]
287 // CHECK-OBJ-LP64
: R_AARCH64_TLSDESC_LD64_LO12 sym
288 // CHECK-OBJ-LP64
: R_AARCH64_TLSDESC_LD64_LO12 sym
290 ldr q20
, [x19
, #:lo12:sym]
291 // CHECK
: ldr q20
, [x19
, :lo12
:sym
]
292 // CHECK-OBJ-LP64
: R_AARCH64_LDST128_ABS_LO12_NC sym
293 // check encoding here
, since encoding test doesn
't belong with TLS encoding
294 // tests, as it isn't a TLS relocation.
295 // CHECK-ENCODING
: ldr q20
, [x19
, :lo12
:sym
] // encoding
: [0x74,0bAAAAAA10
,0b11AAAAAA
,0x3d]
296 // CHECK-ENCODING-NEXT
: 0, value
: :lo12
:sym
, kind
: fixup_aarch64_ldst_imm12_scale16
298 // Since relocated instructions print without
a '#', that syntax should
299 // certainly
be accepted when assembling.
300 add x3
, x5
, :lo12
:imm
301 // CHECK
: add x3
, x5
, :lo12
:imm
305 // CHECK
: ldr x24
, :got
:sym
306 // CHECK
: ldr d22
, :got
:sym
307 // CHECK-OBJ-LP64
: R_AARCH64_GOT_LD_PREL19 sym
308 // CHECK-OBJ-LP64
: R_AARCH64_GOT_LD_PREL19 sym