summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/OutputSections.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 979728e05a3..619a05f1170 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -289,6 +289,14 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
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) {
@@ -316,11 +324,10 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
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();
@@ -342,7 +349,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *Buf) {
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;
OpenPOWER on IntegriCloud