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
This commit is contained in:
@ -1,25 +1,51 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
__attribute__((import_module("mA")))
|
||||
__attribute__((import_name("A"))) extern int
|
||||
A();
|
||||
__attribute__((import_name("A1"))) extern int
|
||||
A1();
|
||||
|
||||
__attribute__((import_module("mB")))
|
||||
__attribute__((import_name("B"))) extern int
|
||||
B();
|
||||
__attribute__((import_name("B1"))) extern int
|
||||
B1();
|
||||
|
||||
int
|
||||
C()
|
||||
__attribute__((import_module("mB")))
|
||||
__attribute__((import_name("B2"))) extern int
|
||||
B2();
|
||||
|
||||
__attribute__((export_name("C1"))) int
|
||||
C1()
|
||||
{
|
||||
return 12;
|
||||
return 31;
|
||||
}
|
||||
|
||||
__attribute__((export_name("C2"))) int
|
||||
C2()
|
||||
{
|
||||
return B1();
|
||||
}
|
||||
|
||||
__attribute__((export_name("C3"))) int
|
||||
C3()
|
||||
{
|
||||
return A1();
|
||||
}
|
||||
|
||||
__attribute__((export_name("C4"))) int
|
||||
C4()
|
||||
{
|
||||
return B2();
|
||||
}
|
||||
|
||||
int
|
||||
call_A()
|
||||
C5()
|
||||
{
|
||||
return A();
|
||||
return C1() + C2() + C3() + 35;
|
||||
}
|
||||
|
||||
int
|
||||
call_B()
|
||||
main()
|
||||
{
|
||||
return B();
|
||||
printf("%u\n", C5());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user