WebAssembly / lld

Staging repository for upstreaming WebAssembly support into lld
Other
10 stars 10 forks source link

[WASM]: Hook up lld's --entry argument to the Wasm "start" section #15

Open NWilson opened 6 years ago

NWilson commented 6 years ago

The --entry option is there to allow designating the entry-point symbol, but it isn't wired in!

LLD needs to actually set the entrypoint on the Wasm output, using the "start" section.

sbc100 commented 6 years ago

The reason we do this right now is for parity the expectations of emscripten and also wasm.js in the musl repo (which we use for testing): https://github.com/jfbastien/musl/blob/wasm-prototype-1/arch/wasm32/wasm.js

Both these loaders expect to be able to run the main function explicitly and get the return code from it.

There has been some discussion about the role of the start section and how the linker should use it. I think it was originally intented to tune the C/C++ internalizer functions but not run main(). This is certainly one concievable option, but it would involve the linker generating said function, or assuming its name (in musl this i called __libc_start_init for example).

For now I think it makes sense to keep it empty and let the embedder choose to run what it wants when it whats rather than on instantiate.