Refine codes and fix several issues (#882)

Refine some codes in wasm loader
Add -Wshadow to gcc compile flags and fix some variable shadowed issues
Fix function parameter/return types not checked issue
Fix fast-interp loader reserve_block_ret() not handle V128 return type issue
Fix mini loader load_table_segment_section() failed issue
Add detailed comments for argc argument in wasm_runtime_call_wasm()
This commit is contained in:
Wenyong Huang
2021-12-10 18:13:17 +08:00
committed by GitHub
parent 915b26b0ec
commit 5547924e28
13 changed files with 273 additions and 289 deletions

View File

@ -1454,14 +1454,14 @@ load_text_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
/* Now code points to an ELF object, we pull it down to .text section */
uint64 offset;
uint64 size;
char *buf = module->code;
module->elf_hdr = buf;
if (!get_text_section(buf, &offset, &size)) {
char *code_buf = module->code;
module->elf_hdr = code_buf;
if (!get_text_section(code_buf, &offset, &size)) {
set_error_buf(error_buf, error_buf_size,
"get text section of ELF failed");
return false;
}
module->code = buf + offset;
module->code = code_buf + offset;
module->code_size -= (uint32)offset;
}
#endif

View File

@ -216,8 +216,6 @@ table_instantiate(AOTModuleInstance *module_inst, AOTModule *module,
/* fill table with element segment content */
for (i = 0; i < module->table_init_data_count; i++) {
AOTTableInstance *tbl_inst;
table_seg = module->table_init_data_list[i];
#if WASM_ENABLE_REF_TYPES != 0
@ -1404,6 +1402,16 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
uint32 ext_ret_count = result_count > 1 ? result_count - 1 : 0;
bool ret;
if (argc < func_type->param_cell_num) {
char buf[128];
snprintf(buf, sizeof(buf),
"invalid argument count %u, must be no smaller than %u", argc,
func_type->param_cell_num);
aot_set_exception(module_inst, buf);
return false;
}
argc = func_type->param_cell_num;
/* set thread handle and stack boundary */
wasm_exec_env_set_thread_info(exec_env);