|
|
@@ -684,7 +684,7 @@ adjust_table_max_size(uint32 init_size, uint32 max_size_flag, uint32 *max_size)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#if WASM_ENABLE_MULTI_MODULE != 0
|
|
|
+#if WASM_ENABLE_LIBC_WASI != 0 || WASM_ENABLE_MULTI_MODULE != 0
|
|
|
/**
|
|
|
* Find export item of a module with export info:
|
|
|
* module name, field name and export kind
|
|
|
@@ -718,11 +718,15 @@ wasm_loader_find_export(const WASMModule *module, const char *module_name,
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+ (void)module_name;
|
|
|
+
|
|
|
/* since there is a validation in load_export_section(), it is for sure
|
|
|
* export->index is valid*/
|
|
|
return export;
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
+#if WASM_ENABLE_MULTI_MODULE != 0
|
|
|
static WASMFunction *
|
|
|
wasm_loader_resolve_function(const char *module_name, const char *function_name,
|
|
|
const WASMType *expected_function_type,
|
|
|
@@ -1240,6 +1244,8 @@ load_table_import(const uint8 **p_buf, const uint8 *buf_end,
|
|
|
table->init_size = declare_init_size;
|
|
|
table->flags = declare_max_size_flag;
|
|
|
table->max_size = declare_max_size;
|
|
|
+
|
|
|
+ (void)parent_module;
|
|
|
return true;
|
|
|
fail:
|
|
|
return false;
|
|
|
@@ -1373,6 +1379,8 @@ load_memory_import(const uint8 **p_buf, const uint8 *buf_end,
|
|
|
memory->num_bytes_per_page = DEFAULT_NUM_BYTES_PER_PAGE;
|
|
|
|
|
|
*p_buf = p;
|
|
|
+
|
|
|
+ (void)parent_module;
|
|
|
return true;
|
|
|
fail:
|
|
|
return false;
|
|
|
@@ -1439,6 +1447,8 @@ load_global_import(const uint8 **p_buf, const uint8 *buf_end,
|
|
|
global->field_name = global_name;
|
|
|
global->type = declare_type;
|
|
|
global->is_mutable = (declare_mutable == 1);
|
|
|
+
|
|
|
+ (void)parent_module;
|
|
|
return true;
|
|
|
fail:
|
|
|
return false;
|
|
|
@@ -2381,6 +2391,7 @@ load_func_index_vec(const uint8 **p_buf, const uint8 *buf_end,
|
|
|
}
|
|
|
#else
|
|
|
read_leb_uint32(p, p_end, function_index);
|
|
|
+ (void)use_init_expr;
|
|
|
#endif
|
|
|
|
|
|
/* since we are using -1 to indicate ref.null */
|
|
|
@@ -2690,6 +2701,7 @@ load_code_section(const uint8 *buf, const uint8 *buf_end, const uint8 *buf_func,
|
|
|
}
|
|
|
|
|
|
LOG_VERBOSE("Load code segment section success.\n");
|
|
|
+ (void)module;
|
|
|
return true;
|
|
|
fail:
|
|
|
return false;
|
|
|
@@ -2900,6 +2912,8 @@ load_user_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
|
|
|
|
|
|
LOG_VERBOSE("Ignore custom section [%s].", section_name);
|
|
|
|
|
|
+ (void)is_load_from_file_buf;
|
|
|
+ (void)module;
|
|
|
return true;
|
|
|
fail:
|
|
|
return false;
|
|
|
@@ -4054,24 +4068,19 @@ fail:
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-#if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0)
|
|
|
+#if WASM_ENABLE_LIBC_WASI != 0
|
|
|
/**
|
|
|
* refer to
|
|
|
* https://github.com/WebAssembly/WASI/blob/main/design/application-abi.md
|
|
|
*/
|
|
|
static bool
|
|
|
-check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
|
|
|
+check_wasi_abi_compatibility(const WASMModule *module,
|
|
|
+#if WASM_ENABLE_MULTI_MODULE != 0
|
|
|
+ bool main_module,
|
|
|
+#endif
|
|
|
char *error_buf, uint32 error_buf_size)
|
|
|
{
|
|
|
/**
|
|
|
- * need to handle:
|
|
|
- * - non-wasi compatiable modules
|
|
|
- * - a fake wasi compatiable module
|
|
|
- * - a command acts as a main_module
|
|
|
- * - a command acts as a sub_module
|
|
|
- * - a reactor acts as a main_module
|
|
|
- * - a reactor acts as a sub_module
|
|
|
- *
|
|
|
* be careful with:
|
|
|
* wasi compatiable modules(command/reactor) which don't import any wasi
|
|
|
* APIs. Usually, a command has to import a "prox_exit" at least, but a
|
|
|
@@ -4087,7 +4096,19 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
|
|
|
* - no one will define either `_start` or `_initialize` on purpose
|
|
|
* - `_start` should always be `void _start(void)`
|
|
|
* - `_initialize` should always be `void _initialize(void)`
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
+ /* clang-format off */
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * | | import_wasi_api True | | import_wasi_api False | |
|
|
|
+ * | ----------- | -------------------- | ---------------- | --------------------- | ---------------- |
|
|
|
+ * | | \_initialize() Y | \_initialize() N | \_initialize() Y | \_initialize() N |
|
|
|
+ * | \_start() Y | N | COMMANDER | N | COMMANDER |
|
|
|
+ * | \_start() N | REACTOR | N | REACTOR | OTHERS |
|
|
|
*/
|
|
|
+ /* clang-format on */
|
|
|
|
|
|
WASMExport *initialize = NULL, *memory = NULL, *start = NULL;
|
|
|
|
|
|
@@ -4147,6 +4168,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+#if WASM_ENABLE_MULTI_MODULE != 0
|
|
|
/* filter out commands (with `_start`) cases */
|
|
|
if (start && !main_module) {
|
|
|
set_error_buf(
|
|
|
@@ -4154,6 +4176,7 @@ check_wasi_abi_compatibility(const WASMModule *module, bool main_module,
|
|
|
"a command (with _start function) can not be a sub-module");
|
|
|
return false;
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
/*
|
|
|
* it is ok a reactor acts as a main module,
|
|
|
@@ -4193,10 +4216,13 @@ wasm_loader_load(uint8 *buf, uint32 size,
|
|
|
goto fail;
|
|
|
}
|
|
|
|
|
|
-#if (WASM_ENABLE_MULTI_MODULE != 0) && (WASM_ENABLE_LIBC_WASI != 0)
|
|
|
+#if WASM_ENABLE_LIBC_WASI != 0
|
|
|
/* Check the WASI application ABI */
|
|
|
- if (!check_wasi_abi_compatibility(module, main_module, error_buf,
|
|
|
- error_buf_size)) {
|
|
|
+ if (!check_wasi_abi_compatibility(module,
|
|
|
+#if WASM_ENABLE_MULTI_MODULE != 0
|
|
|
+ main_module,
|
|
|
+#endif
|
|
|
+ error_buf, error_buf_size)) {
|
|
|
goto fail;
|
|
|
}
|
|
|
#endif
|
|
|
@@ -4971,6 +4997,7 @@ wasm_loader_find_block_addr(WASMExecEnv *exec_env, BlockAddr *block_addr_cache,
|
|
|
}
|
|
|
|
|
|
(void)u8;
|
|
|
+ (void)exec_env;
|
|
|
return false;
|
|
|
fail:
|
|
|
return false;
|
|
|
@@ -5834,6 +5861,8 @@ preserve_referenced_local(WASMLoaderContext *loader_ctx, uint8 opcode,
|
|
|
i += 2;
|
|
|
}
|
|
|
|
|
|
+ (void)error_buf;
|
|
|
+ (void)error_buf_size;
|
|
|
return true;
|
|
|
#if WASM_ENABLE_LABELS_AS_VALUES != 0
|
|
|
#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS == 0
|
|
|
@@ -6098,6 +6127,9 @@ wasm_loader_pop_frame_offset(WASMLoaderContext *ctx, uint8 type,
|
|
|
ctx->dynamic_offset -= 2;
|
|
|
}
|
|
|
emit_operand(ctx, *(ctx->frame_offset));
|
|
|
+
|
|
|
+ (void)error_buf;
|
|
|
+ (void)error_buf_size;
|
|
|
return true;
|
|
|
}
|
|
|
|