Skip to content

Commit

Permalink
fix enclave compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lum1n0us committed Oct 29, 2024
1 parent 3a8b5a6 commit 0c58cc1
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions product-mini/platforms/linux-sgx/enclave-sample/Enclave/Enclave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,9 @@ ecall_iwasm_main(uint8_t *wasm_file_buf, uint32_t wasm_file_size)
const char *exception;
uint32 stack_size = 16 * 1024;
uint32 heap_size = 16 * 1024;
#if WASM_ENABLE_MULTI_MODULE == 0
WASMExternInstance *imports = NULL;
#endif

/* avoid duplicated init */
if (runtime_inited) {
Expand Down Expand Up @@ -839,33 +842,34 @@ ecall_iwasm_main(uint8_t *wasm_file_buf, uint32_t wasm_file_size)

/* instantiate the module */
#if WASM_ENABLE_MULTI_MODULE == 0
int32_t import_count = wasm_runtime_get_import_count(wasm_module);
WASMExternInstance *imports = NULL;
{
int32_t import_count = wasm_runtime_get_import_count(wasm_module);

#if WASM_ENABLE_SPEC_TEST != 0 || WASM_ENABLE_WASI_TEST != 0 \
|| WASM_ENABLE_LIBC_BUILTIN != 0
imports = wasm_runtime_create_imports_with_builtin(wasm_module);
imports = wasm_runtime_create_imports_with_builtin(wasm_module);
#endif
if (import_count > 0 && imports == NULL) {
enclave_print("Need to provide necessary imported objects");
enclave_print("\n");
goto fail2;
}
if (import_count > 0 && imports == NULL) {
enclave_print("Need to provide necessary imported objects");
enclave_print("\n");
goto fail2;
}

InstantiationArgs inst_args = {
.default_stack_size = stack_size,
.host_managed_heap_size = heap_size,
.max_memory_pages = 0,
.import_count = (uint32_t)import_count,
.imports = imports,
};
InstantiationArgs inst_args = {
.default_stack_size = stack_size,
.host_managed_heap_size = heap_size,
.max_memory_pages = 0,
.import_count = (uint32_t)import_count,
.imports = imports,
};

wasm_module_inst = wasm_runtime_instantiate_ex(
wasm_module, &inst_args, error_buf, sizeof(error_buf));
if (!wasm_module_inst) {
enclave_print(error_buf);
enclave_print("\n");
goto fail3;
wasm_module_inst = wasm_runtime_instantiate_ex(
wasm_module, &inst_args, error_buf, sizeof(error_buf));
if (!wasm_module_inst) {
enclave_print(error_buf);
enclave_print("\n");
goto fail3;
}
}
#else /* WASM_ENABLE_MULTI_MODULE == 0 */
if (!(wasm_module_inst =
Expand All @@ -891,7 +895,7 @@ ecall_iwasm_main(uint8_t *wasm_file_buf, uint32_t wasm_file_size)
fail3:
/* destory imports */
wasm_runtime_destroy_imports(wasm_module, imports);
#endif
#endif /* WASM_ENABLE_MULTI_MODULE == 0*/

fail2:
/* unload the module */
Expand Down

0 comments on commit 0c58cc1

Please sign in to comment.