Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: bad relocations on darwin #7280
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.
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.