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

cmd/link: bad relocations on darwin #7280

Closed
dvyukov opened this issue Feb 7, 2014 · 4 comments
Closed

cmd/link: bad relocations on darwin #7280

dvyukov opened this issue Feb 7, 2014 · 4 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Feb 7, 2014

parent: 19024:e2f19c96b7e2 tip, darwin/amd64

$ hg clpatch 55100044
$ ./make.bash
$ go run -race pkg/runtime/race/testdata/cgo_test_main.go

crashes with random failures depending on revision number.
The root cause is that runtime.racefuncenter calls to a random address instead of
__tsan_func_enter.

If 
    CALL    __tsan_func_enter(SB)
is replaced with:
    MOVQ    $__tsan_func_enter(SB), AX
    CALL    AX
then it works correctly.

The difference that I see between these versions is:
machoreloc1 rs->name=__tsan_read r->type=120
machoreloc1 rs->name=__tsan_read r->type=247

120 refers to D_ADDR and works, 247 refers to D_PCREL and does not work.
Not sure where to dig further.
@dvyukov
Copy link
Member Author

dvyukov commented Feb 10, 2014

Comment 1:

Russ, can you help with this? It seems to be your code.

@rsc
Copy link
Contributor

rsc commented Feb 24, 2014

Comment 2:

My suggestion is to keep using that workaround for now.
We can look at this for Go 1.4, but I don't want to make linker changes now, and you've
got a way to make it work.

Labels changed: added release-go1.4, removed release-go1.3.

Owner changed to ---.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 3:

Labels changed: added release-go1.5, removed release-go1.4.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc added OS-Darwin and removed os-macosx labels Apr 10, 2015
@rsc rsc changed the title cmd/ld: bad relocations on darwin cmd/link: bad relocations on darwin Jun 8, 2015
@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

It looks to me like later refactoring of the code has removed even the possibility of writing the alternate form, so there's not much left to do here. I don't know why the PC-relative instruction failed, but it has to do with relocations and linking and probably magic indirections, so it's not surprising there is a detail wrong somewhere.

@rsc rsc closed this as completed Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 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

4 participants