@@ -40,6 +40,9 @@ class AArch64ELFObjectWriter : public MCELFObjectTargetWriter {
40
40
const MCFixup &Fixup, bool IsPCRel) const override ;
41
41
bool needsRelocateWithSymbol (const MCValue &Val, const MCSymbol &Sym,
42
42
unsigned Type) const override ;
43
+ bool isNonILP32reloc (const MCFixup &Fixup, AArch64MCExpr::Specifier RefKind,
44
+ MCContext &Ctx) const ;
45
+
43
46
bool IsILP32;
44
47
};
45
48
@@ -54,8 +57,9 @@ AArch64ELFObjectWriter::AArch64ELFObjectWriter(uint8_t OSABI, bool IsILP32)
54
57
IsILP32 ? ELF::R_AARCH64_P32_##rtype : ELF::R_AARCH64_##rtype
55
58
56
59
// assumes IsILP32 is true
57
- static bool isNonILP32reloc (const MCFixup &Fixup,
58
- AArch64MCExpr::Specifier RefKind, MCContext &Ctx) {
60
+ bool AArch64ELFObjectWriter::isNonILP32reloc (const MCFixup &Fixup,
61
+ AArch64MCExpr::Specifier RefKind,
62
+ MCContext &Ctx) const {
59
63
if (Fixup.getTargetKind () != AArch64::fixup_aarch64_movw)
60
64
return false ;
61
65
switch (RefKind) {
@@ -71,8 +75,8 @@ static bool isNonILP32reloc(const MCFixup &Fixup,
71
75
case AArch64MCExpr::VK_TPREL_G1_NC:
72
76
case AArch64MCExpr::VK_GOTTPREL_G1:
73
77
case AArch64MCExpr::VK_GOTTPREL_G0_NC:
74
- Ctx. reportError (Fixup.getLoc (),
75
- " absolute MOV relocation is not supported in ILP32" );
78
+ reportError (Fixup.getLoc (),
79
+ " absolute MOV relocation is not supported in ILP32" );
76
80
return true ;
77
81
default :
78
82
return false ;
@@ -111,7 +115,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
111
115
if (IsPCRel) {
112
116
switch (Kind) {
113
117
case FK_Data_1:
114
- Ctx. reportError (Fixup.getLoc (), " 1-byte data relocations not supported" );
118
+ reportError (Fixup.getLoc (), " 1-byte data relocations not supported" );
115
119
return ELF::R_AARCH64_NONE;
116
120
case FK_Data_2:
117
121
return R_CLS (PREL16);
@@ -123,32 +127,31 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
123
127
}
124
128
case FK_Data_8:
125
129
if (IsILP32) {
126
- Ctx. reportError (Fixup.getLoc (), " 8 byte PC relative data "
127
- " relocation is not supported in ILP32" );
130
+ reportError (Fixup.getLoc (), " 8 byte PC relative data "
131
+ " relocation is not supported in ILP32" );
128
132
return ELF::R_AARCH64_NONE;
129
133
}
130
134
return ELF::R_AARCH64_PREL64;
131
135
case AArch64::fixup_aarch64_pcrel_adr_imm21:
132
136
if (SymLoc == AArch64MCExpr::VK_GOT_AUTH) {
133
137
if (IsILP32) {
134
- Ctx. reportError (Fixup.getLoc (),
135
- " ADR AUTH relocation is not supported in ILP32" );
138
+ reportError (Fixup.getLoc (),
139
+ " ADR AUTH relocation is not supported in ILP32" );
136
140
return ELF::R_AARCH64_NONE;
137
141
}
138
142
return ELF::R_AARCH64_AUTH_GOT_ADR_PREL_LO21;
139
143
}
140
144
if (SymLoc != AArch64MCExpr::VK_ABS)
141
- Ctx.reportError (Fixup.getLoc (),
142
- " invalid symbol kind for ADR relocation" );
145
+ reportError (Fixup.getLoc (), " invalid symbol kind for ADR relocation" );
143
146
return R_CLS (ADR_PREL_LO21);
144
147
case AArch64::fixup_aarch64_pcrel_adrp_imm21:
145
148
if (SymLoc == AArch64MCExpr::VK_ABS && !IsNC)
146
149
return R_CLS (ADR_PREL_PG_HI21);
147
150
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC) {
148
151
if (IsILP32) {
149
- Ctx. reportError (Fixup.getLoc (),
150
- " invalid fixup for 32-bit pcrel ADRP instruction "
151
- " VK_ABS VK_NC" );
152
+ reportError (Fixup.getLoc (),
153
+ " invalid fixup for 32-bit pcrel ADRP instruction "
154
+ " VK_ABS VK_NC" );
152
155
return ELF::R_AARCH64_NONE;
153
156
}
154
157
return ELF::R_AARCH64_ADR_PREL_PG_HI21_NC;
@@ -157,8 +160,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
157
160
return R_CLS (ADR_GOT_PAGE);
158
161
if (SymLoc == AArch64MCExpr::VK_GOT_AUTH && !IsNC) {
159
162
if (IsILP32) {
160
- Ctx. reportError (Fixup.getLoc (),
161
- " ADRP AUTH relocation is not supported in ILP32" );
163
+ reportError (Fixup.getLoc (),
164
+ " ADRP AUTH relocation is not supported in ILP32" );
162
165
return ELF::R_AARCH64_NONE;
163
166
}
164
167
return ELF::R_AARCH64_AUTH_ADR_GOT_PAGE;
@@ -169,14 +172,13 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
169
172
return R_CLS (TLSDESC_ADR_PAGE21);
170
173
if (SymLoc == AArch64MCExpr::VK_TLSDESC_AUTH && !IsNC) {
171
174
if (IsILP32) {
172
- Ctx. reportError (Fixup.getLoc (),
173
- " ADRP AUTH relocation is not supported in ILP32" );
175
+ reportError (Fixup.getLoc (),
176
+ " ADRP AUTH relocation is not supported in ILP32" );
174
177
return ELF::R_AARCH64_NONE;
175
178
}
176
179
return ELF::R_AARCH64_AUTH_TLSDESC_ADR_PAGE21;
177
180
}
178
- Ctx.reportError (Fixup.getLoc (),
179
- " invalid symbol kind for ADRP relocation" );
181
+ reportError (Fixup.getLoc (), " invalid symbol kind for ADRP relocation" );
180
182
return ELF::R_AARCH64_NONE;
181
183
case AArch64::fixup_aarch64_pcrel_branch26:
182
184
return R_CLS (JUMP26);
@@ -189,8 +191,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
189
191
return R_CLS (GOT_LD_PREL19);
190
192
if (SymLoc == AArch64MCExpr::VK_GOT_AUTH) {
191
193
if (IsILP32) {
192
- Ctx. reportError (Fixup.getLoc (),
193
- " LDR AUTH relocation is not supported in ILP32" );
194
+ reportError (Fixup.getLoc (),
195
+ " LDR AUTH relocation is not supported in ILP32" );
194
196
return ELF::R_AARCH64_NONE;
195
197
}
196
198
return ELF::R_AARCH64_AUTH_GOT_LD_PREL19;
@@ -199,26 +201,26 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
199
201
case AArch64::fixup_aarch64_pcrel_branch14:
200
202
return R_CLS (TSTBR14);
201
203
case AArch64::fixup_aarch64_pcrel_branch16:
202
- Ctx. reportError (Fixup.getLoc (),
203
- " relocation of PAC/AUT instructions is not supported" );
204
+ reportError (Fixup.getLoc (),
205
+ " relocation of PAC/AUT instructions is not supported" );
204
206
return ELF::R_AARCH64_NONE;
205
207
case AArch64::fixup_aarch64_pcrel_branch9:
206
- Ctx. reportError (
208
+ reportError (
207
209
Fixup.getLoc (),
208
210
" relocation of compare-and-branch instructions not supported" );
209
211
return ELF::R_AARCH64_NONE;
210
212
case AArch64::fixup_aarch64_pcrel_branch19:
211
213
return R_CLS (CONDBR19);
212
214
default :
213
- Ctx. reportError (Fixup.getLoc (), " Unsupported pc-relative fixup kind" );
215
+ reportError (Fixup.getLoc (), " Unsupported pc-relative fixup kind" );
214
216
return ELF::R_AARCH64_NONE;
215
217
}
216
218
} else {
217
219
if (IsILP32 && isNonILP32reloc (Fixup, RefKind, Ctx))
218
220
return ELF::R_AARCH64_NONE;
219
221
switch (Fixup.getTargetKind ()) {
220
222
case FK_Data_1:
221
- Ctx. reportError (Fixup.getLoc (), " 1-byte data relocations not supported" );
223
+ reportError (Fixup.getLoc (), " 1-byte data relocations not supported" );
222
224
return ELF::R_AARCH64_NONE;
223
225
case FK_Data_2:
224
226
return R_CLS (ABS16);
@@ -229,7 +231,7 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
229
231
: R_CLS (ABS32);
230
232
case FK_Data_8: {
231
233
if (IsILP32) {
232
- Ctx. reportError (
234
+ reportError (
233
235
Fixup.getLoc (),
234
236
" 8 byte absolute data relocation is not supported in ILP32" );
235
237
return ELF::R_AARCH64_NONE;
@@ -256,25 +258,24 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
256
258
return R_CLS (TLSDESC_ADD_LO12);
257
259
if (RefKind == AArch64MCExpr::VK_TLSDESC_AUTH_LO12) {
258
260
if (IsILP32) {
259
- Ctx. reportError (Fixup.getLoc (),
260
- " ADD AUTH relocation is not supported in ILP32" );
261
+ reportError (Fixup.getLoc (),
262
+ " ADD AUTH relocation is not supported in ILP32" );
261
263
return ELF::R_AARCH64_NONE;
262
264
}
263
265
return ELF::R_AARCH64_AUTH_TLSDESC_ADD_LO12;
264
266
}
265
267
if (RefKind == AArch64MCExpr::VK_GOT_AUTH_LO12 && IsNC) {
266
268
if (IsILP32) {
267
- Ctx. reportError (Fixup.getLoc (),
268
- " ADD AUTH relocation is not supported in ILP32" );
269
+ reportError (Fixup.getLoc (),
270
+ " ADD AUTH relocation is not supported in ILP32" );
269
271
return ELF::R_AARCH64_NONE;
270
272
}
271
273
return ELF::R_AARCH64_AUTH_GOT_ADD_LO12_NC;
272
274
}
273
275
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC)
274
276
return R_CLS (ADD_ABS_LO12_NC);
275
277
276
- Ctx.reportError (Fixup.getLoc (),
277
- " invalid fixup for add (uimm12) instruction" );
278
+ reportError (Fixup.getLoc (), " invalid fixup for add (uimm12) instruction" );
278
279
return ELF::R_AARCH64_NONE;
279
280
case AArch64::fixup_aarch64_ldst_imm12_scale1:
280
281
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC)
@@ -288,8 +289,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
288
289
if (SymLoc == AArch64MCExpr::VK_TPREL && IsNC)
289
290
return R_CLS (TLSLE_LDST8_TPREL_LO12_NC);
290
291
291
- Ctx. reportError (Fixup.getLoc (),
292
- " invalid fixup for 8-bit load/store instruction" );
292
+ reportError (Fixup.getLoc (),
293
+ " invalid fixup for 8-bit load/store instruction" );
293
294
return ELF::R_AARCH64_NONE;
294
295
case AArch64::fixup_aarch64_ldst_imm12_scale2:
295
296
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC)
@@ -303,8 +304,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
303
304
if (SymLoc == AArch64MCExpr::VK_TPREL && IsNC)
304
305
return R_CLS (TLSLE_LDST16_TPREL_LO12_NC);
305
306
306
- Ctx. reportError (Fixup.getLoc (),
307
- " invalid fixup for 16-bit load/store instruction" );
307
+ reportError (Fixup.getLoc (),
308
+ " invalid fixup for 16-bit load/store instruction" );
308
309
return ELF::R_AARCH64_NONE;
309
310
case AArch64::fixup_aarch64_ldst_imm12_scale4:
310
311
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC)
@@ -320,13 +321,13 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
320
321
if (SymLoc == AArch64MCExpr::VK_GOT && IsNC) {
321
322
if (IsILP32)
322
323
return ELF::R_AARCH64_P32_LD32_GOT_LO12_NC;
323
- Ctx. reportError (Fixup.getLoc (), " 4 byte unchecked GOT load/store "
324
- " relocation is not supported in LP64" );
324
+ reportError (Fixup.getLoc (), " 4 byte unchecked GOT load/store "
325
+ " relocation is not supported in LP64" );
325
326
return ELF::R_AARCH64_NONE;
326
327
}
327
328
if (SymLoc == AArch64MCExpr::VK_GOT && !IsNC) {
328
329
if (IsILP32) {
329
- Ctx. reportError (
330
+ reportError (
330
331
Fixup.getLoc (),
331
332
" 4 byte checked GOT load/store relocation is not supported" );
332
333
}
@@ -335,22 +336,22 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
335
336
if (SymLoc == AArch64MCExpr::VK_GOTTPREL && IsNC) {
336
337
if (IsILP32)
337
338
return ELF::R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC;
338
- Ctx. reportError (Fixup.getLoc (), " 32-bit load/store "
339
- " relocation is not supported in LP64" );
339
+ reportError (Fixup.getLoc (), " 32-bit load/store "
340
+ " relocation is not supported in LP64" );
340
341
return ELF::R_AARCH64_NONE;
341
342
}
342
343
if (SymLoc == AArch64MCExpr::VK_TLSDESC && !IsNC) {
343
344
if (IsILP32)
344
345
return ELF::R_AARCH64_P32_TLSDESC_LD32_LO12;
345
- Ctx. reportError (
346
+ reportError (
346
347
Fixup.getLoc (),
347
348
" 4 byte TLSDESC load/store relocation is not supported in LP64" );
348
349
return ELF::R_AARCH64_NONE;
349
350
}
350
351
351
- Ctx. reportError (Fixup.getLoc (),
352
- " invalid fixup for 32-bit load/store instruction "
353
- " fixup_aarch64_ldst_imm12_scale4" );
352
+ reportError (Fixup.getLoc (),
353
+ " invalid fixup for 32-bit load/store instruction "
354
+ " fixup_aarch64_ldst_imm12_scale4" );
354
355
return ELF::R_AARCH64_NONE;
355
356
case AArch64::fixup_aarch64_ldst_imm12_scale8:
356
357
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC)
@@ -367,9 +368,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
367
368
return (IsAuth ? ELF::R_AARCH64_AUTH_LD64_GOT_LO12_NC
368
369
: ELF::R_AARCH64_LD64_GOT_LO12_NC);
369
370
}
370
- Ctx.reportError (
371
- Fixup.getLoc (),
372
- " 64-bit load/store relocation is not supported in ILP32" );
371
+ reportError (Fixup.getLoc (),
372
+ " 64-bit load/store relocation is not supported in ILP32" );
373
373
return ELF::R_AARCH64_NONE;
374
374
}
375
375
if (SymLoc == AArch64MCExpr::VK_DTPREL && !IsNC)
@@ -383,29 +383,27 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
383
383
if (SymLoc == AArch64MCExpr::VK_GOTTPREL && IsNC) {
384
384
if (!IsILP32)
385
385
return ELF::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
386
- Ctx.reportError (
387
- Fixup.getLoc (),
388
- " 64-bit load/store relocation is not supported in ILP32" );
386
+ reportError (Fixup.getLoc (),
387
+ " 64-bit load/store relocation is not supported in ILP32" );
389
388
return ELF::R_AARCH64_NONE;
390
389
}
391
390
if (SymLoc == AArch64MCExpr::VK_TLSDESC) {
392
391
if (!IsILP32)
393
392
return ELF::R_AARCH64_TLSDESC_LD64_LO12;
394
- Ctx.reportError (
395
- Fixup.getLoc (),
396
- " 64-bit load/store relocation is not supported in ILP32" );
393
+ reportError (Fixup.getLoc (),
394
+ " 64-bit load/store relocation is not supported in ILP32" );
397
395
return ELF::R_AARCH64_NONE;
398
396
}
399
397
if (SymLoc == AArch64MCExpr::VK_TLSDESC_AUTH) {
400
398
if (!IsILP32)
401
399
return ELF::R_AARCH64_AUTH_TLSDESC_LD64_LO12;
402
- Ctx. reportError (
400
+ reportError (
403
401
Fixup.getLoc (),
404
402
" 64-bit load/store AUTH relocation is not supported in ILP32" );
405
403
return ELF::R_AARCH64_NONE;
406
404
}
407
- Ctx. reportError (Fixup.getLoc (),
408
- " invalid fixup for 64-bit load/store instruction" );
405
+ reportError (Fixup.getLoc (),
406
+ " invalid fixup for 64-bit load/store instruction" );
409
407
return ELF::R_AARCH64_NONE;
410
408
case AArch64::fixup_aarch64_ldst_imm12_scale16:
411
409
if (SymLoc == AArch64MCExpr::VK_ABS && IsNC)
@@ -419,8 +417,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
419
417
if (SymLoc == AArch64MCExpr::VK_TPREL && IsNC)
420
418
return R_CLS (TLSLE_LDST128_TPREL_LO12_NC);
421
419
422
- Ctx. reportError (Fixup.getLoc (),
423
- " invalid fixup for 128-bit load/store instruction" );
420
+ reportError (Fixup.getLoc (),
421
+ " invalid fixup for 128-bit load/store instruction" );
424
422
return ELF::R_AARCH64_NONE;
425
423
// ILP32 case not reached here, tested with isNonILP32reloc
426
424
case AArch64::fixup_aarch64_movw:
@@ -482,11 +480,10 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
482
480
return ELF::R_AARCH64_TLSIE_MOVW_GOTTPREL_G1;
483
481
if (RefKind == AArch64MCExpr::VK_GOTTPREL_G0_NC)
484
482
return ELF::R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC;
485
- Ctx.reportError (Fixup.getLoc (),
486
- " invalid fixup for movz/movk instruction" );
483
+ reportError (Fixup.getLoc (), " invalid fixup for movz/movk instruction" );
487
484
return ELF::R_AARCH64_NONE;
488
485
default :
489
- Ctx. reportError (Fixup.getLoc (), " Unknown ELF relocation type" );
486
+ reportError (Fixup.getLoc (), " Unknown ELF relocation type" );
490
487
return ELF::R_AARCH64_NONE;
491
488
}
492
489
}
0 commit comments