33 AArch64ELFObjectWriter(
uint8_t OSABI,
bool IsILP32);
35 ~AArch64ELFObjectWriter()
override =
default;
41 unsigned Type)
const override;
47AArch64ELFObjectWriter::AArch64ELFObjectWriter(
uint8_t OSABI,
bool IsILP32)
53 IsILP32 ? ELF::R_AARCH64_P32_##rtype : ELF::R_AARCH64_##rtype
54#define BAD_ILP32_MOV(lp64rtype) \
55 "ILP32 absolute MOV relocation not " \
56 "supported (LP64 eqv: " #lp64rtype ")"
107unsigned AArch64ELFObjectWriter::getRelocType(
MCContext &Ctx,
110 bool IsPCRel)
const {
123 "Should only be expression-level modifiers here");
127 "Should only be expression-level modifiers here");
133 return ELF::R_AARCH64_NONE;
135 return R_CLS(PREL16);
144 "ILP32 8 byte PC relative data "
145 "relocation not supported (LP64 eqv: PREL64)");
146 return ELF::R_AARCH64_NONE;
148 return ELF::R_AARCH64_PREL64;
153 "ILP32 ADR AUTH relocation not supported "
154 "(LP64 eqv: AUTH_GOT_ADR_PREL_LO21)");
155 return ELF::R_AARCH64_NONE;
157 return ELF::R_AARCH64_AUTH_GOT_ADR_PREL_LO21;
161 "invalid symbol kind for ADR relocation");
162 return R_CLS(ADR_PREL_LO21);
165 return R_CLS(ADR_PREL_PG_HI21);
169 "invalid fixup for 32-bit pcrel ADRP instruction "
171 return ELF::R_AARCH64_NONE;
173 return ELF::R_AARCH64_ADR_PREL_PG_HI21_NC;
176 return R_CLS(ADR_GOT_PAGE);
180 "ILP32 ADRP AUTH relocation not supported "
181 "(LP64 eqv: AUTH_ADR_GOT_PAGE)");
182 return ELF::R_AARCH64_NONE;
184 return ELF::R_AARCH64_AUTH_ADR_GOT_PAGE;
187 return R_CLS(TLSIE_ADR_GOTTPREL_PAGE21);
189 return R_CLS(TLSDESC_ADR_PAGE21);
193 "ILP32 ADRP AUTH relocation not supported "
194 "(LP64 eqv: AUTH_TLSDESC_ADR_PAGE21)");
195 return ELF::R_AARCH64_NONE;
197 return ELF::R_AARCH64_AUTH_TLSDESC_ADR_PAGE21;
200 "invalid symbol kind for ADRP relocation");
201 return ELF::R_AARCH64_NONE;
203 return R_CLS(JUMP26);
205 return R_CLS(CALL26);
208 return R_CLS(TLSIE_LD_GOTTPREL_PREL19);
210 return R_CLS(GOT_LD_PREL19);
214 "ILP32 LDR AUTH relocation not supported "
215 "(LP64 eqv: AUTH_GOT_LD_PREL19)");
216 return ELF::R_AARCH64_NONE;
218 return ELF::R_AARCH64_AUTH_GOT_LD_PREL19;
220 return R_CLS(LD_PREL_LO19);
222 return R_CLS(TSTBR14);
225 "relocation of PAC/AUT instructions is not supported");
226 return ELF::R_AARCH64_NONE;
230 "relocation of compare-and-branch instructions not supported");
231 return ELF::R_AARCH64_NONE;
233 return R_CLS(CONDBR19);
236 return ELF::R_AARCH64_NONE;
240 return ELF::R_AARCH64_NONE;
241 switch (
Fixup.getTargetKind()) {
244 return ELF::R_AARCH64_NONE;
250 ? ELF::R_AARCH64_GOTPCREL32
257 Twine(
"ILP32 8 byte absolute data "
258 "relocation not supported (LP64 eqv: ") +
259 (IsAuth ?
"AUTH_ABS64" :
"ABS64") +
Twine(
')'));
260 return ELF::R_AARCH64_NONE;
262 return (IsAuth ? ELF::R_AARCH64_AUTH_ABS64 : ELF::R_AARCH64_ABS64);
266 return R_CLS(TLSLD_ADD_DTPREL_HI12);
268 return R_CLS(TLSLE_ADD_TPREL_HI12);
270 return R_CLS(TLSLD_ADD_DTPREL_LO12_NC);
272 return R_CLS(TLSLD_ADD_DTPREL_LO12);
274 return R_CLS(TLSLE_ADD_TPREL_LO12_NC);
276 return R_CLS(TLSLE_ADD_TPREL_LO12);
278 return R_CLS(TLSDESC_ADD_LO12);
282 "ILP32 ADD AUTH relocation not supported "
283 "(LP64 eqv: AUTH_TLSDESC_ADD_LO12)");
284 return ELF::R_AARCH64_NONE;
286 return ELF::R_AARCH64_AUTH_TLSDESC_ADD_LO12;
291 "ILP32 ADD AUTH relocation not supported "
292 "(LP64 eqv: AUTH_GOT_ADD_LO12_NC)");
293 return ELF::R_AARCH64_NONE;
295 return ELF::R_AARCH64_AUTH_GOT_ADD_LO12_NC;
298 return R_CLS(ADD_ABS_LO12_NC);
301 "invalid fixup for add (uimm12) instruction");
302 return ELF::R_AARCH64_NONE;
305 return R_CLS(LDST8_ABS_LO12_NC);
307 return R_CLS(TLSLD_LDST8_DTPREL_LO12);
309 return R_CLS(TLSLD_LDST8_DTPREL_LO12_NC);
311 return R_CLS(TLSLE_LDST8_TPREL_LO12);
313 return R_CLS(TLSLE_LDST8_TPREL_LO12_NC);
316 "invalid fixup for 8-bit load/store instruction");
317 return ELF::R_AARCH64_NONE;
320 return R_CLS(LDST16_ABS_LO12_NC);
322 return R_CLS(TLSLD_LDST16_DTPREL_LO12);
324 return R_CLS(TLSLD_LDST16_DTPREL_LO12_NC);
326 return R_CLS(TLSLE_LDST16_TPREL_LO12);
328 return R_CLS(TLSLE_LDST16_TPREL_LO12_NC);
331 "invalid fixup for 16-bit load/store instruction");
332 return ELF::R_AARCH64_NONE;
335 return R_CLS(LDST32_ABS_LO12_NC);
337 return R_CLS(TLSLD_LDST32_DTPREL_LO12);
339 return R_CLS(TLSLD_LDST32_DTPREL_LO12_NC);
341 return R_CLS(TLSLE_LDST32_TPREL_LO12);
343 return R_CLS(TLSLE_LDST32_TPREL_LO12_NC);
346 return ELF::R_AARCH64_P32_LD32_GOT_LO12_NC;
348 "LP64 4 byte unchecked GOT load/store relocation "
349 "not supported (ILP32 eqv: LD32_GOT_LO12_NC");
350 return ELF::R_AARCH64_NONE;
355 "ILP32 4 byte checked GOT load/store relocation "
356 "not supported (unchecked eqv: LD32_GOT_LO12_NC)");
359 "LP64 4 byte checked GOT load/store relocation "
360 "not supported (unchecked/ILP32 eqv: "
361 "LD32_GOT_LO12_NC)");
363 return ELF::R_AARCH64_NONE;
367 return ELF::R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC;
369 "relocation not supported (ILP32 eqv: "
370 "TLSIE_LD32_GOTTPREL_LO12_NC)");
371 return ELF::R_AARCH64_NONE;
375 return ELF::R_AARCH64_P32_TLSDESC_LD32_LO12;
377 "LP64 4 byte TLSDESC load/store relocation "
378 "not supported (ILP32 eqv: TLSDESC_LD64_LO12)");
379 return ELF::R_AARCH64_NONE;
383 "invalid fixup for 32-bit load/store instruction "
384 "fixup_aarch64_ldst_imm12_scale4");
385 return ELF::R_AARCH64_NONE;
388 return R_CLS(LDST64_ABS_LO12_NC);
397 return ELF::R_AARCH64_LD64_GOTPAGE_LO15;
398 return (IsAuth ? ELF::R_AARCH64_AUTH_LD64_GOT_LO12_NC
399 : ELF::R_AARCH64_LD64_GOT_LO12_NC);
402 Twine(
"ILP32 64-bit load/store "
403 "relocation not supported (LP64 eqv: ") +
404 (IsAuth ?
"AUTH_GOT_LO12_NC" :
"LD64_GOT_LO12_NC") +
406 return ELF::R_AARCH64_NONE;
409 return R_CLS(TLSLD_LDST64_DTPREL_LO12);
411 return R_CLS(TLSLD_LDST64_DTPREL_LO12_NC);
413 return R_CLS(TLSLE_LDST64_TPREL_LO12);
415 return R_CLS(TLSLE_LDST64_TPREL_LO12_NC);
418 return ELF::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
420 "relocation not supported (LP64 eqv: "
421 "TLSIE_LD64_GOTTPREL_LO12_NC)");
422 return ELF::R_AARCH64_NONE;
426 return ELF::R_AARCH64_TLSDESC_LD64_LO12;
428 "relocation not supported (LP64 eqv: "
429 "TLSDESC_LD64_LO12)");
430 return ELF::R_AARCH64_NONE;
434 return ELF::R_AARCH64_AUTH_TLSDESC_LD64_LO12;
436 "relocation not supported (LP64 eqv: "
437 "AUTH_TLSDESC_LD64_LO12)");
438 return ELF::R_AARCH64_NONE;
441 "invalid fixup for 64-bit load/store instruction");
442 return ELF::R_AARCH64_NONE;
445 return R_CLS(LDST128_ABS_LO12_NC);
447 return R_CLS(TLSLD_LDST128_DTPREL_LO12);
449 return R_CLS(TLSLD_LDST128_DTPREL_LO12_NC);
451 return R_CLS(TLSLE_LDST128_TPREL_LO12);
453 return R_CLS(TLSLE_LDST128_TPREL_LO12_NC);
456 "invalid fixup for 128-bit load/store instruction");
457 return ELF::R_AARCH64_NONE;
461 return ELF::R_AARCH64_MOVW_UABS_G3;
463 return ELF::R_AARCH64_MOVW_UABS_G2;
465 return ELF::R_AARCH64_MOVW_SABS_G2;
467 return ELF::R_AARCH64_MOVW_UABS_G2_NC;
469 return R_CLS(MOVW_UABS_G1);
471 return ELF::R_AARCH64_MOVW_SABS_G1;
473 return ELF::R_AARCH64_MOVW_UABS_G1_NC;
475 return R_CLS(MOVW_UABS_G0);
477 return R_CLS(MOVW_SABS_G0);
479 return R_CLS(MOVW_UABS_G0_NC);
481 return ELF::R_AARCH64_MOVW_PREL_G3;
483 return ELF::R_AARCH64_MOVW_PREL_G2;
485 return ELF::R_AARCH64_MOVW_PREL_G2_NC;
487 return R_CLS(MOVW_PREL_G1);
489 return ELF::R_AARCH64_MOVW_PREL_G1_NC;
491 return R_CLS(MOVW_PREL_G0);
493 return R_CLS(MOVW_PREL_G0_NC);
495 return ELF::R_AARCH64_TLSLD_MOVW_DTPREL_G2;
497 return R_CLS(TLSLD_MOVW_DTPREL_G1);
499 return ELF::R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC;
501 return R_CLS(TLSLD_MOVW_DTPREL_G0);
503 return R_CLS(TLSLD_MOVW_DTPREL_G0_NC);
505 return ELF::R_AARCH64_TLSLE_MOVW_TPREL_G2;
507 return R_CLS(TLSLE_MOVW_TPREL_G1);
509 return ELF::R_AARCH64_TLSLE_MOVW_TPREL_G1_NC;
511 return R_CLS(TLSLE_MOVW_TPREL_G0);
513 return R_CLS(TLSLE_MOVW_TPREL_G0_NC);
515 return ELF::R_AARCH64_TLSIE_MOVW_GOTTPREL_G1;
517 return ELF::R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC;
519 "invalid fixup for movz/movk instruction");
520 return ELF::R_AARCH64_NONE;
523 return ELF::R_AARCH64_NONE;
530bool AArch64ELFObjectWriter::needsRelocateWithSymbol(
const MCValue &Val,
536std::unique_ptr<MCObjectTargetWriter>
538 return std::make_unique<AArch64ELFObjectWriter>(OSABI, IsILP32);
#define BAD_ILP32_MOV(lp64rtype)
static bool isNonILP32reloc(const MCFixup &Fixup, AArch64MCExpr::VariantKind RefKind, MCContext &Ctx)
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static VariantKind getSymbolLoc(VariantKind Kind)
static bool isNotChecked(VariantKind Kind)
static VariantKind getAddressFrag(VariantKind Kind)
Context object for machine code objects.
void reportError(SMLoc L, const Twine &Msg)
virtual bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym, unsigned Type) const
virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const =0
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This represents an "assembler immediate".
uint32_t getRefKind() const
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ fixup_aarch64_pcrel_branch9
@ fixup_aarch64_pcrel_branch16
@ fixup_aarch64_ldst_imm12_scale4
@ fixup_aarch64_pcrel_call26
@ fixup_aarch64_pcrel_branch26
@ fixup_aarch64_pcrel_branch19
@ fixup_aarch64_ldr_pcrel_imm19
@ fixup_aarch64_pcrel_adr_imm21
@ fixup_aarch64_pcrel_branch14
@ fixup_aarch64_ldst_imm12_scale2
@ fixup_aarch64_ldst_imm12_scale16
@ fixup_aarch64_pcrel_adrp_imm21
@ fixup_aarch64_add_imm12
@ fixup_aarch64_ldst_imm12_scale8
@ fixup_aarch64_ldst_imm12_scale1
This is an optimization pass for GlobalISel generic memory operations.
@ FirstLiteralRelocationKind
The range [FirstLiteralRelocationKind, MaxTargetFixupKind) is used for relocations coming from ....
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_2
A two-byte fixup.
std::unique_ptr< MCObjectTargetWriter > createAArch64ELFObjectWriter(uint8_t OSABI, bool IsILP32)