Extend os_mmap to support map file from fd (#2763)
Add an extra argument `os_file_handle file` for `os_mmap` to support mapping file from a file fd, and remove `os_get_invalid_handle` from `posix_file.c` and `win_file.c`, instead, add it in the `platform_internal.h` files to remove the dependency on libc-wasi. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
@ -1574,8 +1574,9 @@ load_object_data_sections(const uint8 **p_buf, const uint8 *buf_end,
|
||||
|
||||
/* Allocate memory for data */
|
||||
if (data_sections[i].size > 0
|
||||
&& !(data_sections[i].data = os_mmap(NULL, data_sections[i].size,
|
||||
map_prot, map_flags))) {
|
||||
&& !(data_sections[i].data =
|
||||
os_mmap(NULL, data_sections[i].size, map_prot, map_flags,
|
||||
os_get_invalid_handle()))) {
|
||||
set_error_buf(error_buf, error_buf_size, "allocate memory failed");
|
||||
return false;
|
||||
}
|
||||
@ -2470,7 +2471,8 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
|
||||
|
||||
if (size > UINT32_MAX
|
||||
|| !(module->extra_plt_data =
|
||||
os_mmap(NULL, (uint32)size, map_prot, map_flags))) {
|
||||
os_mmap(NULL, (uint32)size, map_prot, map_flags,
|
||||
os_get_invalid_handle()))) {
|
||||
set_error_buf(error_buf, error_buf_size, "mmap memory failed");
|
||||
goto fail;
|
||||
}
|
||||
@ -2593,7 +2595,8 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
|
||||
size = (uint64)sizeof(void *) * got_item_count;
|
||||
if (size > UINT32_MAX
|
||||
|| !(module->got_func_ptrs =
|
||||
os_mmap(NULL, (uint32)size, map_prot, map_flags))) {
|
||||
os_mmap(NULL, (uint32)size, map_prot, map_flags,
|
||||
os_get_invalid_handle()))) {
|
||||
set_error_buf(error_buf, error_buf_size, "mmap memory failed");
|
||||
goto fail;
|
||||
}
|
||||
@ -3106,8 +3109,9 @@ create_sections(AOTModule *module, const uint8 *buf, uint32 size,
|
||||
(uint64)section_size + aot_get_plt_table_size();
|
||||
total_size = (total_size + 3) & ~((uint64)3);
|
||||
if (total_size >= UINT32_MAX
|
||||
|| !(aot_text = os_mmap(NULL, (uint32)total_size,
|
||||
map_prot, map_flags))) {
|
||||
|| !(aot_text =
|
||||
os_mmap(NULL, (uint32)total_size, map_prot,
|
||||
map_flags, os_get_invalid_handle()))) {
|
||||
wasm_runtime_free(section);
|
||||
set_error_buf(error_buf, error_buf_size,
|
||||
"mmap memory failed");
|
||||
|
||||
Reference in New Issue
Block a user