[PATCH] D32758: Remove isTlsLocalDynamicRel and isTlsInitialExecRel

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 07:30:47 PDT 2017


ping.

Rafael Ávila de Espíndola via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> rafael created this revision.
>
> This feels a bit hackish, but I think it is still an improvement.
>
> The way a tls address is computed in the various architectures is not that different. For example, for local dynamic we need the base of the tls (R_TLSLD or R_TLSLD_PC), and the offset of that particular symbol (R_ABS).
>
> Given the similarity, we can just use the expressions instead of having two additional target hooks.
>
>
> https://reviews.llvm.org/D32758
>
> Files:
>   ELF/Relocations.cpp
>   ELF/Target.cpp
>   ELF/Target.h
>
> Index: ELF/Target.h
> ===================================================================
> --- ELF/Target.h
> +++ ELF/Target.h
> @@ -23,8 +23,6 @@
>  
>  class TargetInfo {
>  public:
> -  virtual bool isTlsInitialExecRel(uint32_t Type) const;
> -  virtual bool isTlsLocalDynamicRel(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 {}
> Index: ELF/Target.cpp
> ===================================================================
> --- ELF/Target.cpp
> +++ ELF/Target.cpp
> @@ -124,8 +124,6 @@
>    int64_t getImplicitAddend(const uint8_t *Buf, uint32_t Type) const override;
>    void writeGotPltHeader(uint8_t *Buf) const override;
>    uint32_t getDynRel(uint32_t Type) const override;
> -  bool isTlsLocalDynamicRel(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;
>    void writePltHeader(uint8_t *Buf) const override;
> @@ -147,8 +145,6 @@
>    RelExpr getRelExpr(uint32_t Type, const SymbolBody &S,
>                       const uint8_t *Loc) const override;
>    bool isPicRel(uint32_t Type) const override;
> -  bool isTlsLocalDynamicRel(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;
>    void writePltHeader(uint8_t *Buf) const override;
> @@ -193,7 +189,6 @@
>    RelExpr getRelExpr(uint32_t Type, const SymbolBody &S,
>                       const uint8_t *Loc) const override;
>    bool isPicRel(uint32_t Type) const override;
> -  bool isTlsInitialExecRel(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,
> @@ -303,10 +298,6 @@
>    return false;
>  }
>  
> -bool TargetInfo::isTlsInitialExecRel(uint32_t Type) const { return false; }
> -
> -bool TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const { return false; }
> -
>  void TargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const {
>    writeGotPlt(Buf, S);
>  }
> @@ -451,14 +442,6 @@
>    return Type;
>  }
>  
> -bool X86TargetInfo::isTlsLocalDynamicRel(uint32_t Type) const {
> -  return Type == R_386_TLS_LDO_32 || Type == R_386_TLS_LDM;
> -}
> -
> -bool X86TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
> -  return Type == R_386_TLS_IE || Type == R_386_TLS_GOTIE;
> -}
> -
>  void X86TargetInfo::writePltHeader(uint8_t *Buf) const {
>    if (Config->Pic) {
>      const uint8_t V[] = {
> @@ -772,17 +755,6 @@
>  }
>  
>  template <class ELFT>
> -bool X86_64TargetInfo<ELFT>::isTlsInitialExecRel(uint32_t Type) const {
> -  return Type == R_X86_64_GOTTPOFF;
> -}
> -
> -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;
> -}
> -
> -template <class ELFT>
>  void X86_64TargetInfo<ELFT>::relaxTlsGdToLe(uint8_t *Loc, uint32_t Type,
>                                              uint64_t Val) const {
>    // Convert
> @@ -1383,11 +1355,6 @@
>    }
>  }
>  
> -bool AArch64TargetInfo::isTlsInitialExecRel(uint32_t Type) const {
> -  return Type == R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
> -         Type == R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC;
> -}
> -
>  bool AArch64TargetInfo::isPicRel(uint32_t Type) const {
>    return Type == R_AARCH64_ABS32 || Type == R_AARCH64_ABS64;
>  }
> Index: ELF/Relocations.cpp
> ===================================================================
> --- ELF/Relocations.cpp
> +++ ELF/Relocations.cpp
> @@ -233,7 +233,7 @@
>    }
>  
>    // Local-Dynamic relocs can be relaxed to Local-Exec.
> -  if (Target->isTlsLocalDynamicRel(Type) && !Config->Shared) {
> +  if (isRelExprOneOf<R_ABS, R_TLSLD, R_TLSLD_PC>(Expr) && !Config->Shared) {
>      C.Relocations.push_back(
>          {R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body});
>      return 1;
> @@ -282,7 +282,8 @@
>  
>    // Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
>    // defined.
> -  if (Target->isTlsInitialExecRel(Type) && !Config->Shared && !IsPreemptible) {
> +  if (isRelExprOneOf<R_GOT, R_GOT_FROM_END, R_GOT_PC, R_GOT_PAGE_PC>(Expr) &&
> +      !Config->Shared && !IsPreemptible) {
>      C.Relocations.push_back(
>          {R_RELAX_TLS_IE_TO_LE, Type, Offset, Addend, &Body});
>      return 1;
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list