You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 11, 2020. It is now read-only.
package main
funcmain() {
println("Hello, World!")
}
GOOS=js GOARCH=wasm go build -o test.wasm helloworld.go
Run the below code:
package main
import (
"fmt""os""github.com/go-interpreter/wagon/wasm"
)
funcmain() {
f, err:=os.Open("test.wasm")
iferr!=nil {
panic(err)
}
deferf.Close()
mod, err:=wasm.ReadModule(f, nil)
iferr!=nil {
panic(err)
}
fn:=mod.FunctionIndexSpace[0]
fmt.Printf("name: %q\n", fn.Name) // This is empty. That's fine since this is an imported function 'debug'. fmt.Printf("len(code): %d\n", len(fn.Body.Code)) // This is not empty. That's unexpected. This content is for the first function as 'go.buildid'.
}
It looks like the function's index and its instructions don't match. Some of the first functions should be imported functions, but include instructions for other functions. I think the function bodies are shifted.