This is the mail archive of the
mailing list for the GCC project.
Re: gcc corrections for better pie support
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: "Peter S. Mazinger" <ps dot m at gmx dot net>
- Cc: Thiemo Seufer <ica2_ts at csv dot ica dot uni-stuttgart dot de>, Zack Weinberg <zack at codesourcery dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 10 Nov 2004 11:59:04 +0000
- Subject: Re: gcc corrections for better pie support
- References: <Pine.LNX.email@example.com>
"Peter S. Mazinger" <firstname.lastname@example.org> writes:
> On Wed, 10 Nov 2004, Richard Sandiford wrote:
>> Thiemo Seufer <email@example.com> writes:
>> > Richard Sandiford wrote:
>> >> So the current handling of __PIC__ is inconsistent. What does it mean
>> >> for mips*-linux-gnu targets? Does it mean:
>> >> (1) That position independent code has been explicitly selected?
>> >> If so, then flag_pie || flag_shlib seems like the right condition.
>> >> (2) That abicalls code is selected? If so, then the current specs are
>> >> wrong, because "gcc -fno-pic" generates abicalls code.
>> >> But I suppose the current definition is closest to (2). If (2) is indeed
>> >> what we want, then another alternative would be to guard the __PIC__
>> >> definition in linux.h with TARGET_ABICALLS.
>> > Currently in use on MIPS linux are:
>> > - PIC + abicalls for the whole userland. __PIC__ is always expected to
>> > be defined. Executables are always PIC. This is the toolchain default.
>> Executables are created from position-independent objects, but the
>> executables themselves are not PIC. They have a fixed load address
>> and are not relocatable. Hence...
> This is not quite true, I have access to a mips box running uclibc and I
> can build PIE executables, these are relocatable (I know though that such
> test can't be done on glibc, because it fails w/ undefs)
I was talking specifically about the default here, not what happens when
you use -fpie or -fPIE (note the highlighted context). It _is_ true that
mips*-linux-gnu does not create position-independent executables by default.
FWIW (in case this is what you're suggesting) I think making uclibc
targets generate PIE by default would be a mistake.
Anyway (and thanks to Thiemo for his reply), it looks like we're getting
close agreement on the __PIC__=abicalls thing. Going back to your patch,
I think the summary is:
- Remove the __PIC__ handling from spec strings and guard the
TARGET_OS_CPP_BUILTINS definition with TARGET_ABICALLS.
- Make the assembler spec pass -KPIC unless -mno-abicalls is used.