mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 21:26:21 +00:00
Fix loader check_wasi_abi_compatibility (#3126)
Assume that wasi exported `_start` and `_initialize` functions can not be an import function. Fixes issue #3122.
This commit is contained in:
parent
529fa9dd17
commit
06df58f20e
|
@ -4267,14 +4267,22 @@ check_wasi_abi_compatibility(const WASMModule *module,
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
WASMExport *initialize = NULL, *memory = NULL, *start = NULL;
|
WASMExport *initialize = NULL, *memory = NULL, *start = NULL;
|
||||||
|
uint32 import_function_count = module->import_function_count;
|
||||||
|
WASMType *func_type;
|
||||||
|
|
||||||
/* (func (export "_start") (...) */
|
/* (func (export "_start") (...) */
|
||||||
start = wasm_loader_find_export(module, "", "_start", EXPORT_KIND_FUNC,
|
start = wasm_loader_find_export(module, "", "_start", EXPORT_KIND_FUNC,
|
||||||
error_buf, error_buf_size);
|
error_buf, error_buf_size);
|
||||||
if (start) {
|
if (start) {
|
||||||
WASMType *func_type =
|
if (start->index < import_function_count) {
|
||||||
module->functions[start->index - module->import_function_count]
|
set_error_buf(
|
||||||
->func_type;
|
error_buf, error_buf_size,
|
||||||
|
"the builtin _start function can not be an import function");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
func_type =
|
||||||
|
module->functions[start->index - import_function_count]->func_type;
|
||||||
if (func_type->param_count || func_type->result_count) {
|
if (func_type->param_count || func_type->result_count) {
|
||||||
set_error_buf(error_buf, error_buf_size,
|
set_error_buf(error_buf, error_buf_size,
|
||||||
"the signature of builtin _start function is wrong");
|
"the signature of builtin _start function is wrong");
|
||||||
|
@ -4286,11 +4294,17 @@ check_wasi_abi_compatibility(const WASMModule *module,
|
||||||
initialize =
|
initialize =
|
||||||
wasm_loader_find_export(module, "", "_initialize", EXPORT_KIND_FUNC,
|
wasm_loader_find_export(module, "", "_initialize", EXPORT_KIND_FUNC,
|
||||||
error_buf, error_buf_size);
|
error_buf, error_buf_size);
|
||||||
|
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
WASMType *func_type =
|
if (initialize->index < import_function_count) {
|
||||||
module
|
set_error_buf(error_buf, error_buf_size,
|
||||||
->functions[initialize->index
|
"the builtin _initialize function can not be an "
|
||||||
- module->import_function_count]
|
"import function");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
func_type =
|
||||||
|
module->functions[initialize->index - import_function_count]
|
||||||
->func_type;
|
->func_type;
|
||||||
if (func_type->param_count || func_type->result_count) {
|
if (func_type->param_count || func_type->result_count) {
|
||||||
set_error_buf(
|
set_error_buf(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user