@@ -143,8 +143,6 @@ static void fixupLeb128(MCContext &Ctx, const MCFixup &Fixup, uint8_t *Data,
143
143
void LoongArchAsmBackend::applyFixup (const MCFragment &F, const MCFixup &Fixup,
144
144
const MCValue &Target, uint8_t *Data,
145
145
uint64_t Value, bool IsResolved) {
146
- if (IsResolved && shouldForceRelocation (Fixup, Target))
147
- IsResolved = false ;
148
146
IsResolved = addReloc (F, Fixup, Target, Value, IsResolved);
149
147
if (!Value)
150
148
return ; // Doesn't change encoding.
@@ -176,20 +174,6 @@ void LoongArchAsmBackend::applyFixup(const MCFragment &F, const MCFixup &Fixup,
176
174
}
177
175
}
178
176
179
- bool LoongArchAsmBackend::shouldForceRelocation (const MCFixup &Fixup,
180
- const MCValue &Target) {
181
- switch (Fixup.getKind ()) {
182
- default :
183
- return STI.hasFeature (LoongArch::FeatureRelax);
184
- case FK_Data_1:
185
- case FK_Data_2:
186
- case FK_Data_4:
187
- case FK_Data_8:
188
- case FK_Data_leb128:
189
- return !Target.isAbsolute ();
190
- }
191
- }
192
-
193
177
static inline std::pair<MCFixupKind, MCFixupKind>
194
178
getRelocPairForSize (unsigned Size) {
195
179
switch (Size) {
@@ -491,9 +475,16 @@ bool LoongArchAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
491
475
return false ;
492
476
}
493
477
494
- IsResolved = Fallback ();
495
478
// If linker relaxation is enabled and supported by the current relocation,
496
- // append a RELAX relocation.
479
+ // generate a relocation and then append a RELAX.
480
+ if (Fixup.isLinkerRelaxable ())
481
+ IsResolved = false ;
482
+ if (IsResolved && Fixup.isPCRel ())
483
+ IsResolved = isPCRelFixupResolved (Target.getAddSym (), F);
484
+
485
+ if (!IsResolved)
486
+ Asm->getWriter ().recordRelocation (F, Fixup, Target, FixedValue);
487
+
497
488
if (Fixup.isLinkerRelaxable ()) {
498
489
auto FA = MCFixup::create (Fixup.getOffset (), nullptr , ELF::R_LARCH_RELAX);
499
490
Asm->getWriter ().recordRelocation (F, FA, MCValue::get (nullptr ),
0 commit comments