This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Generate imports for undefined data as well as functions
Needs ReviewPublic

Authored by sbc100 on Mar 9 2018, 8:05 PM.

Details

Reviewers
ruiu
ncw
Summary

If the final linked binary contains undefined data symbols
generate inputs for these, just like we do for undefined
functions

Event Timeline

sbc100 created this revision.Mar 9 2018, 8:05 PM
sbc100 edited the summary of this revision. (Show Details)Mar 9 2018, 8:08 PM
sbc100 added reviewers: ruiu, ncw.
ncw added a comment.Mar 10 2018, 8:19 AM

Hmm, does this work? I mean I can see that it generates an imported global of course, but it doesn't do anything. The code that actually references the import is still going to have 0 written in as the value of the relocation!

The "fake globals" that are currently exported for defined data are at least usable in JavaScript, as a way of finding out the address to write to when you want to modify the variable. Is there a similar use (at this stage) for these imported globals?

Maybe hold off merging this until the discussion has come up with a full solution to the problem (assuming that this is the same as https://github.com/WebAssembly/tool-conventions/issues/48).

You are right, the imported globals are never used.

And yes this was as first step to solving https://github.com/WebAssembly/tool-conventions/issues/48.

And yes I agree we probably don't want to land this without the imports actually being used.

And yes, sadly we do have use case for this, in emscripten. I injects the addresses of globals in this way.. something I only just discovered :(