[lld] r299614 - Remove Target::isTlsGlobalDynamicRel()

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 5 20:30:32 PDT 2017


Author: ruiu
Date: Wed Apr  5 22:30:32 2017
New Revision: 299614

URL: http://llvm.org/viewvc/llvm-project?rev=299614&view=rev
Log:
Remove Target::isTlsGlobalDynamicRel()

Relocations are abstracted as platform-independent R_TLS_* relocations,
so we don't need to check platform-specific ones to see if a relocation
is TLS GD.

Modified:
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Target.h

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=299614&r1=299613&r2=299614&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Apr  5 22:30:32 2017
@@ -133,7 +133,7 @@ static unsigned handleNoRelaxTlsRelocati
     return 1;
   }
 
-  if (Target->isTlsGlobalDynamicRel(Type)) {
+  if (isRelExprOneOf<R_TLSGD, R_TLSGD_PC, R_MIPS_TLSGD>(Expr)) {
     if (Got->addDynTlsEntry(Body) &&
         (Body.isPreemptible() || Config->EMachine == EM_ARM)) {
       uint64_t Off = Got->getGlobalDynOffset(Body);
@@ -202,8 +202,8 @@ handleTlsRelocation(uint32_t Type, Symbo
     return 1;
   }
 
-  if (isRelExprOneOf<R_TLSDESC_PAGE, R_TLSDESC, R_TLSDESC_CALL>(Expr) ||
-      Target->isTlsGlobalDynamicRel(Type)) {
+  if (isRelExprOneOf<R_TLSDESC, R_TLSDESC_PAGE, R_TLSDESC_CALL, R_TLSGD,
+                     R_TLSGD_PC>(Expr)) {
     if (Config->Shared) {
       if (In<ELFT>::Got->addDynTlsEntry(Body)) {
         uint64_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=299614&r1=299613&r2=299614&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Wed Apr  5 22:30:32 2017
@@ -124,7 +124,6 @@ public:
   void writeGotPltHeader(uint8_t *Buf) const override;
   uint32_t getDynRel(uint32_t Type) const override;
   bool isTlsLocalDynamicRel(uint32_t Type) const override;
-  bool isTlsGlobalDynamicRel(uint32_t Type) const override;
   bool isTlsInitialExecRel(uint32_t Type) const override;
   void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
   void writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const override;
@@ -147,7 +146,6 @@ public:
   RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const override;
   bool isPicRel(uint32_t Type) const override;
   bool isTlsLocalDynamicRel(uint32_t Type) const override;
-  bool isTlsGlobalDynamicRel(uint32_t Type) const override;
   bool isTlsInitialExecRel(uint32_t Type) const override;
   void writeGotPltHeader(uint8_t *Buf) const override;
   void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
@@ -219,7 +217,6 @@ public:
   uint32_t getDynRel(uint32_t Type) const override;
   int64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
   bool isTlsLocalDynamicRel(uint32_t Type) const override;
-  bool isTlsGlobalDynamicRel(uint32_t Type) const override;
   bool isTlsInitialExecRel(uint32_t Type) const override;
   void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
   void writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const override;
@@ -241,7 +238,6 @@ public:
   bool isPicRel(uint32_t Type) const override;
   uint32_t getDynRel(uint32_t Type) const override;
   bool isTlsLocalDynamicRel(uint32_t Type) const override;
-  bool isTlsGlobalDynamicRel(uint32_t Type) const override;
   void writeGotPlt(uint8_t *Buf, const SymbolBody &S) const override;
   void writePltHeader(uint8_t *Buf) const override;
   void writePlt(uint8_t *Buf, uint64_t GotPltEntryAddr, uint64_t PltEntryAddr,
@@ -306,8 +302,6 @@ bool TargetInfo::isTlsInitialExecRel(uin
 
 bool TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { return false; }
 
-bool TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const { return false; }
-
 void TargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const {
   writeGotPlt(Buf, S);
 }
@@ -431,10 +425,6 @@ uint32_t X86TargetInfo::getDynRel(uint32
   return Type;
 }
 
-bool X86TargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
-  return Type == R_386_TLS_GD;
-}
-
 bool X86TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const {
   return Type == R_386_TLS_LDO_32 || Type == R_386_TLS_LDM;
 }
@@ -758,11 +748,6 @@ bool X86_64TargetInfo<ELFT>::isTlsInitia
 }
 
 template <class ELFT>
-bool X86_64TargetInfo<ELFT>::isTlsGlobalDynamicRel(uint32_t Type) const {
-  return Type == R_X86_64_TLSGD;
-}
-
-template <class ELFT>
 bool X86_64TargetInfo<ELFT>::isTlsLocalDynamicRel(uint32_t Type) const {
   return Type == R_X86_64_DTPOFF32 || Type == R_X86_64_DTPOFF64 ||
          Type == R_X86_64_TLSLD;
@@ -2048,10 +2033,6 @@ bool ARMTargetInfo::isTlsLocalDynamicRel
   return Type == R_ARM_TLS_LDO32 || Type == R_ARM_TLS_LDM32;
 }
 
-bool ARMTargetInfo::isTlsGlobalDynamicRel(uint32_t Type) const {
-  return Type == R_ARM_TLS_GD32;
-}
-
 bool ARMTargetInfo::isTlsInitialExecRel(uint32_t Type) const {
   return Type == R_ARM_TLS_IE32;
 }
@@ -2153,11 +2134,6 @@ bool MipsTargetInfo<ELFT>::isTlsLocalDyn
 }
 
 template <class ELFT>
-bool MipsTargetInfo<ELFT>::isTlsGlobalDynamicRel(uint32_t Type) const {
-  return Type == R_MIPS_TLS_GD;
-}
-
-template <class ELFT>
 void MipsTargetInfo<ELFT>::writeGotPlt(uint8_t *Buf, const SymbolBody &) const {
   write32<ELFT::TargetEndianness>(Buf, In<ELFT>::Plt->getVA());
 }

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=299614&r1=299613&r2=299614&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Wed Apr  5 22:30:32 2017
@@ -25,7 +25,6 @@ class TargetInfo {
 public:
   virtual bool isTlsInitialExecRel(uint32_t Type) const;
   virtual bool isTlsLocalDynamicRel(uint32_t Type) const;
-  virtual bool isTlsGlobalDynamicRel(uint32_t Type) const;
   virtual bool isPicRel(uint32_t Type) const { return true; }
   virtual uint32_t getDynRel(uint32_t Type) const { return Type; }
   virtual void writeGotPltHeader(uint8_t *Buf) const {}




More information about the llvm-commits mailing list