-
Notifications
You must be signed in to change notification settings - Fork 26
/
linux_test.go
59 lines (45 loc) · 960 Bytes
/
linux_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// +build linux
package universal
import (
"io/ioutil"
"log"
"testing"
"github.com/awgh/cppgo/asmcall/cdecl"
)
func Test_Linux_1(t *testing.T) {
image, err := ioutil.ReadFile("test/64/main.so")
loader, err := NewLoader()
if err != nil {
t.Fatal(err)
}
library, err := loader.LoadLibrary("main", &image)
if err != nil {
t.Fatal(err)
}
runmeProc, ok := library.FindProc("Runme")
if !ok {
t.Fatal("FindProc did not find export Runme")
}
log.Printf("%x %x \n", runmeProc, library.BaseAddress)
val, err := cdecl.Call(runmeProc, 7)
if err != nil {
t.Fatal(err)
}
log.Printf("%+v\n", val)
}
func Test_Linux_2(t *testing.T) {
image, err := ioutil.ReadFile("test/64/main.so")
loader, err := NewLoader()
if err != nil {
t.Fatal(err)
}
library, err := loader.LoadLibrary("main", &image)
if err != nil {
t.Fatal(err)
}
val, err := library.Call("Runme", 7)
if err != nil {
t.Fatal(err)
}
log.Printf("%+v\n", val)
}