Stream: git-wasmtime

Topic: wasmtime / issue #5266 Calculate host address


view this post on Zulip Wasmtime GitHub notifications bot (Nov 15 2022 at 00:39):

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 type wasmtime_instance_t, but this isn't compatible with wasm_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);

view this post on Zulip Wasmtime GitHub notifications bot (Nov 15 2022 at 15:08):

alexcrichton commented on issue #5266:

The wasm_instance_t and wasmtime_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 the wasmtime/*.h family of headers you can extract the memory export and base pointer of memory.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 15 2022 at 22:48):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 16 2022 at 15:12):

alexcrichton commented on issue #5266:

I would recommend reading this example

view this post on Zulip Wasmtime GitHub notifications bot (Nov 22 2022 at 20:25):

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 type wasmtime_instance_t, but this isn't compatible with wasm_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);

view this post on Zulip Wasmtime GitHub notifications bot (Nov 22 2022 at 20:25):

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