Skip to content

cmd/ld: unsupported relocation for dynamic symbol #9967

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

Closed
sbinet opened this issue Feb 23, 2015 · 4 comments
Closed

cmd/ld: unsupported relocation for dynamic symbol #9967

sbinet opened this issue Feb 23, 2015 · 4 comments

Comments

@sbinet
Copy link
Member

sbinet commented Feb 23, 2015

  • What version of Go are you using (go version)?
    go version go1.4.2 darwin/amd64
    MacOSX-10.6.8
  • What did you do?
$ cd $GOPATH/src/github.com/sbinet
$ git clone git://github.com/sbinet/test-cgo
$ cd test-cgo
$ make
/bin/rm -f pkg/my/*.so
(cd pkg/my && cc -shared -o libmy.so lib.c)
# github.com/sbinet/test-cgo/pcgo
github.com/sbinet/test-cgo/pkg._Cvar_Global: unsupported relocation for dynamic symbol Global (type=1 stype=32)
github.com/sbinet/test-cgo/pkg._Cvar_Global: unhandled relocation for Global (type 32 rtype 1)
make: *** [install] Error 2

note that if, in test-cgo/pkg/my/lib.h I change:

#define API_DATA(RTYPE) extern RTYPE
//#define API_DATA(RTYPE) RTYPE

to:

//#define API_DATA(RTYPE) extern RTYPE
#define API_DATA(RTYPE) RTYPE

everything compiles and runs:

$ make && (cd ./pkg/my && pcgo)
/bin/rm -f pkg/my/*.so
(cd pkg/my && cc -shared -o libmy.so lib.c)
>>>
Global: 42
Global: 42
<<<

Note that on master, I get instead:

$ go version devel +48469a2 Mon Feb 23 07:54:13 2015 +0000 darwin/amd64
$ make && (cd ./pkg/my && pcgo)
>>>
Global: 42
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0xb01dfacedebac1e pc=0x1dbf23]

runtime stack:
runtime.throw(0x126e70, 0x2a)
    /Users/binet/dev/go/root/go/src/runtime/panic.go:511 +0xa0
runtime.sigpanic()
    /Users/binet/dev/go/root/go/src/runtime/sigpanic_unix.go:12 +0x62

goroutine 1 [syscall, locked to thread]:
runtime.cgocall_errno(0xac120, 0xc208037ed0, 0xc200000000)
    /Users/binet/dev/go/root/go/src/runtime/cgocall.go:130 +0x10c fp=0xc208037eb0 sp=0xc208037e88
github.com/sbinet/test-cgo/pkg._Cfunc_Get(0x25ff0000077a25ff, 0x0)
    /Users/binet/dev/go/root/path/src/github.com/sbinet/test-cgo/pkg/:24 +0x3c fp=0xc208037ed0 sp=0xc208037eb0
github.com/sbinet/test-cgo/pkg.Print()
    /Users/binet/dev/go/root/path/src/github.com/sbinet/test-cgo/pkg/pkg.go:14 +0x10c fp=0xc208037f58 sp=0xc208037ed0
main.main()
    /Users/binet/dev/go/root/path/src/github.com/sbinet/test-cgo/pcgo/main.go:11 +0x4e fp=0xc208037fa0 sp=0xc208037f58
runtime.main()
    /Users/binet/dev/go/root/go/src/runtime/proc.go:88 +0x1d2 fp=0xc208037fe0 sp=0xc208037fa0
runtime.goexit()
    /Users/binet/dev/go/root/go/src/runtime/asm_amd64.s:2466 +0x1 fp=0xc208037fe8 sp=0xc208037fe0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /Users/binet/dev/go/root/go/src/runtime/asm_amd64.s:2466 +0x1
zsh: exit 2     (; cd pkg/my && pcgo; )

Such extern global symbols are heavily used in e.g. the CPython API.

To recap: the pkg builds fine, it's when somebody uses that cgo-based package that all hell breaks loose.

@rsc
Copy link
Contributor

rsc commented Apr 10, 2015

I suspect this is a duplicate of #8009.

Issue #9511 talks about dropping support for OS X 10.6 officially. If we do that we can close this bug and #8009 and maybe a few others.

@rsc rsc changed the title cgo: unsupported relocation for dynamic symbol cmd/ld: unsupported relocation for dynamic symbol Apr 10, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@sbinet
Copy link
Member Author

sbinet commented Apr 12, 2015

yes, most probably the same underlying issue.

I just upgraded my old (2008) macbook-pro from 10.6 to 10.10 (yosemite) and everything works fine (master and 1.4.2)

@rsc
Copy link
Contributor

rsc commented Apr 28, 2015

Per #9511, we will not be making any further bug fixes specific to 10.6.

1 similar comment
@rsc
Copy link
Contributor

rsc commented Apr 28, 2015

Per #9511, we will not be making any further bug fixes specific to 10.6.

@rsc rsc closed this as completed Apr 28, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants