[lld] r258760 - Move code to create RELATIVE reloc for TLS_IE to one place.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 25 17:03:21 PST 2016


Author: ruiu
Date: Mon Jan 25 19:03:21 2016
New Revision: 258760

URL: http://llvm.org/viewvc/llvm-project?rev=258760&view=rev
Log:
Move code to create RELATIVE reloc for TLS_IE to one place.

Modified:
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=258760&r1=258759&r2=258760&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Jan 25 19:03:21 2016
@@ -289,6 +289,14 @@ template <class ELFT> void RelocationSec
     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 RelocationSec
 
     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 RelocationSec
       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;




More information about the llvm-commits mailing list