This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Why -mxgot on MIPS and not -fpic/-fPIC?
- From: Matthew Fortune <Matthew dot Fortune at imgtec dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>, "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Cc: Maciej Rozycki <Maciej dot Rozycki at imgtec dot com>
- Date: Mon, 3 Oct 2016 12:45:43 +0000
- Subject: RE: Why -mxgot on MIPS and not -fpic/-fPIC?
- Authentication-results: sourceware.org; auth=none
- References: <877f9rsryz.fsf@mid.deneb.enyo.de>
Florian Weimer <fw@deneb.enyo.de> writes:
> It looks like -mxgot has a similar impact on MIPS as using -fPIC
> (instead of -fpic) on other architectures.
>
> Why wasn't the -fpic/-fPIC distinction carried over to MIPS?
Much of the history here is probably folklore and guesswork but for
my understanding is that MIPS has three levels of 'pic'.
MIPS PIC code is really controlled by -mabicalls and -mshared which
I assume originate from the MIPS-pro days.
-fpic is simply set to imply -mabicalls and -mshared which is where
everything gets far more confusing (but let's not get into that
unless we have to)
The reason there is no -fPIC is probably a conscious decision as
MIPS has 'multi-got' that allows the small -fpic model to scale to
most situations.
-mxgot (aka big-got) is however a good match for -fPIC as it is a
model guaranteed to work irrespective of how big the GOT is.
I do have a report to deal with about -fPIC and the value it sets
for __PIC__ because it always sets '1' due to not supporting -fPIC.
It is tempting to just make -fPIC imply -mxgot and set __PIC__ to 2
but it will lead to bloated code in a number of cases where
multi-got is sufficient.
This is one of several conflicted issues for MIPS that has no
obvious right answer.
Matthew