https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80759
Daniel Santos <daniel.santos at pobox dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #41605|0 |1 is obsolete| | --- Comment #54 from Daniel Santos <daniel.santos at pobox dot com> --- Created attachment 41627 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41627&action=edit darwin fixup (on top of v6) -- second attempt So I've learned that some_symbol@GOTPCREL(%%rip) resolves to the the address of the GOT *entry* for that symbol, which has to be dereferenced to get the address of the object its self. I was able to test this on my machine by changing #ifdef __MACH__ to #ifndef and this patch is working using the GOT. I've re-written do_test_body and added a macro LOAD_TEST_DATA_ADDR(dest) in hopes to make both the sources fairly readable and the resulting assembly also readable. To simplify the routine, I changed mem_to_regs/regs_to_mem to use r10 instead of rax so that I don't have to save and restore it. Of course this is sub-optimal code, but the execution of the test program is by no means the bottleneck -- I'm trying to keep it as simple and maintainable as possible! The macro has only two uses, so if you prefer, I can remove it and just replace it with inline #if blocks, e.g., #ifdef __MACH__ " mov " ASMNAME(test_data) "@GOTPCREL(%%rip), %%rax\n" #else " lea " ASMNAME(test_data) "(%%rip), %%rax\n" #endif Thanks! Daniel