[ELF] - Error out when R_X86_64_PC32/R_X86_64_32 are used against preemptible symbol when linking shared object.

When R_X86_64_PC32/R_X86_64_32 relocations are
used against preemptible symbol and output is position independent,
error should be generated.

Differential revision: http://reviews.llvm.org/D18190

llvm-svn: 264707
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 5bc6fc0..4f87aac 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -110,6 +110,7 @@
 class X86_64TargetInfo final : public TargetInfo {
 public:
   X86_64TargetInfo();
+  uint32_t getDynRel(uint32_t Type) const override;
   uint32_t getTlsGotRel(uint32_t Type) const override;
   bool pointsToLocalDynamicGotEntry(uint32_t Type) const override;
   bool isTlsLocalDynamicRel(uint32_t Type) const override;
@@ -758,6 +759,14 @@
   return refersToGotEntry(Type) || needsPlt(Type, S);
 }
 
+uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {
+  if (Type == R_X86_64_PC32 || Type == R_X86_64_32)
+    if (Config->Shared)
+      error(getELFRelocationTypeName(EM_X86_64, Type) +
+            " cannot be a dynamic relocation");
+  return Type;
+}
+
 uint32_t X86_64TargetInfo::getTlsGotRel(uint32_t Type) const {
   // No other types of TLS relocations requiring GOT should
   // reach here.