Open NWilson opened 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.
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.