@@ -69,6 +69,11 @@ class AArch64AsmBackend : public MCAsmBackend {
69
69
{" fixup_aarch64_pcrel_call26" , 0 , 26 , PCRelFlagVal},
70
70
{" fixup_aarch64_tlsdesc_call" , 0 , 0 , 0 }};
71
71
72
+ // Fixup kinds from .reloc directive are like R_AARCH64_NONE. They do not
73
+ // require any extra processing.
74
+ if (Kind >= FirstLiteralRelocationKind)
75
+ return MCAsmBackend::getFixupKindInfo (FK_NONE);
76
+
72
77
if (Kind < FirstTargetFixupKind)
73
78
return MCAsmBackend::getFixupKindInfo (Kind);
74
79
@@ -109,7 +114,6 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
109
114
default :
110
115
llvm_unreachable (" Unknown fixup kind!" );
111
116
112
- case FK_NONE:
113
117
case AArch64::fixup_aarch64_tlsdesc_call:
114
118
return 0 ;
115
119
@@ -330,17 +334,24 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target,
330
334
if (!valueFitsIntoFixupKind (Fixup.getTargetKind (), Value))
331
335
Ctx.reportError (Fixup.getLoc (), " fixup value too large for data type!" );
332
336
LLVM_FALLTHROUGH;
333
- case FK_NONE:
334
337
case FK_SecRel_2:
335
338
case FK_SecRel_4:
336
339
return Value;
337
340
}
338
341
}
339
342
340
343
Optional<MCFixupKind> AArch64AsmBackend::getFixupKind (StringRef Name) const {
341
- if (TheTriple.isOSBinFormatELF () && Name == " R_AARCH64_NONE" )
342
- return FK_NONE;
343
- return MCAsmBackend::getFixupKind (Name);
344
+ if (!TheTriple.isOSBinFormatELF ())
345
+ return None;
346
+
347
+ unsigned Type = llvm::StringSwitch<unsigned >(Name)
348
+ #define ELF_RELOC (X, Y ) .Case(#X, Y)
349
+ #include " llvm/BinaryFormat/ELFRelocs/AArch64.def"
350
+ #undef ELF_RELOC
351
+ .Default (-1u );
352
+ if (Type == -1u )
353
+ return None;
354
+ return static_cast <MCFixupKind>(FirstLiteralRelocationKind + Type);
344
355
}
345
356
346
357
// / getFixupKindContainereSizeInBytes - The number of bytes of the
@@ -387,9 +398,12 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
387
398
MutableArrayRef<char > Data, uint64_t Value,
388
399
bool IsResolved,
389
400
const MCSubtargetInfo *STI) const {
390
- unsigned NumBytes = getFixupKindNumBytes (Fixup.getKind ());
391
401
if (!Value)
392
402
return ; // Doesn't change encoding.
403
+ unsigned Kind = Fixup.getKind ();
404
+ if (Kind >= FirstLiteralRelocationKind)
405
+ return ;
406
+ unsigned NumBytes = getFixupKindNumBytes (Kind);
393
407
MCFixupKindInfo Info = getFixupKindInfo (Fixup.getKind ());
394
408
MCContext &Ctx = Asm.getContext ();
395
409
int64_t SignedValue = static_cast <int64_t >(Value);
@@ -475,7 +489,7 @@ bool AArch64AsmBackend::shouldForceRelocation(const MCAssembler &Asm,
475
489
const MCFixup &Fixup,
476
490
const MCValue &Target) {
477
491
unsigned Kind = Fixup.getKind ();
478
- if (Kind == FK_NONE )
492
+ if (Kind >= FirstLiteralRelocationKind )
479
493
return true ;
480
494
481
495
// The ADRP instruction adds some multiple of 0x1000 to the current PC &
0 commit comments