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

Go bindings are broken #27

Open
williballenthin opened this issue May 27, 2014 · 9 comments
Open

Go bindings are broken #27

williballenthin opened this issue May 27, 2014 · 9 comments

Comments

@williballenthin
Copy link

I am unable to get the Go-language bindings working with r2. I don't think this is due to an issue with r2 being in a state of flux, rather I think it has something to do with the binding generation themselves. I fixed as many Go binding bugs as I could (see other PRs), but I'm woefully uneducated in SWIG.

Details:

$ cd radare2-bindings/go
$ # remove Makefile line 5 (`include ../rules.mk`), as described in #26, or we don't get anywhere
$ make r_bin.so
  ...   # output looks fine
$ make rbintest
. ./goenv.sh ; \
    ${GOC} -I . test-r_bin.go ; \
    ${GOL} -L . test-r_bin.${GO_N} ; \
    LD_LIBRARY_PATH=. ./${GO_N}.out /bin/ls
./6.out: symbol lookup error: ./6.out: undefined symbol: _wrap_RListIter_get_next
make: *** [rbintest] Error 127

Other supporting details:

$ nm 6.out | grep _wrap_RListIter_get_next                                
  00000000004506f0 T r_bin._swig_wrap_RListIter_get_next
  00000000005ef2b0 d x_wrap_RListIter_get_next
$ nm r_bin.a | grep _wrap_RListIter_get_next     
  nm: __.GOSYMDEF: File format not recognized
  nm: __.PKGDEF: File format not recognized
  nm: r_bin.6: File format not recognized
  nm: r_bin_gc.6: File format not recognized
$ grep _wrap_RListIter_get_next r_bin_wrap.cxx                            
  void _wrap_RListIter_get_next(void *swig_v) { RListIter *arg1 = (RListIter *) 0 ;     RListIter *result = 0 ; struct swigargs {

I think the fix would be small, but requires insight into r2 and SWIG (which I don't have yet). If you could dedicate a little time to fixing the the issue, I'd really appreciate it. Otherwise, if you could point me towards the appropriate resources to learn to do it myself, that would be a great help.

@radare
Copy link
Collaborator

radare commented May 27, 2014

I’m in favor of implementing valabind —golang to generate CGO bindings without depending
on SWIG. That would be like the ctypes or nodejs bindings. Do you want to contribute on this?

On OSX I get the following error:

Undefined symbols for architecture x86_64:
  "__cgo_allocate", referenced from:
      _swig_goallocate(unsigned long) in r_bin_wrap-cac679.o
  "__cgo_panic", referenced from:
      _swig_gopanic(char const*) in r_bin_wrap-cac679.o
  "_crosscall2", referenced from:
      _swig_gopanic(char const*) in r_bin_wrap-cac679.o
      _swig_goallocate(unsigned long) in r_bin_wrap-cac679.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

which seems to be related to the version of Go installed.

On 27 May 2014, at 03:20, Willi Ballenthin notifications@github.com wrote:

I am unable to get the Go-language bindings working with r2. I don't think this is due to an issue with r2 being in a state of flux, rather I think it has something to do with the binding generation themselves. I fixed as many Go binding bugs as I could (see other PRs), but I'm woefully uneducated in SWIG.

Details:

$ cd radare2-bindings/go
$ # remove Makefile line 5 (include ../rules.mk), as described in #26, or we don't get anywhere
$ make r_bin.so
... # output looks fine
$ make rbintest
. ./goenv.sh ;
${GOC} -I . test-r_bin.go ;
${GOL} -L . test-r_bin.${GO_N} ;
LD_LIBRARY_PATH=. ./${GO_N}.out /bin/ls
./6.out: symbol lookup error: ./6.out: undefined symbol: _wrap_RListIter_get_next
make: *** [rbintest] Error 127
Other supporting details:

$ nm 6.out | grep _wrap_RListIter_get_next
00000000004506f0 T r_bin._swig_wrap_RListIter_get_next
00000000005ef2b0 d x_wrap_RListIter_get_next
$ nm r_bin.a | grep _wrap_RListIter_get_next
nm: __.GOSYMDEF: File format not recognized
nm: __.PKGDEF: File format not recognized
nm: r_bin.6: File format not recognized
nm: r_bin_gc.6: File format not recognized
$ grep _wrap_RListIter_get_next r_bin_wrap.cxx
void _wrap_RListIter_get_next(void *swig_v) { RListIter *arg1 = (RListIter *) 0 ; RListIter *result = 0 ; struct swigargs {
I think the fix would be small, but requires insight into r2 and SWIG (which I don't have yet). If you could dedicate a little time to fixing the the issue, I'd really appreciate it. Otherwise, if you could point me towards the appropriate resources to learn to do it myself, that would be a great help.


Reply to this email directly or view it on GitHub.

@williballenthin
Copy link
Author

Sure, I'd be happy to look into implementing a Go writer for valabind. I'll use the existing writers as examples.

Thanks for the quick response!

@radare
Copy link
Collaborator

radare commented May 27, 2014

Awesome!

Yesterday i was playing a little with gco to make the bindings for sdb and learn a litle of go.

It seems that swig is again doing an awful job and it would be better to nake our own bindings.

I would add --golang to valabind, look at the ctypes or nodejs implementation. It should be quite straight forward.

Thanks!

On 27 May 2014, at 03:40, Willi Ballenthin notifications@github.com wrote:

Sure, I'd be happy to look into implementing a Go writer for valabind. I'll use the existing writers as examples.

Thanks for the quick response!


Reply to this email directly or view it on GitHub.

@XVilka
Copy link
Contributor

XVilka commented Aug 11, 2014

@williballenthin shall we close this bug now?

@williballenthin
Copy link
Author

Sorry, but unfortunately my bindings are not yet complete. In fact, they probably don't cover much of the existing r2 API, yet. Finishing them is high on my list of projects, but realistically, won't happen this week.

@XVilka XVilka added this to the 1.0.0 milestone Apr 18, 2015
@XVilka
Copy link
Contributor

XVilka commented Apr 18, 2015

@williballenthin I'm postponing this to 1.0.0 release, but you always can improve Go bindings earlier :)

@radare
Copy link
Collaborator

radare commented Apr 18, 2015

The r2pipe go bindings are very mature and stable right now. And i think it fits better with the philosophy of extending and using r2 from bindings is getting in shape. But yeah it would be great to make valabind work fine for go

On 18 Apr 2015, at 23:54, Anton Kochkov notifications@github.com wrote:

@williballenthin I'm postponing this to 1.0.0 release, but you always can improve Go bindings earlier :)


Reply to this email directly or view it on GitHub.

@radare
Copy link
Collaborator

radare commented May 31, 2016

@XVilka XVilka removed this from the 1.0.0 milestone Feb 25, 2019
@XVilka
Copy link
Contributor

XVilka commented Oct 21, 2019

By the way, I wrote a simple Python script to generate the bindings for some languages directly from the C headers, so no need for middle-men like Valabind or SWIG, it supports Go through c-for-go, see https://github.com/radareorg/radare2-bindings#experimental-radare2-bindgen

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

No branches or pull requests

3 participants