@@ -28,7 +28,6 @@ static uint64_t adjustFixupValue(unsigned Kind, uint64_t Value) {
28
28
switch (Kind) {
29
29
default :
30
30
llvm_unreachable (" Unknown fixup kind!" );
31
- case FK_NONE:
32
31
case FK_Data_1:
33
32
case FK_Data_2:
34
33
case FK_Data_4:
@@ -52,8 +51,6 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
52
51
switch (Kind) {
53
52
default :
54
53
llvm_unreachable (" Unknown fixup kind!" );
55
- case FK_NONE:
56
- return 0 ;
57
54
case FK_Data_1:
58
55
return 1 ;
59
56
case FK_Data_2:
@@ -109,6 +106,11 @@ class PPCAsmBackend : public MCAsmBackend {
109
106
{ " fixup_ppc_nofixup" , 0 , 0 , 0 }
110
107
};
111
108
109
+ // Fixup kinds from .reloc directive are like R_PPC_NONE/R_PPC64_NONE. They
110
+ // do not require any extra processing.
111
+ if (Kind >= FirstLiteralRelocationKind)
112
+ return MCAsmBackend::getFixupKindInfo (FK_NONE);
113
+
112
114
if (Kind < FirstTargetFixupKind)
113
115
return MCAsmBackend::getFixupKindInfo (Kind);
114
116
@@ -123,11 +125,14 @@ class PPCAsmBackend : public MCAsmBackend {
123
125
const MCValue &Target, MutableArrayRef<char > Data,
124
126
uint64_t Value, bool IsResolved,
125
127
const MCSubtargetInfo *STI) const override {
126
- Value = adjustFixupValue (Fixup.getKind (), Value);
128
+ MCFixupKind Kind = Fixup.getKind ();
129
+ if (Kind >= FirstLiteralRelocationKind)
130
+ return ;
131
+ Value = adjustFixupValue (Kind, Value);
127
132
if (!Value) return ; // Doesn't change encoding.
128
133
129
134
unsigned Offset = Fixup.getOffset ();
130
- unsigned NumBytes = getFixupKindNumBytes (Fixup. getKind () );
135
+ unsigned NumBytes = getFixupKindNumBytes (Kind );
131
136
132
137
// For each byte of the fragment that the fixup touches, mask in the bits
133
138
// from the fixup value. The Value has been "split up" into the appropriate
@@ -140,11 +145,10 @@ class PPCAsmBackend : public MCAsmBackend {
140
145
141
146
bool shouldForceRelocation (const MCAssembler &Asm, const MCFixup &Fixup,
142
147
const MCValue &Target) override {
143
- switch ((unsigned )Fixup.getKind ()) {
148
+ MCFixupKind Kind = Fixup.getKind ();
149
+ switch ((unsigned )Kind) {
144
150
default :
145
- return false ;
146
- case FK_NONE:
147
- return true ;
151
+ return Kind >= FirstLiteralRelocationKind;
148
152
case PPC::fixup_ppc_br24:
149
153
case PPC::fixup_ppc_br24abs:
150
154
// If the target symbol has a local entry point we must not attempt
@@ -228,14 +232,25 @@ class XCOFFPPCAsmBackend : public PPCAsmBackend {
228
232
} // end anonymous namespace
229
233
230
234
Optional<MCFixupKind> ELFPPCAsmBackend::getFixupKind (StringRef Name) const {
231
- if (TT.isPPC64 ()) {
232
- if (Name == " R_PPC64_NONE" )
233
- return FK_NONE;
234
- } else {
235
- if (Name == " R_PPC_NONE" )
236
- return FK_NONE;
235
+ if (TT.isOSBinFormatELF ()) {
236
+ unsigned Type;
237
+ if (TT.isPPC64 ()) {
238
+ Type = llvm::StringSwitch<unsigned >(Name)
239
+ #define ELF_RELOC (X, Y ) .Case(#X, Y)
240
+ #include " llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
241
+ #undef ELF_RELOC
242
+ .Default (-1u );
243
+ } else {
244
+ Type = llvm::StringSwitch<unsigned >(Name)
245
+ #define ELF_RELOC (X, Y ) .Case(#X, Y)
246
+ #include " llvm/BinaryFormat/ELFRelocs/PowerPC.def"
247
+ #undef ELF_RELOC
248
+ .Default (-1u );
249
+ }
250
+ if (Type != -1u )
251
+ return static_cast <MCFixupKind>(FirstLiteralRelocationKind + Type);
237
252
}
238
- return MCAsmBackend::getFixupKind (Name) ;
253
+ return None ;
239
254
}
240
255
241
256
MCAsmBackend *llvm::createPPCAsmBackend (const Target &T,
0 commit comments