[Bug middle-end/63793] -mcmodel=medium in gfortran on x86_64 emits references that are RIP relative (instead of using the GOT)

howarth at bromo dot med.uc.edu gcc-bugzilla@gcc.gnu.org
Fri Nov 14 00:36:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63793

--- Comment #13 from howarth at bromo dot med.uc.edu ---
(In reply to howarth from comment #11)
> FYI, the darwin linker developer had the following comments on @GOTOFF..
> 
> > This may be a red herring.
> > 
> > @GOTOFF is a different concept.  IIRC, the ELF runtime sets of RBX to point
> >  to the GOT table.  @GOTOFF is for accessing variables that are a (link time)
> > fixed offset in the GOT table.
> > 
> > Darwin does not support @GOTOFF at all.  Local variables are accessed 
> > RIP-rel, or if large, indirectly via @GOT.
> 
> However, outside of the sections of gcc/config/i386/i386.[c/md] conditional
> on HAVE_AS_GOTOFF_IN_DATA, I don't see any other obvious places where %rip
> would be emitted for Mach-O but not linux.

Empirically, it seems logical that this bug should be in the section
conditional on HAVE_AS_GOTOFF_IN_DATA because the problematic symbol with the
core name sumpartgrid shows up as in a grep of the assembly as...

    movabsq    $sumpartgrid.3500@GOTOFF, %rax

on linux, while on darwin it shows up as

    leaq    _sumpartgrid.2471(%rip), %rax

I am assuming that the emission of @GOTOFF on linux is entirely under the
control of the HAVE_AS_GOTOFF_IN_DATA conditional and thus should point us at
the section that needs to be enhanced to use &GOT on darwin for
-mcmodel=medium/large.



More information about the Gcc-bugs mailing list