diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index f1a5c4796..4a5006adb 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -2605,9 +2605,16 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data) while (!LLVMObjectFileIsSymbolIteratorAtEnd(obj_data->binary, sym_itr)) { if ((name = LLVMGetSymbolName(sym_itr)) - && !strcmp(name, aot_stack_sizes_alias_name)) { + && (!strcmp(name, aot_stack_sizes_alias_name) + /* symbol of COFF32 starts with "_" */ + || (obj_data->target_info.bin_type == AOT_COFF32_BIN_TYPE + && !strncmp(name, "_", 1) + && !strcmp(name + 1, aot_stack_sizes_alias_name)))) { uint64 sz = LLVMGetSymbolSize(sym_itr); - if (sz != sizeof(uint32) * obj_data->func_count) { + if (sz != sizeof(uint32) * obj_data->func_count + /* sz of COFF64/COFF32 is 0, ignore the check */ + && obj_data->target_info.bin_type != AOT_COFF64_BIN_TYPE + && obj_data->target_info.bin_type != AOT_COFF32_BIN_TYPE) { aot_set_last_error("stack_sizes had unexpected size."); goto fail; } @@ -2642,10 +2649,6 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data) goto fail; } } - if (addr > UINT32_MAX) { - aot_set_last_error("too large stack_sizes offset."); - goto fail; - } /* * Record section/offset and construct a copy of stack_sizes. * aot_emit_object_data_section_info will emit this copy. diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 2b88c398f..b71b608a2 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -1913,8 +1913,9 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent, } if (memory_data) { - bh_memcpy_s(memory_data + base_offset, memory_size - base_offset, - data_seg->data, length); + bh_memcpy_s(memory_data + base_offset, + (uint32)memory_size - base_offset, data_seg->data, + length); } } diff --git a/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c b/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c index 4d53da0c9..dc2d4f1bc 100644 --- a/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c +++ b/core/iwasm/libraries/lib-wasi-threads/tid_allocator.c @@ -21,7 +21,8 @@ tid_allocator_init(TidAllocator *tid_allocator) return false; for (int64 i = tid_allocator->pos - 1; i >= 0; i--) - tid_allocator->ids[i] = TID_MIN + (tid_allocator->pos - 1 - i); + tid_allocator->ids[i] = + (uint32)(TID_MIN + (tid_allocator->pos - 1 - i)); return true; } @@ -54,7 +55,8 @@ tid_allocator_get_tid(TidAllocator *tid_allocator) LOG_ERROR("Overflow detected during realloc"); return -1; } - int32 *tmp = wasm_runtime_realloc(tid_allocator->ids, realloc_size); + int32 *tmp = + wasm_runtime_realloc(tid_allocator->ids, (uint32)realloc_size); if (tmp == NULL) { LOG_ERROR("Thread ID allocator realloc failed"); return -1; @@ -64,7 +66,8 @@ tid_allocator_get_tid(TidAllocator *tid_allocator) tid_allocator->pos = new_size - old_size; tid_allocator->ids = tmp; for (int64 i = tid_allocator->pos - 1; i >= 0; i--) - tid_allocator->ids[i] = TID_MIN + (tid_allocator->size - 1 - i); + tid_allocator->ids[i] = + (uint32)(TID_MIN + (tid_allocator->size - 1 - i)); } // Pop available thread identifier from the stack @@ -77,4 +80,4 @@ tid_allocator_release_tid(TidAllocator *tid_allocator, int32 thread_id) // Release thread identifier by pushing it into the stack bh_assert(tid_allocator->pos < tid_allocator->size); tid_allocator->ids[tid_allocator->pos++] = thread_id; -} \ No newline at end of file +} diff --git a/core/shared/platform/common/posix/posix_socket.c b/core/shared/platform/common/posix/posix_socket.c index c018588ae..d0a232bc5 100644 --- a/core/shared/platform/common/posix/posix_socket.c +++ b/core/shared/platform/common/posix/posix_socket.c @@ -275,7 +275,7 @@ os_socket_recv_from(bh_socket_t socket, void *buf, unsigned int len, int flags, return -1; } } - else { + else if (src_addr) { memset(src_addr, 0, sizeof(*src_addr)); } diff --git a/product-mini/platforms/posix/main.c b/product-mini/platforms/posix/main.c index b79af9b83..5d20fd293 100644 --- a/product-mini/platforms/posix/main.c +++ b/product-mini/platforms/posix/main.c @@ -330,7 +330,7 @@ load_native_lib(const char *name) if (ret != 0) { LOG_WARNING("warning: `init_native_lib` function from native " "lib %s failed with %d", - name); + name, ret); goto fail; } }