This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fpic vs -fPIC
- To: kthomas at gwdg dot de
- Subject: Re: -fpic vs -fPIC
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Mon, 19 Apr 1999 09:05:52 +0200
- CC: egcs at cygnus dot com
- References: <3720a225.77123225@mailer.gwdg.de>
> Could somebody please explain to me the different approaches gcc uses when
> given one or the other flag ? I only found the description in gcc.info that
> -fPIC overcomes a size limit but not how that's achieved.
It very much depends on the architecture. In addition to the
architectures listed in gcc.info, -fPIC makes a difference on PA and
rs6000. Although I haven't understood all the architectures, here is
what I found:
On m68k and m88k, -fPIC will result in GOT symbols that end in ":l"
instead of ":w". I assume that a wider immediate constant is emitted,
together with using a wider register.
On Sparc, an immediate 32bit-constant can't be loaded in a single
instruction, unless it is smaller than a limit. So with -fPIC, the
compiler uses two (logical) registers to load the constants, and also
emits two Sparc-specific relocations.
For rs6000, the difference is only real on V4 unix variants
(e.g. Solaris); for AIX and NT, it makes no difference. On the former
systems, access to pic symbols goes through something called the
"constant pool".
On PA, it also appears that the pic value is loaded in two
instructions, the second being "addil LT'%G2,%1".
> As the info says that -fPIC isn't needed for x86, I'm always
> changing libtool in new packages I compile to use -fpic. But I was
> always unsure if this is the right thing to do and would like to
> know the implications in order to base my doing on knowledge rather
> than guesswork.
Well, -fPIC isn't needed, or at least it makes no difference compared
to -fpic. Either option is a good idea when compiling shared
libraries.
Regards,
Martin