Is it possible to use assembly code with gomobile?

80 Views Asked by At

I've been experimenting to use assembly code inside the library that I'm going to run on Android platform using gomobile.

TEXT gotomobile·sum(SB),4,$0
MOVW    arg1+0(FP), R14
MOVW    arg2+4(FP), R13
ADD     R15, R14, R13
MOVW    R13, ret+8(FP)
RET

So far it is successfully compiling and it is even complaining if I make any mistake on assembly code but the function definition I pass won't seem to shown on exported jar,

    package gotomobile

import "fmt"

func sum(arg1, arg2 int32) int32

func add() {
    result := sum(3, 4)
    fmt.Println(result)
}

func Test() {
    fmt.Println("Test")
    add() // Tried it like so to try even to suppress function unused warning.
}

func TestWRet() string {
    return "Hello from go"
}

and if I call Test(); function on Java I'm getting this error:

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "github.com/user/gomobile/pkg/gotomobile.sum" referenced by "/data/app/com.example.myapplication-tphaYUXt9nWES8ofkOKnCw==/base.apk!/lib/arm64-v8a/libgojni.so"...

So I've been wondering is it possible to use assembly with gomobile ?

0

There are 0 best solutions below