Simplify handling of size relocations. NFC.
llvm-svn: 266355
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 58ab226..8b12d75 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -120,7 +120,6 @@
   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::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 @@
   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::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:
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 4d90fe2..ed32faa 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -56,7 +56,6 @@
   // 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;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 6bb1391..d3505ab 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -609,11 +609,8 @@
     // 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;