wasmerio / wasmer-go

🐹🕸️ WebAssembly runtime for Go
https://pkg.go.dev/github.com/wasmerio/wasmer-go
MIT License
2.84k stars 161 forks source link

Is it possible to access un-exported data #401

Open joesonw opened 1 year ago

joesonw commented 1 year ago

Summary

I've compiled following code using tinygo

//go:wasmimport env call
func _call(ptr uint32)

//go:noinline
func call(f func()) {
    ptr := unsafe.Pointer(&f)
    _call(uint32(uintptr(ptr)))
}

and the resulted wasm will call my host function with value a pointer to a memory with two u32: 0 (receiver), 1 (index of function in the table), and the table is as following.

image

And the generated wasm does not export this table, is there any way I can access this function $main.main$1

Additional details

I've got it working with wazero, they exposed a function to retrieve unexported function defined in tables.

I am wondering if it's archievable in wasmer.