WAVM Modules
WASM natively has a notion of modules.
Normally, in WASM, a module is the entire program.
A .wasm
file represents one module, and generally they aren't combined.
An exception to this is C compiled via Clang, where wasm files are also used as object files,
but its linking scheme is not supported in other languages.
In WAVM this is extended to make the executing program composed of multiple modules. These may call each other, and library modules may write to their caller's memory to return results.
The entrypoint module
The entrypoint module is where execution begins.
It calls modules' start
functions if specified,
and then calls the main module's main function, which is language specific.
For Go it sets argv to ["js"]
to match the JS environment, and calls run
.
For Rust it calls main
with no arguments.
Library exports
Libraries may export functions with the name pattern module__name
,
which future libraries or the main module can import as "module" "name"
.
For instance, this is used for wasi-stub to provide functions rust imports according to the WebAssembly System Interface.