-
Notifications
You must be signed in to change notification settings - Fork 17.3k
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
cgo/darwin-amd64: Contant float/double values incorrectly initialized for statically linked objects. #1658
Labels
Comments
Labels changed: added cgo. Owner changed to @rsc. Status changed to Accepted. |
A little mind dump: After adding the __rodata section to the output file, it seems to almost work. (https://gist.github.com/901976) However, the addends that are calculated for relocations of what was previously the __literal8 section are wrong. I tried to ignore the addend for these cases (explicitly zero it), but this just makes it always reference the first float value. Also, the symnum of the relocation points to the __literal8 section and not a particular symbol, so I'm guessing that the addend in this case should be the offset into the __literal8 section, somehow... |
OK, the reason it references a section and not a symbol is that rel->extrn == 0. I guess that case isn't handled correctly in the linker? /usr/include/mach-o/x86_64/reloc.h has this to say about the relocations that accessing __literal8 data generates: lea L0(%rip), %rax r_type=X86_64_RELOC_SIGNED, r_length=2, r_extern=0, r_pcrel=1, r_symbolnum=3 48 8d 05 56 00 00 00 // assumes L0 is in third section and there is no previous non-local label. // The rip-relative-offset of 0x00000056 is L0-address_of_next_instruction. // address_of_next_instruction is the address of the relocation + 4. |
This issue was closed by revision 2aceea6. 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.
Attachments:
The text was updated successfully, but these errors were encountered: