[lld] r266609 - Simplify handling of R_X86_64_TPOFF32. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 05:44:35 PDT 2016


Author: rafael
Date: Mon Apr 18 07:44:33 2016
New Revision: 266609

URL: http://llvm.org/viewvc/llvm-project?rev=266609&view=rev
Log:
Simplify handling of R_X86_64_TPOFF32. NFC.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=266609&r1=266608&r2=266609&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Mon Apr 18 07:44:33 2016
@@ -198,7 +198,7 @@ getSymVA(uint32_t Type, typename ELFT::u
   case R_GOTONLY_PC:
     return Out<ELFT>::Got->getVA() + A - P;
   case R_TLS:
-    return Body.getVA<ELFT>(A) - Out<ELF32LE>::TlsPhdr->p_memsz;
+    return Body.getVA<ELFT>(A) - Out<ELFT>::TlsPhdr->p_memsz;
   case R_NEG_TLS:
     return Out<ELF32LE>::TlsPhdr->p_memsz - Body.getVA<ELFT>(A);
   case R_ABS:

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=266609&r1=266608&r2=266609&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Apr 18 07:44:33 2016
@@ -636,6 +636,8 @@ RelExpr X86_64TargetInfo::getRelExpr(uin
   switch (Type) {
   default:
     return R_ABS;
+  case R_X86_64_TPOFF32:
+    return R_TLS;
   case R_X86_64_TLSLD:
     return R_TLSLD_PC;
   case R_X86_64_TLSGD:
@@ -768,7 +770,8 @@ void X86_64TargetInfo::relaxTlsGdToLe(ui
       0x48, 0x8d, 0x80, 0x00, 0x00, 0x00, 0x00              // lea x at tpoff,%rax
   };
   memcpy(Loc - 4, Inst, sizeof(Inst));
-  relocateOne(Loc + 8, R_X86_64_TPOFF32, Val + 4);
+  relocateOne(Loc + 8, R_X86_64_TPOFF32,
+              Val + 4 - Out<ELF64LE>::TlsPhdr->p_memsz);
 }
 
 // "Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5
@@ -824,7 +827,7 @@ void X86_64TargetInfo::relaxTlsIeToLe(ui
   if (*Prefix == 0x4c)
     *Prefix = (IsMov || RspAdd) ? 0x49 : 0x4d;
   *RegSlot = (IsMov || RspAdd) ? (0xc0 | Reg) : (0x80 | Reg | (Reg << 3));
-  relocateOne(Loc, R_X86_64_TPOFF32, Val + 4);
+  relocateOne(Loc, R_X86_64_TPOFF32, Val + 4 - Out<ELF64LE>::TlsPhdr->p_memsz);
 }
 
 // "Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5
@@ -845,7 +848,7 @@ void X86_64TargetInfo::relaxTlsLdToLe(ui
     return;
   }
   if (Type == R_X86_64_DTPOFF32) {
-    relocateOne(Loc, R_X86_64_TPOFF32, Val);
+    relocateOne(Loc, R_X86_64_TPOFF32, Val - Out<ELF64LE>::TlsPhdr->p_memsz);
     return;
   }
 
@@ -865,6 +868,7 @@ void X86_64TargetInfo::relocateOne(uint8
     write32le(Loc, Val);
     break;
   case R_X86_64_32S:
+  case R_X86_64_TPOFF32:
     checkInt<32>(Val, Type);
     write32le(Loc, Val);
     break;
@@ -884,12 +888,6 @@ void X86_64TargetInfo::relocateOne(uint8
   case R_X86_64_SIZE32:
     write32le(Loc, Val);
     break;
-  case R_X86_64_TPOFF32: {
-    Val -= Out<ELF64LE>::TlsPhdr->p_memsz;
-    checkInt<32>(Val, Type);
-    write32le(Loc, Val);
-    break;
-  }
   default:
     fatal("unrecognized reloc " + Twine(Type));
   }




More information about the llvm-commits mailing list