alexthomas1 edited issue #5266:
I am trying to calculate the host address and I found a similar issue: #2547
However, it seems like
wasmtime_linker_instantiate
takes in typewasmtime_instance_t
, but this isn't compatible withwasm_instance_exports
. Is there an updated way to get the base pointer of a module using linker? Thank you.wasm_instance_t* wasm_instance; error = wasmtime_linker_instantiate(linker, module, &wasm_instance, &trap); if (error != NULL || trap != NULL) { printf("Failed to instantiate \n"); exit(1); } wasm_extern_vec_t exports; wasm_instance_exports(wasm_instance, &exports); size_t i = 0; g_memory = get_export_memory(&exports, i++); // Run it. wasm_func_t* func; wasmtime_linker_get_default(linker, &empty, &func); if (error != NULL) exit_with_error("failed to locate default export for module", error, NULL); error = wasmtime_func_call(func, NULL, 0, NULL, 0, &trap); if (error != NULL) exit_with_error("error calling default export", error, trap);
alexcrichton commented on issue #5266:
The
wasm_instance_t
andwasmtime_instance_t
types are not compatible and can't be used with one another. The above code in theory should give you a warning from your C compiler which you'll need to fix. Using thewasmtime/*.h
family of headers you can extract the memory export and base pointer of memory.
alexthomas1 commented on issue #5266:
Any specific functions I should look at? Or any examples I can take a look for a more up to date version of getting the base pointer?
alexcrichton commented on issue #5266:
I would recommend reading this example
alexcrichton closed issue #5266:
I am trying to calculate the host address and I found a similar issue: #2547
However, it seems like
wasmtime_linker_instantiate
takes in typewasmtime_instance_t
, but this isn't compatible withwasm_instance_exports
. Is there an updated way to get the base pointer of a module using linker? Thank you.wasm_instance_t* wasm_instance; error = wasmtime_linker_instantiate(linker, module, &wasm_instance, &trap); if (error != NULL || trap != NULL) { printf("Failed to instantiate \n"); exit(1); } wasm_extern_vec_t exports; wasm_instance_exports(wasm_instance, &exports); size_t i = 0; g_memory = get_export_memory(&exports, i++); // Run it. wasm_func_t* func; wasmtime_linker_get_default(linker, &empty, &func); if (error != NULL) exit_with_error("failed to locate default export for module", error, NULL); error = wasmtime_func_call(func, NULL, 0, NULL, 0, &trap); if (error != NULL) exit_with_error("error calling default export", error, trap);
alexcrichton commented on issue #5266:
I'm going to close this but if you still have any questions feel free to post them here as well.
Last updated: Dec 23 2024 at 12:05 UTC