* Fix valabind bindings

* Fix Go bindings build for arm, 386 and amd64
* Apply ricky's patch honoring LIBDIR
This commit is contained in:
pancake 2011-08-21 14:24:58 +02:00
parent efb113ce8b
commit 2f84cbe1c4
8 changed files with 36 additions and 33 deletions

View File

@ -3,7 +3,7 @@ include ../../libr/config.mk
.PHONY: all clean .PHONY: all clean
CFLAGS+=-I../../libr/include CFLAGS+=-I../../libr/include
CFLAGS+=-DLIBDIR=\"${PREFIX}/lib\" CFLAGS+=-DLIBDIR=\"${LIBDIR}\"
ifeq ($(WITHPIC),1) ifeq ($(WITHPIC),1)
LIBS=$(subst r_,-lr_,$(BINDEPS)) LIBS=$(subst r_,-lr_,$(BINDEPS))

View File

@ -1,7 +1,7 @@
include ../../config.mk include ../../config.mk
BINDEPS=r_lib r_bin r_flags r_util r_cons BINDEPS=r_lib r_bin r_flags r_util r_cons
CFLAGS+=-DLIBDIR=\"${PREFIX}/lib\" CFLAGS+=-DLIBDIR=\"${LIBDIR}\"
LIBS+=${DL_LIBS} LIBS+=${DL_LIBS}
LDPATH=-L.. -L../../util LDPATH=-L.. -L../../util

View File

@ -5,7 +5,7 @@ OBJ=lib.o
include ../config.mk include ../config.mk
# XXX only for linux # XXX only for linux
CFLAGS+=-Wall -DLIBR_PLUGINS=\"${PREFIX}/lib/radare2\" CFLAGS+=-Wall -DLIBR_PLUGINS=\"${LIBDIR}/radare2\"
LDFLAGS+=${DL_LIBS} LDFLAGS+=${DL_LIBS}

View File

