Skip to content

Commit 3388a71

Browse files
committed
[wasmtime] Check functions after manual loading
Signed-off-by: Maximilian Hüter <[email protected]>
1 parent 2bf9858 commit 3388a71

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/libcrun/handlers/wasmtime.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* You should have received a copy of the GNU Lesser General Public License
1616
* along with crun. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
#include <wasmtime/store.h>
1918
#define _GNU_SOURCE
2019

2120
#include <config.h>
@@ -342,11 +341,6 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
342341
wasmtime_context_t *context,
343342
const wasmtime_component_t *component,
344343
wasmtime_component_instance_t *instance_out);
345-
wasmtime_component_export_index_t *(*wasmtime_component_get_export_index) (
346-
wasmtime_component_t *component,
347-
wasmtime_component_export_index_t *index,
348-
const char *name,
349-
size_t name_len);
350344
wasmtime_component_export_index_t *(*wasmtime_component_instance_get_export_index) (
351345
const wasmtime_component_instance_t *instance,
352346
wasmtime_context_t *context,
@@ -385,7 +379,6 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
385379
wasmtime_component_linker_new = dlsym (cookie, "wasmtime_component_linker_new");
386380
wasmtime_component_linker_add_wasip2 = dlsym (cookie, "wasmtime_component_linker_add_wasip2");
387381
wasmtime_component_linker_instantiate = dlsym (cookie, "wasmtime_component_linker_instantiate");
388-
wasmtime_component_get_export_index = dlsym (cookie, "wasmtime_component_get_export_index");
389382
wasmtime_component_instance_get_export_index = dlsym (cookie, "wasmtime_component_instance_get_export_index");
390383
wasmtime_component_instance_get_func = dlsym (cookie, "wasmtime_component_instance_get_func");
391384
wasmtime_component_func_call = dlsym (cookie, "wasmtime_component_func_call");
@@ -395,6 +388,17 @@ libwasmtime_run_component (void *cookie, char *const argv[], wasm_engine_t *engi
395388
wasmtime_error_message = dlsym (cookie, "wasmtime_error_message");
396389
wasmtime_error_delete = dlsym (cookie, "wasmtime_error_delete");
397390

391+
if (wasm_engine_delete == NULL || wasm_byte_vec_delete == NULL || wasmtime_store_new == NULL
392+
|| wasmtime_store_delete == NULL || wasmtime_store_context == NULL || wasmtime_component_new == NULL
393+
|| wasmtime_wasip2_config_new == NULL || wasmtime_wasip2_config_inherit_stdin == NULL
394+
|| wasmtime_wasip2_config_inherit_stdout == NULL || wasmtime_wasip2_config_inherit_stderr == NULL
395+
|| wasmtime_context_set_wasip2 == NULL || wasmtime_component_linker_new == NULL || wasmtime_component_linker_add_wasip2 == NULL
396+
|| wasmtime_component_linker_instantiate == NULL || wasmtime_component_instance_get_export_index == NULL
397+
|| wasmtime_component_instance_get_func == NULL || wasmtime_component_func_call == NULL || wasmtime_component_export_index_delete == NULL
398+
|| wasmtime_component_delete == NULL || wasmtime_component_linker_delete == NULL || wasmtime_error_message == NULL
399+
|| wasmtime_error_delete == NULL)
400+
error (EXIT_FAILURE, 0, "could not find symbol in `libwasmtime.so`");
401+
398402
// Set up wasmtime context
399403
wasmtime_store_t *store = wasmtime_store_new (engine, NULL, NULL);
400404
assert (store != NULL);

0 commit comments

Comments
 (0)