https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md says:
Regardless of the kind, all modules accessing WASI APIs also export a linear memory with the name memory. Data pointers in WASI API calls are relative to this memory's index space.
i guess it's the convention used by many of host functions, not only WASI.
however, wasi-libc's libc.so doesn't export "memory".
actually, wasm-ld rejects -shared -export-memory.
https://github.com/llvm/llvm-project/blob/06a808c4f4014edfeb2517bddd0bcb63eb4a260b/lld/wasm/Driver.cpp#L658
am i missing something?
a. wasm-ld should be fixed.
b. application-abi.md doesn't apply to a module which is a shared library.
the memory exported from the "main" module should always be used.
i feel this a bit strange because the module calling wasi (eg. libc.so) doesn't know about the "main" module.