public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [testsuite] Run TLS torture tests with -fpic etc.
Date: Tue, 07 Jun 2011 16:48:00 -0000	[thread overview]
Message-ID: <yddei35io53.fsf@manam.CeBiTec.Uni-Bielefeld.DE> (raw)
In-Reply-To: <yddsjrnpa7r.fsf@manam.CeBiTec.Uni-Bielefeld.DE> (Rainer Orth's	message of "Mon, 06 Jun 2011 11:42:32 +0200")

Jakub,

any word on this patch?   I think I only need approval for the gcc.c
part.

Thanks.
        Rainer


Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Jakub Jelinek <jakub@redhat.com> writes:
>
>> On Fri, Jun 03, 2011 at 09:38:31PM +0200, Rainer Orth wrote:
>>> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>>> Jakub, any suggestion how to properly test for -fpie/-fPIE support?
>>> Otherwise, I'll remove that part of the patch for now and just commit
>>> the -fpic/-fPIC one.
>>
>> You want to compile/link the program with -pie -fpie rather than just -fpie,
>> if it links, otherwise you are testing just linking PIC code into normal
>> executables.
>
> Ok, thanks.  Unfortunately, this didn't work out of the box since for
> targets where the linker doesn't support -pie, gcc silently ignores it
> which I think is bad style.
>
> The following patch corrects this by rejecting -pie in this case.  I've
> also added a effective-target keyword pie for testsuite use, both below
> and in the revised TLS torture tests to be submitted separately.
>
> I didn't introduce a separte fpie keyword since e.g. gcc.dg/tls/pie-1.c
> uses fpic for that purpose, but maybe I should?
>
> One other question: gcc.target/i386/pr39013-[12].c is currently
> restricted to *-*-linux*.  Any particular reason for that?
>
> Bootstrapped without regressions on i386-pc-solaris2.11 with Sun ld (no
> -pie support, pie-link becomes UNSUPPORTED) and with GNU ld 2.21 (-pie
> support, 32-bit pie-link works, 64-bit pie-link becomes unsupported:
>
> /vol/gcc/bin/gld-2.21: /usr/lib/amd64/crt1.o: relocation R_X86_64_32S against `_DYNAMIC' can not be used when making a shared object; recompile with -fPIC
> /usr/lib/amd64/crt1.o: could not read symbols: Bad value
>
> ).  Ok for mainline?
>
> Thanks.
>         Rainer
>
>
> 2011-06-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
> 	gcc:
> 	* gcc.c [!HAVE_LD_PIE] (LINK_PIE_SPEC): Reject -pie.
> 	* doc/sourcebuild.texi (Effective-Target Keywords, pie): Document it.
>
> 	gcc/testsuite:
> 	* lib/target-supports.exp (check_effective_target_pie): New proc.
> 	* gcc.dg/pie-link.c: Use target pie.
> 	Add -pie to dg-options.
>
> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> --- a/gcc/doc/sourcebuild.texi
> +++ b/gcc/doc/sourcebuild.texi
> @@ -1782,6 +1782,9 @@ Target defines @code{PCC_BITFIELD_TYPE_M
>  @item pe_aligned_commons
>  Target supports @option{-mpe-aligned-commons}.
>  
> +@item pie
> +Target supports @option{-pie}, @option{-fpie} and @option{-fPIE}.
> +
>  @item section_anchors
>  Target supports section anchors.
>  
> diff --git a/gcc/gcc.c b/gcc/gcc.c
> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -612,7 +612,7 @@ proper position among the other output f
>  #ifdef HAVE_LD_PIE
>  #define LINK_PIE_SPEC "%{pie:-pie} "
>  #else
> -#define LINK_PIE_SPEC "%{pie:} "
> +#define LINK_PIE_SPEC "%{pie:%e-pie is not supported in this configuration} "
>  #endif
>  #endif
>  
> diff --git a/gcc/testsuite/gcc.dg/pie-link.c b/gcc/testsuite/gcc.dg/pie-link.c
> --- a/gcc/testsuite/gcc.dg/pie-link.c
> +++ b/gcc/testsuite/gcc.dg/pie-link.c
> @@ -1,5 +1,5 @@
> -/* { dg-do link { target *-*-darwin[912]* *-*-linux* } } */
> -/* { dg-options "-fpie" } */
> +/* { dg-do link { target pie } } */
> +/* { dg-options "-pie -fpie" } */
>  
>  int main(void)
>  {
> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -788,6 +788,18 @@ proc check_effective_target_fpic { } {
>      return 0
>  }
>  
> +# Return 1 if -pie, -fpie and -fPIE are supported, as in no warnings or errors
> +# emitted, 0 otherwise.
> +
> +proc check_effective_target_pie { } {
> +    if [check_no_compiler_messages pie executable {
> +	int main (void) { return 0; }
> +    } "-pie -fpie"] {
> +	return 1
> +    }
> +    return 0
> +}
> +
>  # Return true if the target supports -mpaired-single (as used on MIPS).
>  
>  proc check_effective_target_mpaired_single { } {

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

  reply	other threads:[~2011-06-07 16:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-30 17:45 Rainer Orth
2011-06-03 19:38 ` Rainer Orth
2011-06-03 19:44   ` Jakub Jelinek
2011-06-06  9:42     ` Rainer Orth
2011-06-07 16:48       ` Rainer Orth [this message]
2011-06-07 16:55         ` Jakub Jelinek
2011-06-07 16:57           ` Rainer Orth
2011-06-10 10:14           ` Rainer Orth
2011-06-10 14:13             ` Joseph S. Myers
2011-06-10 14:45               ` Rainer Orth
2011-06-10 15:11 ` Rainer Orth
2011-06-15 16:33   ` Ramana Radhakrishnan
2011-06-15 17:29     ` Mike Stump
2011-06-15 23:07       ` Ramana Radhakrishnan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yddei35io53.fsf@manam.CeBiTec.Uni-Bielefeld.DE \
    --to=ro@cebitec.uni-bielefeld.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).