@ -126,9 +126,10 @@ install-lua:
fi fi
install-go: install-go:
@if [ -n "${GOROOT}" -a -n "${GOOS}" -a -n "${GOARCH}" ]; then \ @. ./go/goenv.sh ; \
echo "Installing r2 modules in ${GOROOT}/pkg/${GOOS}_${GOARCH}" ; \ if [ -n "$${GOROOT}" -a -n "$${GOOS}" -a -n "$${GOARCH}" ]; then \
cp -f go/*.a go/*.${SOEXT} ${GOROOT}/pkg/${GOOS}_${GOARCH} ; \ echo "Installing r2 modules in $${GOROOT}/pkg/$${GOOS}_$${GOARCH}" ; \
cp -f go/*.a go/*.${SOEXT} $${GOROOT}/pkg/$${GOOS}_$${GOARCH} ; \
else \ else \
echo "You have to set the following vars: GOROOT, GOOS and GOARCH" ; \ echo "You have to set the following vars: GOROOT, GOOS and GOARCH" ; \
fi fi

View File

@ -13,24 +13,25 @@ include ../rules.mk
false ; \ false ; \
fi ; \ fi ; \
fi ; \ fi ; \
if [ "${GOARCH}" = "amd64" ]; then \ . ./goenv.sh ; \
GO_FLAGS=-D_64BIT ; \
GO_N=6 ; \
else \
if [ "${GOARCH}" = "386" ]; then \
GO_N=8 ; \
else \
GO_N=5 ; \
fi ; fi ; \
if [ $$? = 0 ]; then \ if [ $$? = 0 ]; then \
(cd .. && sh do-swig.sh ${LANG} `echo $@ | sed -e s,.so,,`) ; \ (cd .. && sh do-swig.sh ${LANG} `echo $@ | sed -e s,.so,,`) ; \
./fixgoswig.sh `echo $@ | sed -e s,.so,.go,` ; \ ./fixgoswig.sh `echo $@ | sed -e s,.so,.go,` ; \
$${GO_N}g `echo $@ | sed -e s,.so,.go,` ; \ echo $${GOC} `echo $@ | sed -e s,.so,.go,` ; \
$${GO_N}c $${GO_FLAGS} -I ${GOROOT}/pkg/${GOOS}_${GOARCH} `echo $@ | sed -e s,.so,_gc.c,` ; \ $${GOC} `echo $@ | sed -e s,.so,.go,` ; \
echo $${GOCC} $${GO_FLAGS} -I ${GOROOT}/pkg/$${GOOS}_$${GOARCH} `echo $@ | sed -e s,.so,_gc.c,` ; \
$${GOCC} $${GO_FLAGS} -I ${GOROOT}/pkg/$${GOOS}_$${GOARCH} `echo $@ | sed -e s,.so,_gc.c,` ; \
gopack grc `echo $@ | sed -e s,.so,.a,` `echo $@ | sed -e s,.so,.$${GO_N},` `echo $@ | sed -e s,.so,_gc.$${GO_N},` ; \ gopack grc `echo $@ | sed -e s,.so,.a,` `echo $@ | sed -e s,.so,.$${GO_N},` `echo $@ | sed -e s,.so,_gc.$${GO_N},` ; \
fi fi
rbintest: rbintest:
6g test-r_bin.go . ./goenv.sh ; \
6l test-r_bin.6 $${GOC} -I. test-r_bin.go ; \
./6.out /bin/ls $${GOL} -L. test-r_bin.$${GO_N} ; \
LD_LIBRARY_PATH=. ./$${GO_N}.out /bin/ls
ibintest:
. ./goenv.sh ; \
$${GOC} test-r_bin.go ; \
$${GOL} test-r_bin.$${GO_N} ; \
./$${GO_N}.out /bin/ls

View File

@ -4,20 +4,20 @@ import (
"os" "os"
"fmt" "fmt"
"r_bin" "r_bin"
) )
func main() { func main() {
if len(os.Args) < 2 { if len (os.Args) < 2 {
fmt.Println("Usage:", os.Args[0], "<bin>") fmt.Println ("Usage:", os.Args[0], "<bin>")
os.Exit(1) os.Exit (1)
} }
b := r_bin.NewRBin() b := r_bin.NewRBin ()
b.Load(os.Args[1], false) b.Load (os.Args[1], false)
baddr := b.Get_baddr() baddr := b.Get_baddr ()
fmt.Println("-> Sections") fmt.Println ("-> Sections")
fmt.Printf("baddr=%08x\n", baddr) fmt.Printf ("baddr=%08x\n", baddr)
for _, s:= range b.Get_sections() { for _, s:= range b.Get_sections () {
fmt.Printf("offset=0x%08x va=0x%08x size=%05d %s\n", fmt.Printf ("offset=0x%08x va=0x%08x size=%05d %s\n",
s.GetOffset(), baddr+s.GetRva(), s.GetSize(), s.GetName()) s.GetOffset(), baddr+s.GetRva(), s.GetSize(), s.GetName())
} }
} }

View File

@ -23,7 +23,7 @@ namespace Radare {
public int wr_output (string filename); public int wr_output (string filename);
public int load(string file, bool dummy); public int load(string file, bool dummy);
public int create(uint8 *code, int codelen, uint8 *data, int datalen); public RBuffer create(uint8 *code, int codelen, uint8 *data, int datalen);
public int use_arch(string arch, int bits, string name); public int use_arch(string arch, int bits, string name);
public int select(string arch, int bits, string name); public int select(string arch, int bits, string name);
public int select_idx(int idx); public int select_idx(int idx);

View File

@ -45,7 +45,7 @@ public class RCore {
public string op_str(uint64 addr); public string op_str(uint64 addr);
public RAnal.Op op_anal(uint64 addr); public RAnal.Op op_anal(uint64 addr);
public RAsm.Op disassemble(uint64 addr); public RAsm.Op* disassemble(uint64 addr); // memory leak here
public unowned string disassemble_instr(uint64 addr, int l); public unowned string disassemble_instr(uint64 addr, int l);
public unowned string disassemble_bytes(uint64 addr, int b); public unowned string disassemble_bytes(uint64 addr, int b);
@ -125,6 +125,7 @@ public class RCore {
// public static RList<RCoreAsmHit> AsmHit.list(); // public static RList<RCoreAsmHit> AsmHit.list();
} }
[CCode (cname="RCoreSearchCallback")]
public delegate int SearchCallback (uint64 from, uint8 *buf, int len); public delegate int SearchCallback (uint64 from, uint8 *buf, int len);
public bool search_cb(uint64 from, uint64 to, SearchCallback cb); public bool search_cb(uint64 from, uint64 to, SearchCallback cb);