-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/cgo: build fails on OS X 10.6 #5130
Labels
Milestone
Comments
My current diagnosis is that the Darwin linker on 10.6 has a bug. It does not correctly handle a X86_64_RELOC_UNSIGNED relocation with a size other than 64 bits. You can see the bug at line 4592 of http://opensource.apple.com/source/ld64/ld64-95.2.12/src/ld/MachOReaderRelocatable.hpp . It does an unconditional 64-bit load regardless of the relocation length. It then checks to see that the loaded address is within the target section. 6l is using 32 bit addresses to load variable addresses. This is unusual on a 64-bit system but it works fine provided the linker always puts the code in the low order 32 bits of the address space. Unfortunately this triggers the bug in the Darwin linker. In 10.7 the linker appears to have been completely rewritten, and it no longer has this bug. One possible fix would be to change 6l to convert MOVQ from an absolute address to use RIP-relative addressing instead. That would continue using a 32-bit address, but would produce a relocation that the Darwin 10.6 linker can understand. I don't know how complex that would be. I also don't know if there are other cases that would have to be addressed. |
Note that I've already added the necessary PIC changes to 6l, guarded by the -shared flag. I suppose darwin (10.6) could re-use the PIC mode, but since RIP-relative addressing excludes other useful addressing modes the resulting code size will grow, which is probably not an acceptable tradeoff. |
Note that I've already added the necessary PIC changes to 6l, guarded by the -shared flag. I suppose darwin (10.6) could re-use the PIC mode, but since RIP-relative addressing excludes other useful addressing modes the resulting code size will grow, which is probably not an acceptable tradeoff. |
This issue was closed by revision 3197be4. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: