33 AArch64ELFObjectWriter(uint8_t OSABI,
bool IsILP32);
35 ~AArch64ELFObjectWriter()
override =
default;
43 unsigned Type)
const override;
49AArch64ELFObjectWriter::AArch64ELFObjectWriter(uint8_t OSABI,
bool IsILP32)
55 IsILP32 ? ELF::R_AARCH64_P32_##rtype : ELF::R_AARCH64_##rtype
56#define BAD_ILP32_MOV(lp64rtype) \
57 "ILP32 absolute MOV relocation not " \
58 "supported (LP64 eqv: " #lp64rtype ")"
109unsigned AArch64ELFObjectWriter::getRelocType(
MCContext &Ctx,
112 bool IsPCRel)
const {
125 "Should only be expression-level modifiers here");
129 "Should only be expression-level modifiers here");
135 return ELF::R_AARCH64_NONE;
137 return R_CLS(PREL16);
146 "ILP32 8 byte PC relative data "
147 "relocation not supported (LP64 eqv: PREL64)");
148 return ELF::R_AARCH64_NONE;
150 return ELF::R_AARCH64_PREL64;
154 "invalid symbol kind for ADR relocation");
155 return R_CLS(ADR_PREL_LO21);
158 return R_CLS(ADR_PREL_PG_HI21);
162 "invalid fixup for 32-bit pcrel ADRP instruction "
164 return ELF::R_AARCH64_NONE;
166 return ELF::R_AARCH64_ADR_PREL_PG_HI21_NC;
169 return R_CLS(ADR_GOT_PAGE);
173 "ILP32 ADRP AUTH relocation not supported "
174 "(LP64 eqv: AUTH_ADR_GOT_PAGE)");
175 return ELF::R_AARCH64_NONE;
177 return ELF::R_AARCH64_AUTH_ADR_GOT_PAGE;
180 return R_CLS(TLSIE_ADR_GOTTPREL_PAGE21);
182 return R_CLS(TLSDESC_ADR_PAGE21);
184 "invalid symbol kind for ADRP relocation");
185 return ELF::R_AARCH64_NONE;
187 return R_CLS(JUMP26);
189 return R_CLS(CALL26);
192 return R_CLS(TLSIE_LD_GOTTPREL_PREL19);
194 return R_CLS(GOT_LD_PREL19);
195 return R_CLS(LD_PREL_LO19);
197 return R_CLS(TSTBR14);
200 "relocation of PAC/AUT instructions is not supported");
201 return ELF::R_AARCH64_NONE;
203 return R_CLS(CONDBR19);
206 return ELF::R_AARCH64_NONE;
210 return ELF::R_AARCH64_NONE;
211 switch (
Fixup.getTargetKind()) {
214 return ELF::R_AARCH64_NONE;
220 ? ELF::R_AARCH64_GOTPCREL32
227 Twine(
"ILP32 8 byte absolute data "
228 "relocation not supported (LP64 eqv: ") +
229 (IsAuth ?
"AUTH_ABS64" :
"ABS64") +
Twine(
')'));
230 return ELF::R_AARCH64_NONE;
232 return (IsAuth ? ELF::R_AARCH64_AUTH_ABS64 : ELF::R_AARCH64_ABS64);
236 return R_CLS(TLSLD_ADD_DTPREL_HI12);
238 return R_CLS(TLSLE_ADD_TPREL_HI12);
240 return R_CLS(TLSLD_ADD_DTPREL_LO12_NC);
242 return R_CLS(TLSLD_ADD_DTPREL_LO12);
244 return R_CLS(TLSLE_ADD_TPREL_LO12_NC);
246 return R_CLS(TLSLE_ADD_TPREL_LO12);
248 return R_CLS(TLSDESC_ADD_LO12);
252 "ILP32 ADD AUTH relocation not supported "
253 "(LP64 eqv: AUTH_GOT_ADD_LO12_NC)");
254 return ELF::R_AARCH64_NONE;
256 return ELF::R_AARCH64_AUTH_GOT_ADD_LO12_NC;
259 return R_CLS(ADD_ABS_LO12_NC);
262 "invalid fixup for add (uimm12) instruction");
263 return ELF::R_AARCH64_NONE;
266 return R_CLS(LDST8_ABS_LO12_NC);
268 return R_CLS(TLSLD_LDST8_DTPREL_LO12);
270 return R_CLS(TLSLD_LDST8_DTPREL_LO12_NC);
272 return R_CLS(TLSLE_LDST8_TPREL_LO12);
274 return R_CLS(TLSLE_LDST8_TPREL_LO12_NC);
277 "invalid fixup for 8-bit load/store instruction");
278 return ELF::R_AARCH64_NONE;
281 return R_CLS(LDST16_ABS_LO12_NC);
283 return R_CLS(TLSLD_LDST16_DTPREL_LO12);
285 return R_CLS(TLSLD_LDST16_DTPREL_LO12_NC);
287 return R_CLS(TLSLE_LDST16_TPREL_LO12);
289 return R_CLS(TLSLE_LDST16_TPREL_LO12_NC);
292 "invalid fixup for 16-bit load/store instruction");
293 return ELF::R_AARCH64_NONE;
296 return R_CLS(LDST32_ABS_LO12_NC);
298 return R_CLS(TLSLD_LDST32_DTPREL_LO12);
300 return R_CLS(TLSLD_LDST32_DTPREL_LO12_NC);
302 return R_CLS(TLSLE_LDST32_TPREL_LO12);
304 return R_CLS(TLSLE_LDST32_TPREL_LO12_NC);
307 return ELF::R_AARCH64_P32_LD32_GOT_LO12_NC;
309 "LP64 4 byte unchecked GOT load/store relocation "
310 "not supported (ILP32 eqv: LD32_GOT_LO12_NC");
311 return ELF::R_AARCH64_NONE;
316 "ILP32 4 byte checked GOT load/store relocation "
317 "not supported (unchecked eqv: LD32_GOT_LO12_NC)");
320 "LP64 4 byte checked GOT load/store relocation "
321 "not supported (unchecked/ILP32 eqv: "
322 "LD32_GOT_LO12_NC)");
324 return ELF::R_AARCH64_NONE;
328 return ELF::R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC;
330 "relocation not supported (ILP32 eqv: "
331 "TLSIE_LD32_GOTTPREL_LO12_NC)");
332 return ELF::R_AARCH64_NONE;
336 return ELF::R_AARCH64_P32_TLSDESC_LD32_LO12;
338 "LP64 4 byte TLSDESC load/store relocation "
339 "not supported (ILP32 eqv: TLSDESC_LD64_LO12)");
340 return ELF::R_AARCH64_NONE;
344 "invalid fixup for 32-bit load/store instruction "
345 "fixup_aarch64_ldst_imm12_scale4");
346 return ELF::R_AARCH64_NONE;
349 return R_CLS(LDST64_ABS_LO12_NC);
358 return ELF::R_AARCH64_LD64_GOTPAGE_LO15;
359 return (IsAuth ? ELF::R_AARCH64_AUTH_LD64_GOT_LO12_NC
360 : ELF::R_AARCH64_LD64_GOT_LO12_NC);
363 Twine(
"ILP32 64-bit load/store "
364 "relocation not supported (LP64 eqv: ") +
365 (IsAuth ?
"AUTH_GOT_LO12_NC" :
"LD64_GOT_LO12_NC") +
367 return ELF::R_AARCH64_NONE;
370 return R_CLS(TLSLD_LDST64_DTPREL_LO12);
372 return R_CLS(TLSLD_LDST64_DTPREL_LO12_NC);
374 return R_CLS(TLSLE_LDST64_TPREL_LO12);
376 return R_CLS(TLSLE_LDST64_TPREL_LO12_NC);
379 return ELF::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
381 "relocation not supported (LP64 eqv: "
382 "TLSIE_LD64_GOTTPREL_LO12_NC)");
383 return ELF::R_AARCH64_NONE;
387 return ELF::R_AARCH64_TLSDESC_LD64_LO12;
389 "relocation not supported (LP64 eqv: "
390 "TLSDESC_LD64_LO12)");
391 return ELF::R_AARCH64_NONE;
394 "invalid fixup for 64-bit load/store instruction");
395 return ELF::R_AARCH64_NONE;
398 return R_CLS(LDST128_ABS_LO12_NC);
400 return R_CLS(TLSLD_LDST128_DTPREL_LO12);
402 return R_CLS(TLSLD_LDST128_DTPREL_LO12_NC);
404 return R_CLS(TLSLE_LDST128_TPREL_LO12);
406 return R_CLS(TLSLE_LDST128_TPREL_LO12_NC);
409 "invalid fixup for 128-bit load/store instruction");
410 return ELF::R_AARCH64_NONE;
414 return ELF::R_AARCH64_MOVW_UABS_G3;
416 return ELF::R_AARCH64_MOVW_UABS_G2;
418 return ELF::R_AARCH64_MOVW_SABS_G2;
420 return ELF::R_AARCH64_MOVW_UABS_G2_NC;
422 return R_CLS(MOVW_UABS_G1);
424 return ELF::R_AARCH64_MOVW_SABS_G1;
426 return ELF::R_AARCH64_MOVW_UABS_G1_NC;
428 return R_CLS(MOVW_UABS_G0);
430 return R_CLS(MOVW_SABS_G0);
432 return R_CLS(MOVW_UABS_G0_NC);
434 return ELF::R_AARCH64_MOVW_PREL_G3;
436 return ELF::R_AARCH64_MOVW_PREL_G2;
438 return ELF::R_AARCH64_MOVW_PREL_G2_NC;
440 return R_CLS(MOVW_PREL_G1);
442 return ELF::R_AARCH64_MOVW_PREL_G1_NC;
444 return R_CLS(MOVW_PREL_G0);
446 return R_CLS(MOVW_PREL_G0_NC);
448 return ELF::R_AARCH64_TLSLD_MOVW_DTPREL_G2;
450 return R_CLS(TLSLD_MOVW_DTPREL_G1);
452 return ELF::R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC;
454 return R_CLS(TLSLD_MOVW_DTPREL_G0);
456 return R_CLS(TLSLD_MOVW_DTPREL_G0_NC);
458 return ELF::R_AARCH64_TLSLE_MOVW_TPREL_G2;
460 return R_CLS(TLSLE_MOVW_TPREL_G1);
462 return ELF::R_AARCH64_TLSLE_MOVW_TPREL_G1_NC;
464 return R_CLS(TLSLE_MOVW_TPREL_G0);
466 return R_CLS(TLSLE_MOVW_TPREL_G0_NC);
468 return ELF::R_AARCH64_TLSIE_MOVW_GOTTPREL_G1;
470 return ELF::R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC;
472 "invalid fixup for movz/movk instruction");
473 return ELF::R_AARCH64_NONE;
476 return ELF::R_AARCH64_NONE;
483bool AArch64ELFObjectWriter::needsRelocateWithSymbol(
const MCValue &Val,
490AArch64ELFObjectWriter::getMemtagRelocsSection(
MCContext &Ctx)
const {
495std::unique_ptr<MCObjectTargetWriter>
497 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.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
void reportError(SMLoc L, const Twine &Msg)
virtual bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym, unsigned Type) const
virtual MCSectionELF * getMemtagRelocsSection(MCContext &Ctx) 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)...
This represents a section on linux, lots of unix variants and some bare metal systems.
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_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
@ SHT_AARCH64_MEMTAG_GLOBALS_STATIC
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)