[WebAssembly] Apply data relocations at runtime in shared objects

See: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md

Data section relocations in wasm shared libraries are applied by the
library itself at static constructor time.  This change adds a new
synthetic function that applies relocations to relevant memory locations
on startup.

Differential Revision: https://reviews.llvm.org/D59278

llvm-svn: 357715
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp
index c3786da..a53c472 100644
--- a/lld/wasm/MarkLive.cpp
+++ b/lld/wasm/MarkLive.cpp
@@ -76,6 +76,11 @@
     }
   }
 
+  if (Config->Pic) {
+    Enqueue(WasmSym::CallCtors);
+    Enqueue(WasmSym::ApplyRelocs);
+  }
+
   // Follow relocations to mark all reachable chunks.
   while (!Q.empty()) {
     InputChunk *C = Q.pop_back_val();