@@ -48,10 +48,17 @@ class ARMELFObjectWriter : public MCELFObjectTargetWriter {
48
48
} // end anonymous namespace
49
49
50
50
Optional<MCFixupKind> ARMAsmBackend::getFixupKind (StringRef Name) const {
51
- if (STI.getTargetTriple ().isOSBinFormatELF () && Name == " R_ARM_NONE" )
52
- return FK_NONE;
53
-
54
- return MCAsmBackend::getFixupKind (Name);
51
+ if (!STI.getTargetTriple ().isOSBinFormatELF ())
52
+ return None;
53
+
54
+ unsigned Type = llvm::StringSwitch<unsigned >(Name)
55
+ #define ELF_RELOC (X, Y ) .Case(#X, Y)
56
+ #include " llvm/BinaryFormat/ELFRelocs/ARM.def"
57
+ #undef ELF_RELOC
58
+ .Default (-1u );
59
+ if (Type == -1u )
60
+ return None;
61
+ return static_cast <MCFixupKind>(FirstLiteralRelocationKind + Type);
55
62
}
56
63
57
64
const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo (MCFixupKind Kind) const {
@@ -172,6 +179,11 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
172
179
{" fixup_le" , 0 , 32 , MCFixupKindInfo::FKF_IsPCRel}
173
180
};
174
181
182
+ // Fixup kinds from .reloc directive are like R_ARM_NONE. They do not require
183
+ // any extra processing.
184
+ if (Kind >= FirstLiteralRelocationKind)
185
+ return MCAsmBackend::getFixupKindInfo (FK_NONE);
186
+
175
187
if (Kind < FirstTargetFixupKind)
176
188
return MCAsmBackend::getFixupKindInfo (Kind);
177
189
@@ -438,7 +450,6 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
438
450
default :
439
451
Ctx.reportError (Fixup.getLoc (), " bad relocation fixup type" );
440
452
return 0 ;
441
- case FK_NONE:
442
453
case FK_Data_1:
443
454
case FK_Data_2:
444
455
case FK_Data_4:
@@ -871,7 +882,7 @@ bool ARMAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
871
882
const MCSymbolRefExpr *A = Target.getSymA ();
872
883
const MCSymbol *Sym = A ? &A->getSymbol () : nullptr ;
873
884
const unsigned FixupKind = Fixup.getKind ();
874
- if (FixupKind == FK_NONE )
885
+ if (FixupKind >= FirstLiteralRelocationKind )
875
886
return true ;
876
887
if (FixupKind == ARM::fixup_arm_thumb_bl) {
877
888
assert (Sym && " How did we resolve this?" );
@@ -915,9 +926,6 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
915
926
default :
916
927
llvm_unreachable (" Unknown fixup kind!" );
917
928
918
- case FK_NONE:
919
- return 0 ;
920
-
921
929
case FK_Data_1:
922
930
case ARM::fixup_arm_thumb_bcc:
923
931
case ARM::fixup_arm_thumb_cp:
@@ -979,9 +987,6 @@ static unsigned getFixupKindContainerSizeBytes(unsigned Kind) {
979
987
default :
980
988
llvm_unreachable (" Unknown fixup kind!" );
981
989
982
- case FK_NONE:
983
- return 0 ;
984
-
985
990
case FK_Data_1:
986
991
return 1 ;
987
992
case FK_Data_2:
@@ -1037,7 +1042,10 @@ void ARMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
1037
1042
MutableArrayRef<char > Data, uint64_t Value,
1038
1043
bool IsResolved,
1039
1044
const MCSubtargetInfo* STI) const {
1040
- unsigned NumBytes = getFixupKindNumBytes (Fixup.getKind ());
1045
+ unsigned Kind = Fixup.getKind ();
1046
+ if (Kind >= FirstLiteralRelocationKind)
1047
+ return ;
1048
+ unsigned NumBytes = getFixupKindNumBytes (Kind);
1041
1049
MCContext &Ctx = Asm.getContext ();
1042
1050
Value = adjustFixupValue (Asm, Fixup, Target, Value, IsResolved, Ctx, STI);
1043
1051
if (!Value)
@@ -1049,7 +1057,7 @@ void ARMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
1049
1057
// Used to point to big endian bytes.
1050
1058
unsigned FullSizeBytes;
1051
1059
if (Endian == support::big) {
1052
- FullSizeBytes = getFixupKindContainerSizeBytes (Fixup. getKind () );
1060
+ FullSizeBytes = getFixupKindContainerSizeBytes (Kind );
1053
1061
assert ((Offset + FullSizeBytes) <= Data.size () && " Invalid fixup size!" );
1054
1062
assert (NumBytes <= FullSizeBytes && " Invalid fixup size!" );
1055
1063
}
0 commit comments