[WebAssembly] Create synthetic __dso_handle symbol

This is used by __cxa_ataxit to determine the currently
executing DLL.  Once we fully support DLLs this will need
to be set to some address within the DLL.

The ELF linker added support for this symbol here:
https://reviews.llvm.org/D33856

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

llvm-svn: 322606
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 75c3cb5..05b0b75 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -299,9 +299,18 @@
     for (auto* Arg : Args.filtered(OPT_undefined))
       addSyntheticUndefinedFunction(Arg->getValue(), nullptr);
 
+    // Create linker-synthetic symbols
+    // __wasm_call_ctors:
+    //    Function that directly calls all ctors in priority order.
+    // __stack_pointer:
+    //    Wasm global that holds the address of the top of the explict
+    //    value stack in linear memory.
+    // __dso_handle;
+    //    Global in calls to __cxa_atexit to determine current DLL
     Config->CtorSymbol = Symtab->addDefinedFunction(
         "__wasm_call_ctors", &Signature, WASM_SYMBOL_VISIBILITY_HIDDEN);
     Config->StackPointerSymbol = Symtab->addDefinedGlobal("__stack_pointer");
+    Symtab->addDefinedGlobal("__dso_handle")->setVirtualAddress(0);
   }
 
   createFiles(Args);