@@ -3908,23 +3908,18 @@ wasm_runtime_is_wasi_mode(WASMModuleInstanceCommon *module_inst)
39083908WASMFunctionInstanceCommon *
39093909wasm_runtime_lookup_wasi_start_function (WASMModuleInstanceCommon * module_inst )
39103910{
3911- uint32 i ;
3912-
39133911#if WASM_ENABLE_INTERP != 0
39143912 if (module_inst -> module_type == Wasm_Module_Bytecode ) {
39153913 WASMModuleInstance * wasm_inst = (WASMModuleInstance * )module_inst ;
3916- WASMFunctionInstance * func ;
3917- for (i = 0 ; i < wasm_inst -> export_func_count ; i ++ ) {
3918- if (!strcmp (wasm_inst -> export_functions [i ].name , "_start" )) {
3919- func = wasm_inst -> export_functions [i ].function ;
3920- if (func -> u .func -> func_type -> param_count != 0
3921- || func -> u .func -> func_type -> result_count != 0 ) {
3922- LOG_ERROR ("Lookup wasi _start function failed: "
3923- "invalid function type.\n" );
3924- return NULL ;
3925- }
3926- return (WASMFunctionInstanceCommon * )func ;
3914+ WASMFunctionInstance * func = wasm_lookup_function (wasm_inst , "_start" );
3915+ if (func ) {
3916+ if (func -> u .func -> func_type -> param_count != 0
3917+ || func -> u .func -> func_type -> result_count != 0 ) {
3918+ LOG_ERROR ("Lookup wasi _start function failed: "
3919+ "invalid function type.\n" );
3920+ return NULL ;
39273921 }
3922+ return (WASMFunctionInstanceCommon * )func ;
39283923 }
39293924 return NULL ;
39303925 }
@@ -3933,19 +3928,15 @@ wasm_runtime_lookup_wasi_start_function(WASMModuleInstanceCommon *module_inst)
39333928#if WASM_ENABLE_AOT != 0
39343929 if (module_inst -> module_type == Wasm_Module_AoT ) {
39353930 AOTModuleInstance * aot_inst = (AOTModuleInstance * )module_inst ;
3936- AOTFunctionInstance * export_funcs =
3937- (AOTFunctionInstance * )aot_inst -> export_functions ;
3938- for (i = 0 ; i < aot_inst -> export_func_count ; i ++ ) {
3939- if (!strcmp (export_funcs [i ].func_name , "_start" )) {
3940- AOTFuncType * func_type = export_funcs [i ].u .func .func_type ;
3941- if (func_type -> param_count != 0
3942- || func_type -> result_count != 0 ) {
3943- LOG_ERROR ("Lookup wasi _start function failed: "
3944- "invalid function type.\n" );
3945- return NULL ;
3946- }
3947- return (WASMFunctionInstanceCommon * )& export_funcs [i ];
3931+ AOTFunctionInstance * func = aot_lookup_function (aot_inst , "_start" );
3932+ if (func ) {
3933+ AOTFuncType * func_type = func -> u .func .func_type ;
3934+ if (func_type -> param_count != 0 || func_type -> result_count != 0 ) {
3935+ LOG_ERROR ("Lookup wasi _start function failed: "
3936+ "invalid function type.\n" );
3937+ return NULL ;
39483938 }
3939+ return func ;
39493940 }
39503941 return NULL ;
39513942 }
0 commit comments