Report error in instantiation when meeting unlinked import globals (#1859)
This commit is contained in:
@ -976,6 +976,26 @@ execute_memory_init_function(AOTModuleInstance *module_inst)
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool
|
||||
check_linked_symbol(AOTModule *module, char *error_buf, uint32 error_buf_size)
|
||||
{
|
||||
uint32 i;
|
||||
|
||||
/* init_func_ptrs() will go through import functions */
|
||||
|
||||
for (i = 0; i < module->import_global_count; i++) {
|
||||
AOTImportGlobal *global = module->import_globals + i;
|
||||
if (!global->is_linked) {
|
||||
set_error_buf_v(error_buf, error_buf_size,
|
||||
"warning: failed to link import global (%s, %s)",
|
||||
global->module_name, global->global_name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AOTModuleInstance *
|
||||
aot_instantiate(AOTModule *module, bool is_sub_inst, uint32 stack_size,
|
||||
uint32 heap_size, char *error_buf, uint32 error_buf_size)
|
||||
@ -1059,6 +1079,9 @@ aot_instantiate(AOTModule *module, bool is_sub_inst, uint32 stack_size,
|
||||
if (!init_func_type_indexes(module_inst, module, error_buf, error_buf_size))
|
||||
goto fail;
|
||||
|
||||
if (!check_linked_symbol(module, error_buf, error_buf_size))
|
||||
goto fail;
|
||||
|
||||
if (!create_exports(module_inst, module, error_buf, error_buf_size))
|
||||
goto fail;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user