@@ -88,6 +88,9 @@ class AArch64AsmBackend : public MCAsmBackend {
88
88
unsigned getPointerSize () const { return 8 ; }
89
89
90
90
unsigned getFixupKindContainereSizeInBytes (unsigned Kind) const ;
91
+
92
+ bool shouldForceRelocation (const MCAssembler &Asm, const MCFixup &Fixup,
93
+ const MCValue &Target) override ;
91
94
};
92
95
93
96
} // end anonymous namespace
@@ -338,6 +341,26 @@ bool AArch64AsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
338
341
return true ;
339
342
}
340
343
344
+ bool AArch64AsmBackend::shouldForceRelocation (const MCAssembler &Asm,
345
+ const MCFixup &Fixup,
346
+ const MCValue &Target) {
347
+ // The ADRP instruction adds some multiple of 0x1000 to the current PC &
348
+ // ~0xfff. This means that the required offset to reach a symbol can vary by
349
+ // up to one step depending on where the ADRP is in memory. For example:
350
+ //
351
+ // ADRP x0, there
352
+ // there:
353
+ //
354
+ // If the ADRP occurs at address 0xffc then "there" will be at 0x1000 and
355
+ // we'll need that as an offset. At any other address "there" will be in the
356
+ // same page as the ADRP and the instruction should encode 0x0. Assuming the
357
+ // section isn't 0x1000-aligned, we therefore need to delegate this decision
358
+ // to the linker -- a relocation!
359
+ if ((uint32_t )Fixup.getKind () == AArch64::fixup_aarch64_pcrel_adrp_imm21)
360
+ return true ;
361
+ return false ;
362
+ }
363
+
341
364
namespace {
342
365
343
366
namespace CU {
@@ -544,31 +567,8 @@ class ELFAArch64AsmBackend : public AArch64AsmBackend {
544
567
MCObjectWriter *createObjectWriter (raw_pwrite_stream &OS) const override {
545
568
return createAArch64ELFObjectWriter (OS, OSABI, IsLittleEndian, IsILP32);
546
569
}
547
-
548
- bool shouldForceRelocation (const MCAssembler &Asm, const MCFixup &Fixup,
549
- const MCValue &Target) override ;
550
570
};
551
571
552
- bool ELFAArch64AsmBackend::shouldForceRelocation (const MCAssembler &Asm,
553
- const MCFixup &Fixup,
554
- const MCValue &Target) {
555
- // The ADRP instruction adds some multiple of 0x1000 to the current PC &
556
- // ~0xfff. This means that the required offset to reach a symbol can vary by
557
- // up to one step depending on where the ADRP is in memory. For example:
558
- //
559
- // ADRP x0, there
560
- // there:
561
- //
562
- // If the ADRP occurs at address 0xffc then "there" will be at 0x1000 and
563
- // we'll need that as an offset. At any other address "there" will be in the
564
- // same page as the ADRP and the instruction should encode 0x0. Assuming the
565
- // section isn't 0x1000-aligned, we therefore need to delegate this decision
566
- // to the linker -- a relocation!
567
- if ((uint32_t )Fixup.getKind () == AArch64::fixup_aarch64_pcrel_adrp_imm21)
568
- return true ;
569
- return false ;
570
- }
571
-
572
572
}
573
573
574
574
namespace {
0 commit comments