wasm-micro-runtime/samples/multi-module/wasm-apps/mB.c
liang.he 50b6474f54
Add WASI ABI compatibility check for multi-module (#913)
Refer to https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md
to check the WASI ABI compatibility:
- Command (main module) may export _start function with signature "()"
- Reactor (sub module) may export _initialize function with signature "()"
- _start and _initialize can not be exported at the same time
- Reactor cannot export _start function
- Command and Reactor must export memory

And
- Rename module->is_wasi_module to module->import_wasi_api
- Refactor wasm_loader_find_export()
- Remove MULTI_MODULE related codes from mini_loader
- Update multi-module samples
- Fix a "use-after-free" issue. Since we reuse the memory instance of sub module,
   just to protect it from freeing an imported memory instance
2021-12-29 11:04:36 +08:00

23 lines
297 B
C

__attribute__((import_module("mA")))
__attribute__((import_name("A1"))) extern int
A1();
__attribute__((export_name("B1"))) int
B1()
{
return 21;
}
__attribute__((export_name("B2"))) int
B2()
{
return A1();
}
int
B3()
{
return 23;
}
/* mA is a reactor. it doesn't need a main() */