[lld] r266355 - Simplify handling of size relocations. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 14 11:39:44 PDT 2016


Author: rafael
Date: Thu Apr 14 13:39:44 2016
New Revision: 266355

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

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

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=266355&r1=266354&r2=266355&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Thu Apr 14 13:39:44 2016
@@ -120,7 +120,6 @@ public:
   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;
-  bool isSizeRel(uint32_t Type) const override;
 
   void relaxTlsGdToIe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
   void relaxTlsGdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
@@ -282,7 +281,6 @@ bool TargetInfo::needsCopyRel(uint32_t T
 bool TargetInfo::isGotRelative(uint32_t Type) const { return false; }
 bool TargetInfo::isHintRel(uint32_t Type) const { return false; }
 bool TargetInfo::isRelRelative(uint32_t Type) const { return true; }
-bool TargetInfo::isSizeRel(uint32_t Type) const { return false; }
 
 bool TargetInfo::needsGot(uint32_t Type, const SymbolBody &S) const {
   return false;
@@ -692,6 +690,9 @@ RelExpr X86_64TargetInfo::getRelExpr(uin
   switch (Type) {
   default:
     return R_ABS;
+  case R_X86_64_SIZE32:
+  case R_X86_64_SIZE64:
+    return R_SIZE;
   case R_X86_64_GOTPCREL:
   case R_X86_64_PLT32:
   case R_X86_64_PC32:
@@ -810,10 +811,6 @@ bool X86_64TargetInfo::isRelRelative(uin
   }
 }
 
-bool X86_64TargetInfo::isSizeRel(uint32_t Type) const {
-  return Type == R_X86_64_SIZE32 || Type == R_X86_64_SIZE64;
-}
-
 // "Ulrich Drepper, ELF Handling For Thread-Local Storage" (5.5
 // x86-x64 linker optimizations, http://www.akkadia.org/drepper/tls.pdf) shows
 // how GD can be optimized to LE:

Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=266355&r1=266354&r2=266355&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Thu Apr 14 13:39:44 2016
@@ -56,7 +56,6 @@ public:
   // dynamic linker if isRelRelative returns true.
   virtual bool isRelRelative(uint32_t Type) const;
 
-  virtual bool isSizeRel(uint32_t Type) const;
   virtual bool needsDynRelative(uint32_t Type) const { return false; }
   virtual bool needsGot(uint32_t Type, const SymbolBody &S) const;
   virtual bool refersToGotEntry(uint32_t Type) const;

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=266355&r1=266354&r2=266355&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Apr 14 13:39:44 2016
@@ -609,11 +609,8 @@ void Writer<ELFT>::scanRelocs(InputSecti
     // We can however do better than just copying the incoming relocation. We
     // can process some of it and and just ask the dynamic linker to add the
     // load address.
-    if (Target->isSizeRel(Type)) {
-      C.Relocations.push_back({R_SIZE, Type, Offset, Addend, &Body});
-      continue;
-    }
-    if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC) {
+    if (!Config->Pic || Target->isRelRelative(Type) || Expr == R_PC ||
+        Expr == R_SIZE) {
       if (Config->EMachine == EM_MIPS && Body.isLocal() &&
           (Type == R_MIPS_GPREL16 || Type == R_MIPS_GPREL32))
         Expr = R_MIPS_GP0;




More information about the llvm-commits mailing list