[ELF] Handle copy relocations for PC32.

This will eventually need to be refactored to better handle COPY relocations,
as other relocations can also generate them. I'm not yet sure the exact
circumstances in which they are needed yet.

llvm-svn: 191567
diff --git a/lld/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp b/lld/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
index 2ef6f38..33c919e 100644
--- a/lld/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
+++ b/lld/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
@@ -407,7 +407,10 @@
     if (auto sla = dyn_cast<SharedLibraryAtom>(ref.target())) {
       if (sla->type() == SharedLibraryAtom::Type::Code)
         return handlePLT32(ref);
-      else
+      else if (sla->type() == SharedLibraryAtom::Type::Data) {
+        const_cast<Reference &>(ref).setTarget(getObjectEntry(sla));
+        return error_code::success();
+      } else
         return handleGOTPCREL(ref);
     }
     return handleIFUNC(ref);
diff --git a/lld/test/elf/Inputs/undef-pc32.o b/lld/test/elf/Inputs/undef-pc32.o
new file mode 100644
index 0000000..954916d
--- /dev/null
+++ b/lld/test/elf/Inputs/undef-pc32.o
Binary files differ
diff --git a/lld/test/elf/undef-from-main-dso.test b/lld/test/elf/undef-from-main-dso.test
index c1e7962..64c3d2e 100644
--- a/lld/test/elf/undef-from-main-dso.test
+++ b/lld/test/elf/undef-from-main-dso.test
@@ -1,6 +1,9 @@
 RUN: lld -flavor gnu -e main -o %t -L%p/Inputs -lundef %p/Inputs/undef.o
 RUN: llvm-readobj -relocations -symbols %t | FileCheck %s
 
+RUN: lld -flavor gnu -e main -o %t -L%p/Inputs -lundef %p/Inputs/undef-pc32.o
+RUN: llvm-readobj -relocations -symbols %t | FileCheck %s
+
 # DSO source code:
 # int x[2] = { 1, 2 };
 #