if (applyTlsDynamicReloc(Body, Type, P, reinterpret_cast<Elf_Rel *>(Buf)))
continue;
+ // Writer::scanRelocs creates a RELATIVE reloc for some type of TLS reloc.
+ // We want to write it down as is.
+ if (Type == Target->getRelativeReloc()) {
+ P->setSymbolAndType(0, Type, Config->Mips64EL);
+ P->r_offset = C.getOffset(RI.r_offset) + C.OutSec->getVA();
+ continue;
+ }
+
// Emit a copy relocation.
auto *SS = dyn_cast_or_null<SharedSymbol<ELFT>>(Body);
if (SS && SS->NeedsCopy) {
bool LazyReloc = Body && Target->supportsLazyRelocations() &&
Target->relocNeedsPlt(Type, *Body);
- bool IsDynRelative = Type == Target->getRelativeReloc();
unsigned Sym = CBP ? Body->DynamicSymbolTableIndex : 0;
unsigned Reloc;
- if (!CBP || IsDynRelative)
+ if (!CBP)
Reloc = Target->getRelativeReloc();
else if (LazyReloc)
Reloc = Target->getPltReloc();
OrigAddend = static_cast<const Elf_Rela &>(RI).r_addend;
uintX_t Addend;
- if (CBP || IsDynRelative)
+ if (CBP)
Addend = OrigAddend;
else if (Body)
Addend = getSymVA<ELFT>(*Body) + OrigAddend;