Skip to content

Commit

Permalink
remove unnecessary functions load
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej <[email protected]>
  • Loading branch information
Maciej committed Jul 23, 2024
1 parent d0cdb02 commit ee7ce28
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/libcrun/handlers/wamr.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <sys/types.h>
#include <fcntl.h>
#include <sched.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

Expand Down Expand Up @@ -125,7 +124,6 @@ libwamr_exec (void *cookie, __attribute__ ((unused)) libcrun_container_t *contai
// load symbols from the shared library libiwasm.so
bool (*wasm_runtime_init) ();
RuntimeInitArgs init_args;
bool (*wasm_runtime_full_init) (RuntimeInitArgs * init_args);
wasm_module_t module;
wasm_module_t (*wasm_runtime_load) (uint8_t * buf, uint32_t size, char *error_buf, uint32_t error_buf_size);
wasm_module_inst_t module_inst;
Expand All @@ -135,35 +133,26 @@ libwamr_exec (void *cookie, __attribute__ ((unused)) libcrun_container_t *contai
wasm_exec_env_t exec_env;
wasm_exec_env_t (*wasm_runtime_create_exec_env) (wasm_module_inst_t module_inst, uint32_t stack_size);
bool (*wasm_runtime_call_wasm) (wasm_exec_env_t exec_env, wasm_function_inst_t function, uint32_t argc, uint32_t argv[]);
const char *(*wasm_runtime_get_exception) (wasm_module_inst_t module_inst);
void (*wasm_runtime_destroy_exec_env) (wasm_exec_env_t exec_env);
void (*wasm_runtime_deinstantiate) (wasm_module_inst_t module_inst);
void (*wasm_runtime_unload) (wasm_module_t module);
void (*wasm_runtime_destroy) ();
uint32_t (*wasm_runtime_get_wasi_exit_code) (wasm_module_inst_t module_inst);
bool (*wasm_application_execute_main) (wasm_module_inst_t module_inst, int32_t argc, char *argv[]);
void (*wasm_runtime_set_wasi_args) (wasm_module_t module, const char *dir_list[], uint32_t dir_count, const char *map_dir_list[], uint32_t map_dir_count, const char *env[], uint32_t env_count, char *argv[], int argc);

wasm_runtime_init = dlsym (cookie, "wasm_runtime_init");
wasm_runtime_full_init = dlsym (cookie, "wasm_runtime_full_init");
wasm_runtime_load = dlsym (cookie, "wasm_runtime_load");
wasm_runtime_instantiate = dlsym (cookie, "wasm_runtime_instantiate");
wasm_runtime_lookup_function = dlsym (cookie, "wasm_runtime_lookup_function");
wasm_runtime_create_exec_env = dlsym (cookie, "wasm_runtime_create_exec_env");
wasm_runtime_call_wasm = dlsym (cookie, "wasm_runtime_call_wasm");
wasm_runtime_get_exception = dlsym (cookie, "wasm_runtime_get_exception");
wasm_runtime_destroy_exec_env = dlsym (cookie, "wasm_runtime_destroy_exec_env");
wasm_runtime_deinstantiate = dlsym (cookie, "wasm_runtime_deinstantiate");
wasm_runtime_unload = dlsym (cookie, "wasm_runtime_unload");
wasm_runtime_destroy = dlsym (cookie, "wasm_runtime_destroy");
wasm_runtime_get_wasi_exit_code = dlsym (cookie, "wasm_runtime_get_wasi_exit_code");
wasm_application_execute_main = dlsym (cookie, "wasm_application_execute_main");
wasm_runtime_set_wasi_args = dlsym (cookie, "wasm_runtime_set_wasi_args");

if (wasm_runtime_init == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_init symbol in `libiwasm.so`");
if (wasm_runtime_full_init == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_full_init symbol in `libiwasm.so`");
if (wasm_runtime_load == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_load symbol in `libiwasm.so`");
if (wasm_runtime_instantiate == NULL)
Expand All @@ -174,8 +163,6 @@ libwamr_exec (void *cookie, __attribute__ ((unused)) libcrun_container_t *contai
error (EXIT_FAILURE, 0, "could not find wasm_runtime_create_exec_env symbol in `libiwasm.so`");
if (wasm_runtime_call_wasm == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_call_wasm symbol in `libiwasm.so`");
if (wasm_runtime_get_exception == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_get_exception symbol in `libiwasm.so`");
if (wasm_runtime_destroy_exec_env == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_destroy_exec_env symbol in `libiwasm.so`");
if (wasm_runtime_deinstantiate == NULL)
Expand All @@ -184,10 +171,6 @@ libwamr_exec (void *cookie, __attribute__ ((unused)) libcrun_container_t *contai
error (EXIT_FAILURE, 0, "could not find wasm_runtime_unload symbol in `libiwasm.so`");
if (wasm_runtime_destroy == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_destroy symbol in `libiwasm.so`");
if (wasm_runtime_get_wasi_exit_code == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_get_wasi_exit_code symbol in `libiwasm.so`");
if (wasm_application_execute_main == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_application_execute_main symbol in `libiwasm.so`");
if (wasm_runtime_set_wasi_args == NULL)
error (EXIT_FAILURE, 0, "could not find wasm_runtime_set_wasi_args symbol in `libiwasm.so`");

Expand Down Expand Up @@ -225,7 +208,7 @@ libwamr_exec (void *cookie, __attribute__ ((unused)) libcrun_container_t *contai
if (! module_inst)
error (EXIT_FAILURE, 0, "Failed to instantiate the WASM module");

/* lookup a WASM function by its name The function signature can NULL here */
/* lookup a WASM function by its name; the function signature can be NULL here */
func = wasm_runtime_lookup_function (module_inst, "_start");
if (! func || func == NULL)
error (EXIT_FAILURE, 0, "Failed to lookup the WASM function");
Expand Down

0 comments on commit ee7ce28

Please sign in to comment.