[lld] r266890 - Delete refersToGotEntry.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 10:30:23 PDT 2016


Author: rafael
Date: Wed Apr 20 12:30:22 2016
New Revision: 266890

URL: http://llvm.org/viewvc/llvm-project?rev=266890&view=rev
Log:
Delete refersToGotEntry.

It can be computed from the expression.

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

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=266890&r1=266889&r2=266890&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Apr 20 12:30:22 2016
@@ -59,6 +59,12 @@ enum RelExpr {
   R_TLSLD_PC
 };
 
+inline bool refersToGotEntry(RelExpr Expr) {
+  return Expr == R_GOT || Expr == R_GOT_OFF || Expr == R_MIPS_GOT ||
+         Expr == R_MIPS_GOT_LOCAL || Expr == R_GOT_PAGE_PC ||
+         Expr == R_GOT_PC || Expr == R_GOT_FROM_END;
+}
+
 struct Relocation {
   RelExpr Expr;
   uint32_t Type;

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=266890&r1=266889&r2=266890&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Wed Apr 20 12:30:22 2016
@@ -91,8 +91,6 @@ public:
   void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   void relaxTlsIeToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   void relaxTlsLdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
-
-  bool refersToGotEntry(uint32_t Type) const override;
 };
 
 class X86_64TargetInfo final : public TargetInfo {
@@ -110,7 +108,6 @@ public:
   void writePlt(uint8_t *Buf, uint64_t GotEntryAddr, uint64_t PltEntryAddr,
                 int32_t Index, unsigned RelOff) const override;
   bool needsCopyRelImpl(uint32_t Type) const override;
-  bool refersToGotEntry(uint32_t Type) const override;
   bool needsPltImpl(uint32_t Type) const override;
   void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   bool isRelRelative(uint32_t Type) const override;
@@ -154,7 +151,6 @@ public:
   uint32_t getTlsGotRel(uint32_t Type) const override;
   bool isRelRelative(uint32_t Type) const override;
   bool needsCopyRelImpl(uint32_t Type) const override;
-  bool refersToGotEntry(uint32_t Type) const override;
   bool needsPltImpl(uint32_t Type) const override;
   void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -190,7 +186,6 @@ public:
   void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   bool isHintRel(uint32_t Type) const override;
   bool isRelRelative(uint32_t Type) const override;
-  bool refersToGotEntry(uint32_t Type) const override;
 };
 } // anonymous namespace
 
@@ -251,8 +246,6 @@ bool TargetInfo::isRelRelative(uint32_t
 
 bool TargetInfo::needsPltImpl(uint32_t Type) const { return false; }
 
-bool TargetInfo::refersToGotEntry(uint32_t Type) const { return false; }
-
 TargetInfo::PltNeed TargetInfo::needsPlt(uint32_t Type,
                                          const SymbolBody &S) const {
   if (S.isGnuIFunc())
@@ -281,9 +274,11 @@ TargetInfo::PltNeed TargetInfo::needsPlt
   // that points to the real function is a dedicated got entry used by the
   // plt. That is identified by special relocation types (R_X86_64_JUMP_SLOT,
   // R_386_JMP_SLOT, etc).
-  if (S.isShared())
-    if (!Config->Pic && S.isFunc() && !refersToGotEntry(Type))
+  if (S.isShared() && !Config->Pic && S.isFunc()) {
+    RelExpr Expr = getRelExpr(Type, S);
+    if (!refersToGotEntry(Expr))
       return Plt_Implicit;
+  }
 
   return Plt_No;
 }
@@ -461,10 +456,6 @@ bool X86TargetInfo::needsPltImpl(uint32_
   return Type == R_386_PLT32;
 }
 
-bool X86TargetInfo::refersToGotEntry(uint32_t Type) const {
-  return Type == R_386_GOT32;
-}
-
 uint64_t X86TargetInfo::getImplicitAddend(const uint8_t *Buf,
                                           uint32_t Type) const {
   switch (Type) {
@@ -672,11 +663,6 @@ bool X86_64TargetInfo::needsCopyRelImpl(
          Type == R_X86_64_64;
 }
 
-bool X86_64TargetInfo::refersToGotEntry(uint32_t Type) const {
-  return Type == R_X86_64_GOTPCREL || Type == R_X86_64_GOTPCRELX ||
-         Type == R_X86_64_REX_GOTPCRELX;
-}
-
 uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {
   if (Type == R_X86_64_PC32 || Type == R_X86_64_32)
     if (Config->Shared)
@@ -1236,10 +1222,6 @@ bool AArch64TargetInfo::needsCopyRelImpl
   }
 }
 
-bool AArch64TargetInfo::refersToGotEntry(uint32_t Type) const {
-  return Type == R_AARCH64_ADR_GOT_PAGE || Type == R_AARCH64_LD64_GOT_LO12_NC;
-}
-
 bool AArch64TargetInfo::needsPltImpl(uint32_t Type) const {
   switch (Type) {
   default:
@@ -1612,11 +1594,6 @@ bool MipsTargetInfo<ELFT>::needsCopyRelI
 }
 
 template <class ELFT>
-bool MipsTargetInfo<ELFT>::refersToGotEntry(uint32_t Type) const {
-  return Type == R_MIPS_GOT16 || Type == R_MIPS_CALL16;
-}
-
-template <class ELFT>
 bool MipsTargetInfo<ELFT>::needsPltImpl(uint32_t Type) const {
   return Type == R_MIPS_26;
 }

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=266890&r1=266889&r2=266890&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Wed Apr 20 12:30:22 2016
@@ -55,8 +55,6 @@ public:
   // dynamic linker if isRelRelative returns true.
   virtual bool isRelRelative(uint32_t Type) const;
 
-  virtual bool refersToGotEntry(uint32_t Type) const;
-
   enum PltNeed { Plt_No, Plt_Explicit, Plt_Implicit };
   PltNeed needsPlt(uint32_t Type, const SymbolBody &S) const;
 

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=266890&r1=266889&r2=266890&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Apr 20 12:30:22 2016
@@ -573,9 +573,7 @@ void Writer<ELFT>::scanRelocs(InputSecti
     }
 
     // If a relocation needs GOT, we create a GOT slot for the symbol.
-    if (Expr == R_GOT || Expr == R_GOT_OFF || Expr == R_MIPS_GOT ||
-        Expr == R_MIPS_GOT_LOCAL || Expr == R_GOT_PAGE_PC || Expr == R_GOT_PC ||
-        Expr == R_GOT_FROM_END) {
+    if (refersToGotEntry(Expr)) {
       uint32_t T = Body.isTls() ? Target->getTlsGotRel(Type) : Type;
       if (Config->EMachine == EM_MIPS && Expr == R_GOT_OFF)
         Addend -= MipsGPOffset;




More information about the llvm-commits mailing list