Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

golang so can't export function call crash #1

Open
Hello-xBugs opened this issue Mar 23, 2021 · 2 comments
Open

golang so can't export function call crash #1

Hello-xBugs opened this issue Mar 23, 2021 · 2 comments

Comments

@Hello-xBugs
Copy link

golang so can't export function call crash, please support

@cauefcr
Copy link

cauefcr commented May 5, 2021

i think tooBugs means that exported go .so files aren't supported by the loader, for example the code

package main

import (
	"C"
	"fmt"
)

//export Runme
func Runme() string {
	return "hello world, bipbop!"
}

func main() {
	fmt.Println(Runme())
}

built with

go build -o libplugin.so -buildmode=c-shared plugin.go

and loaded with

package main

import (
	"fmt"
	"io/ioutil"

	"github.com/Binject/universal"
)

func main() {
	libraryPath := "libplugin.so"
	image, err := ioutil.ReadFile(libraryPath)
	if err != nil {
		panic(err)
	}
	loader, err := universal.NewLoader()
	if err != nil {
		panic(err)
	}
	library, err := loader.LoadLibrary("main", &image)
	if err != nil {
		panic(err)
	}
	// fmt.Println("call")

	// runmeProc, ok := library.FindProc("Runme")
	// if !ok {
	// 	fmt.Println("FindProc did not find export Runme")
	// 	return
	// }
	val, err := library.Call("Runme")
	if err != nil {
		panic(err)
	}
	fmt.Println(val)
}

does not work, at least, for me, on linux amd64, if possible please help!

@Hello-xBugs
Copy link
Author

yes ,this project only support C so, golang runtime can't load second time, another project can support this。i think this can help you !https://github.com/pkujhd/goloader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants