|
| 1 | +diff --git a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c |
| 2 | +index 2a06f42..506ee29 100644 |
| 3 | +--- a/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c |
| 4 | ++++ b/lib/wasm-micro-runtime-WAMR-1.3.0/core/iwasm/interpreter/wasm_loader.c |
| 5 | +@@ -3980,14 +3980,22 @@ check_wasi_abi_compatibility(const WASMModule *module, |
| 6 | + /* clang-format on */ |
| 7 | + |
| 8 | + WASMExport *initialize = NULL, *memory = NULL, *start = NULL; |
| 9 | ++ uint32 import_function_count = module->import_function_count; |
| 10 | ++ WASMType *func_type; |
| 11 | + |
| 12 | + /* (func (export "_start") (...) */ |
| 13 | + start = wasm_loader_find_export(module, "", "_start", EXPORT_KIND_FUNC, |
| 14 | + error_buf, error_buf_size); |
| 15 | + if (start) { |
| 16 | +- WASMType *func_type = |
| 17 | +- module->functions[start->index - module->import_function_count] |
| 18 | +- ->func_type; |
| 19 | ++ if (start->index < import_function_count) { |
| 20 | ++ set_error_buf( |
| 21 | ++ error_buf, error_buf_size, |
| 22 | ++ "the builtin _start function can not be an import function"); |
| 23 | ++ return false; |
| 24 | ++ } |
| 25 | ++ |
| 26 | ++ func_type = |
| 27 | ++ module->functions[start->index - import_function_count]->func_type; |
| 28 | + if (func_type->param_count || func_type->result_count) { |
| 29 | + set_error_buf(error_buf, error_buf_size, |
| 30 | + "the signature of builtin _start function is wrong"); |
| 31 | +@@ -3999,8 +4007,15 @@ check_wasi_abi_compatibility(const WASMModule *module, |
| 32 | + initialize = wasm_loader_find_export( |
| 33 | + module, "", "_initialize", EXPORT_KIND_FUNC, error_buf, error_buf_size); |
| 34 | + if (initialize) { |
| 35 | +- WASMType *func_type = |
| 36 | +- module->functions[initialize->index - module->import_function_count] |
| 37 | ++ if (initialize->index < import_function_count) { |
| 38 | ++ set_error_buf(error_buf, error_buf_size, |
| 39 | ++ "the builtin _initialize function can not be an " |
| 40 | ++ "import function"); |
| 41 | ++ return false; |
| 42 | ++ } |
| 43 | ++ |
| 44 | ++ func_type = |
| 45 | ++ module->functions[initialize->index - import_function_count] |
| 46 | + ->func_type; |
| 47 | + if (func_type->param_count || func_type->result_count) { |
| 48 | + set_error_buf( |
0 commit comments