This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Create synthetic __dso_handle symbol
ClosedPublic

Authored by sbc100 on Jan 12 2018, 6:02 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

sbc100 created this revision.Jan 12 2018, 6:02 PM
sbc100 edited the summary of this revision. (Show Details)Jan 12 2018, 6:03 PM
sbc100 added reviewers: dschuff, ruiu.

Couldn't this just be in crtbegin.c? Then there wouldn't have to be custom linker logic for it.

ruiu added a comment.Jan 16 2018, 2:34 PM

I'm not opposing to this patch, but I wonder if this is the best way of doing what you want to do in the new file format. We define __dso_handle symbol for ELF because the existing code expects the symbol. But since we don't have such existing code in wasm (am I correct?) I wonder if there's a different way.

In D42024#977637, @ruiu wrote:

I'm not opposing to this patch, but I wonder if this is the best way of doing what you want to do in the new file format. We define __dso_handle symbol for ELF because the existing code expects the symbol. But since we don't have such existing code in wasm (am I correct?) I wonder if there's a different way.

We do have existing code that depends on dso_handle in that clang will generate calls to cxa_atexit() passing __dso_handle as the third arg (see clang/lib/CodeGen/ItaniumCXXABI.cpp).

ruiu accepted this revision.Jan 16 2018, 2:46 PM

LGTM

This revision is now accepted and ready to land.Jan 16 2018, 2:46 PM
This revision was automatically updated to reflect the committed changes.