[lld] r322606 - [WebAssembly] Create synthetic __dso_handle symbol

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 17:10:28 PST 2018


Author: sbc
Date: Tue Jan 16 17:10:28 2018
New Revision: 322606

URL: http://llvm.org/viewvc/llvm-project?rev=322606&view=rev
Log:
[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

Modified:
    lld/trunk/wasm/Driver.cpp

Modified: lld/trunk/wasm/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Driver.cpp?rev=322606&r1=322605&r2=322606&view=diff
==============================================================================
--- lld/trunk/wasm/Driver.cpp (original)
+++ lld/trunk/wasm/Driver.cpp Tue Jan 16 17:10:28 2018
@@ -299,9 +299,18 @@ void LinkerDriver::link(ArrayRef<const c
     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);




More information about the llvm-commits mailing list