* [testsuite] Run TLS torture tests with -fpic etc.
@ 2011-05-30 17:45 Rainer Orth
2011-06-03 19:38 ` Rainer Orth
2011-06-10 15:11 ` Rainer Orth
0 siblings, 2 replies; 14+ messages in thread
From: Rainer Orth @ 2011-05-30 17:45 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
As suggested by Joseph, the gcc.dg/torture/tls tests should be run with
-fpic/-fPIC and -fpie/-fPIE if supported.
The patch below implements part of this. Unlike
gcc.dg/torture/stackalign/stackalign.exp, I'm using the code below to
add -fpic etc. to the torture options so it shows up in gcc.sum.
Unfortunately, I have no idea how to properly test if -fpie/-fPIE is
supported. Jakub, do you have a suggestion? Such a test could (and
probably should) be used in the few tests we currently have for -fpie:
gcc.dg/tls/pie-1.c, gcc.dg/pie-link.c, gcc.target/i386/pr39013-[12].c
Bootstrapped without regression on i386-pc-solaris2.11.
Will install on mainline unless someone objects once the -fpie test has
been fixed.
Rainer
2011-05-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* lib/target-supports.exp (check_effective_target_fpie): New proc.
* gcc.dg/torture/tls/tls.exp: Load torture-options.exp.
Run tests with -fpic/-fPIC, -fpie/-fPIE if supported.
diff --git a/gcc/testsuite/gcc.dg/torture/tls/tls.exp b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
--- a/gcc/testsuite/gcc.dg/torture/tls/tls.exp
+++ b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Free Software Foundation, Inc.
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
# Load support procs.
load_lib gcc-dg.exp
+load_lib torture-options.exp
# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
@@ -25,12 +26,32 @@ if ![info exists DEFAULT_CFLAGS] then {
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}
+global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
+set TLS_TORTURE_OPTIONS $DG_TORTURE_OPTIONS
+if { [check_effective_target_fpic] } then {
+ foreach pic {fpic fPIC} {
+ foreach option $DG_TORTURE_OPTIONS {
+ lappend TLS_TORTURE_OPTIONS "$option -$pic"
+ }
+ }
+}
+if { [check_effective_target_fpie] } then {
+ foreach pie {fpie fPIE} {
+ foreach option $DG_TORTURE_OPTIONS {
+ lappend TLS_TORTURE_OPTIONS "$option -$pie"
+ }
+ }
+}
+
# Initialize `dg'.
dg-init
+torture-init
+set-torture-options $TLS_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
# Main loop.
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
$DEFAULT_CFLAGS
# All done.
+torture-finish
dg-finish
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 -fpie and -fPIE are supported, as in no warnings or errors
+# emitted, 0 otherwise.
+
+proc check_effective_target_fpie { } {
+ if [check_no_compiler_messages fpie executable {
+ int main (void) { return 0; }
+ } "-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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-05-30 17:45 [testsuite] Run TLS torture tests with -fpic etc Rainer Orth
@ 2011-06-03 19:38 ` Rainer Orth
2011-06-03 19:44 ` Jakub Jelinek
2011-06-10 15:11 ` Rainer Orth
1 sibling, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-06-03 19:38 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
> As suggested by Joseph, the gcc.dg/torture/tls tests should be run with
> -fpic/-fPIC and -fpie/-fPIE if supported.
>
> The patch below implements part of this. Unlike
> gcc.dg/torture/stackalign/stackalign.exp, I'm using the code below to
> add -fpic etc. to the torture options so it shows up in gcc.sum.
>
> Unfortunately, I have no idea how to properly test if -fpie/-fPIE is
> supported. Jakub, do you have a suggestion? Such a test could (and
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.
> probably should) be used in the few tests we currently have for -fpie:
>
> gcc.dg/tls/pie-1.c, gcc.dg/pie-link.c, gcc.target/i386/pr39013-[12].c
>
> Bootstrapped without regression on i386-pc-solaris2.11.
>
> Will install on mainline unless someone objects once the -fpie test has
> been fixed.
>
> Rainer
>
>
> 2011-05-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
>
> * lib/target-supports.exp (check_effective_target_fpie): New proc.
> * gcc.dg/torture/tls/tls.exp: Load torture-options.exp.
> Run tests with -fpic/-fPIC, -fpie/-fPIE if supported.
>
> diff --git a/gcc/testsuite/gcc.dg/torture/tls/tls.exp b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
> --- a/gcc/testsuite/gcc.dg/torture/tls/tls.exp
> +++ b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
> @@ -1,4 +1,4 @@
> -# Copyright (C) 2010 Free Software Foundation, Inc.
> +# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
>
> # This program is free software; you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> @@ -18,6 +18,7 @@
>
> # Load support procs.
> load_lib gcc-dg.exp
> +load_lib torture-options.exp
>
> # If a testcase doesn't have special options, use these.
> global DEFAULT_CFLAGS
> @@ -25,12 +26,32 @@ if ![info exists DEFAULT_CFLAGS] then {
> set DEFAULT_CFLAGS " -ansi -pedantic-errors"
> }
>
> +global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
> +set TLS_TORTURE_OPTIONS $DG_TORTURE_OPTIONS
> +if { [check_effective_target_fpic] } then {
> + foreach pic {fpic fPIC} {
> + foreach option $DG_TORTURE_OPTIONS {
> + lappend TLS_TORTURE_OPTIONS "$option -$pic"
> + }
> + }
> +}
> +if { [check_effective_target_fpie] } then {
> + foreach pie {fpie fPIE} {
> + foreach option $DG_TORTURE_OPTIONS {
> + lappend TLS_TORTURE_OPTIONS "$option -$pie"
> + }
> + }
> +}
> +
> # Initialize `dg'.
> dg-init
> +torture-init
> +set-torture-options $TLS_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
>
> # Main loop.
> gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
> $DEFAULT_CFLAGS
>
> # All done.
> +torture-finish
> dg-finish
> 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 -fpie and -fPIE are supported, as in no warnings or errors
> +# emitted, 0 otherwise.
> +
> +proc check_effective_target_fpie { } {
> + if [check_no_compiler_messages fpie executable {
> + int main (void) { return 0; }
> + } "-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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-03 19:38 ` Rainer Orth
@ 2011-06-03 19:44 ` Jakub Jelinek
2011-06-06 9:42 ` Rainer Orth
0 siblings, 1 reply; 14+ messages in thread
From: Jakub Jelinek @ 2011-06-03 19:44 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches
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.
Jakub
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-03 19:44 ` Jakub Jelinek
@ 2011-06-06 9:42 ` Rainer Orth
2011-06-07 16:48 ` Rainer Orth
0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-06-06 9:42 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-06 9:42 ` Rainer Orth
@ 2011-06-07 16:48 ` Rainer Orth
2011-06-07 16:55 ` Jakub Jelinek
0 siblings, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-06-07 16:48 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-07 16:48 ` Rainer Orth
@ 2011-06-07 16:55 ` Jakub Jelinek
2011-06-07 16:57 ` Rainer Orth
2011-06-10 10:14 ` Rainer Orth
0 siblings, 2 replies; 14+ messages in thread
From: Jakub Jelinek @ 2011-06-07 16:55 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches
On Tue, Jun 07, 2011 at 06:48:08PM +0200, Rainer Orth wrote:
> any word on this patch? I think I only need approval for the gcc.c
I'm not a maintainer of gcc.c, and I think it is a bad idea.
PIE is just a (slightly) more secure form of an executable, therefore
if a target doesn't support position independent executables, linking
it as normal executable is IMHO just fine.
Jakub
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-07 16:55 ` Jakub Jelinek
@ 2011-06-07 16:57 ` Rainer Orth
2011-06-10 10:14 ` Rainer Orth
1 sibling, 0 replies; 14+ messages in thread
From: Rainer Orth @ 2011-06-07 16:57 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, Joseph S. Myers
Jakub Jelinek <jakub@redhat.com> writes:
> On Tue, Jun 07, 2011 at 06:48:08PM +0200, Rainer Orth wrote:
>> any word on this patch? I think I only need approval for the gcc.c
>
> I'm not a maintainer of gcc.c, and I think it is a bad idea.
> PIE is just a (slightly) more secure form of an executable, therefore
> if a target doesn't support position independent executables, linking
> it as normal executable is IMHO just fine.
I don't think so: silently ignoring a user-provided option seems like a
bad idea to me. At the very least, there should be a warning.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
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
1 sibling, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-06-10 10:14 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches, Jakub Jelinek
Jakub Jelinek <jakub@redhat.com> writes:
> On Tue, Jun 07, 2011 at 06:48:08PM +0200, Rainer Orth wrote:
>> any word on this patch? I think I only need approval for the gcc.c
>
> I'm not a maintainer of gcc.c, and I think it is a bad idea.
> PIE is just a (slightly) more secure form of an executable, therefore
> if a target doesn't support position independent executables, linking
> it as normal executable is IMHO just fine.
Joseph, as driver maintainer, what's your take on this?
http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00373.html
If the gcc.c change is unacceptable, I'll change the pie
effective-target keyword to just check for darwin9+ and linux instead.
Thanks.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-10 10:14 ` Rainer Orth
@ 2011-06-10 14:13 ` Joseph S. Myers
2011-06-10 14:45 ` Rainer Orth
0 siblings, 1 reply; 14+ messages in thread
From: Joseph S. Myers @ 2011-06-10 14:13 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches, Jakub Jelinek
On Fri, 10 Jun 2011, Rainer Orth wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
>
> > On Tue, Jun 07, 2011 at 06:48:08PM +0200, Rainer Orth wrote:
> >> any word on this patch? I think I only need approval for the gcc.c
> >
> > I'm not a maintainer of gcc.c, and I think it is a bad idea.
> > PIE is just a (slightly) more secure form of an executable, therefore
> > if a target doesn't support position independent executables, linking
> > it as normal executable is IMHO just fine.
>
> Joseph, as driver maintainer, what's your take on this?
>
> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00373.html
>
> If the gcc.c change is unacceptable, I'll change the pie
> effective-target keyword to just check for darwin9+ and linux instead.
I think we should leave gcc.c as-is here, treating -pie as a non-semantic
option.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-10 14:13 ` Joseph S. Myers
@ 2011-06-10 14:45 ` Rainer Orth
0 siblings, 0 replies; 14+ messages in thread
From: Rainer Orth @ 2011-06-10 14:45 UTC (permalink / raw)
To: Joseph S. Myers; +Cc: gcc-patches, Jakub Jelinek
"Joseph S. Myers" <joseph@codesourcery.com> writes:
> On Fri, 10 Jun 2011, Rainer Orth wrote:
>
>> Jakub Jelinek <jakub@redhat.com> writes:
>>
>> > On Tue, Jun 07, 2011 at 06:48:08PM +0200, Rainer Orth wrote:
>> >> any word on this patch? I think I only need approval for the gcc.c
>> >
>> > I'm not a maintainer of gcc.c, and I think it is a bad idea.
>> > PIE is just a (slightly) more secure form of an executable, therefore
>> > if a target doesn't support position independent executables, linking
>> > it as normal executable is IMHO just fine.
>>
>> Joseph, as driver maintainer, what's your take on this?
>>
>> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00373.html
>>
>> If the gcc.c change is unacceptable, I'll change the pie
>> effective-target keyword to just check for darwin9+ and linux instead.
>
> I think we should leave gcc.c as-is here, treating -pie as a non-semantic
> option.
Ok, I've comitted that patch as follows, after running the appropriate
runtest invocation on powerpc-apple-darwin9.8.0 and i386-pc-solaris2.10.
I've omitted adding -pie in gcc.dg/pie-link.c for now.
Rainer
2011-06-04 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc:
* 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.
Index: gcc/doc/sourcebuild.texi
===================================================================
--- gcc/doc/sourcebuild.texi (revision 174908)
+++ gcc/doc/sourcebuild.texi (working copy)
@@ -1787,6 +1787,9 @@
@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.
Index: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp (revision 174908)
+++ gcc/testsuite/lib/target-supports.exp (working copy)
@@ -788,6 +788,16 @@
return 0
}
+# Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
+
+proc check_effective_target_pie { } {
+ if { [istarget *-*-darwin\[912\]*]
+ || [istarget *-*-linux*] } {
+ return 1;
+ }
+ return 0
+}
+
# Return true if the target supports -mpaired-single (as used on MIPS).
proc check_effective_target_mpaired_single { } {
Index: gcc/testsuite/gcc.dg/pie-link.c
===================================================================
--- gcc/testsuite/gcc.dg/pie-link.c (revision 174908)
+++ gcc/testsuite/gcc.dg/pie-link.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do link { target *-*-darwin[912]* *-*-linux* } } */
+/* { dg-do link { target pie } } */
/* { dg-options "-fpie" } */
int main(void)
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-05-30 17:45 [testsuite] Run TLS torture tests with -fpic etc Rainer Orth
2011-06-03 19:38 ` Rainer Orth
@ 2011-06-10 15:11 ` Rainer Orth
2011-06-15 16:33 ` Ramana Radhakrishnan
1 sibling, 1 reply; 14+ messages in thread
From: Rainer Orth @ 2011-06-10 15:11 UTC (permalink / raw)
To: gcc-patches
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
> As suggested by Joseph, the gcc.dg/torture/tls tests should be run with
> -fpic/-fPIC and -fpie/-fPIE if supported.
>
> The patch below implements part of this. Unlike
> gcc.dg/torture/stackalign/stackalign.exp, I'm using the code below to
> add -fpic etc. to the torture options so it shows up in gcc.sum.
>
> Unfortunately, I have no idea how to properly test if -fpie/-fPIE is
> supported. Jakub, do you have a suggestion? Such a test could (and
> probably should) be used in the few tests we currently have for -fpie:
>
> gcc.dg/tls/pie-1.c, gcc.dg/pie-link.c, gcc.target/i386/pr39013-[12].c
>
> Bootstrapped without regression on i386-pc-solaris2.11.
After it has been determined how to check for PIE support, I'm checking
this in.
Rainer
2011-05-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/torture/tls/tls.exp: Load torture-options.exp.
Run tests with -fpic/-fPIC, -pie -fpie/-fPIE if supported.
diff --git a/gcc/testsuite/gcc.dg/torture/tls/tls.exp b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
--- a/gcc/testsuite/gcc.dg/torture/tls/tls.exp
+++ b/gcc/testsuite/gcc.dg/torture/tls/tls.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Free Software Foundation, Inc.
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
# Load support procs.
load_lib gcc-dg.exp
+load_lib torture-options.exp
# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
@@ -25,12 +26,32 @@ if ![info exists DEFAULT_CFLAGS] then {
set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}
+global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
+set TLS_TORTURE_OPTIONS $DG_TORTURE_OPTIONS
+if { [check_effective_target_fpic] } then {
+ foreach pic {fpic fPIC} {
+ foreach option $DG_TORTURE_OPTIONS {
+ lappend TLS_TORTURE_OPTIONS "$option -$pic"
+ }
+ }
+}
+if { [check_effective_target_pie] } then {
+ foreach pie {fpie fPIE} {
+ foreach option $DG_TORTURE_OPTIONS {
+ lappend TLS_TORTURE_OPTIONS "$option -pie -$pie"
+ }
+ }
+}
+
# Initialize `dg'.
dg-init
+torture-init
+set-torture-options $TLS_TORTURE_OPTIONS {{}} $LTO_TORTURE_OPTIONS
# Main loop.
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
$DEFAULT_CFLAGS
# All done.
+torture-finish
dg-finish
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-10 15:11 ` Rainer Orth
@ 2011-06-15 16:33 ` Ramana Radhakrishnan
2011-06-15 17:29 ` Mike Stump
0 siblings, 1 reply; 14+ messages in thread
From: Ramana Radhakrishnan @ 2011-06-15 16:33 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches
>
> After it has been determined how to check for PIE support, I'm checking
> this in.
I haven't bisected it and not investigated failures in detail because
I'm about to walk out of the door. This patch might have broken
testing with arm-linux-gnueabi cross with defaults set to v7-a. (
configured with --with-arch=armv7-a --with-fpu=neon
--with-float=-softfp) . The GNU ARM linker doesn't allow PIE modules
where objects contain the MOVW_ABS_NC and MOVT_ABS relocations (which
are actually absolute relocations) and thus we should require -fPIC /
-fpic for these cases as well.
This *gross* hack below allows testing to proceed atleast for tls.exp
as far as arm-linux-gnueabi is concerned. What's the best way of
taking this forward ?
cheers
Ramana
2011-06-15 Ramana Radhakrishnan <ramana.radhakrishnan@linaro.org>
* lib/wrapper.exp (target-support.exp): Load it.
(${tool}_maybe_build_wrapper): Add -fPIC to the options list for
testglue.
diff --git a/gcc/testsuite/lib/wrapper.exp b/gcc/testsuite/lib/wrapper.exp
index b7f7773..37c20f6 100644
--- a/gcc/testsuite/lib/wrapper.exp
+++ b/gcc/testsuite/lib/wrapper.exp
@@ -20,7 +20,7 @@
# needs it. FILENAME is the path to the wrapper file. If there are
# additional arguments, they are command-line options to provide to
# the compiler when compiling FILENAME.
-
+load_lib target-supports.exp
proc ${tool}_maybe_build_wrapper { filename args } {
global gluefile wrap_flags
@@ -30,6 +30,9 @@ proc ${tool}_maybe_build_wrapper { filename args } {
set_ld_library_path_env_vars
set saved_wrap_compile_flags [target_info wrap_compile_flags]
set flags [join $args " "]
+ if { [check_effective_target_fpic] } then {
+ lappend flags "-fPIC"
+ }
# The wrapper code may contain code that gcc objects on. This
# became true for dejagnu-1.4.4. The set of warnings and code
# that gcc objects on may change, so just make sure -w is always
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-15 16:33 ` Ramana Radhakrishnan
@ 2011-06-15 17:29 ` Mike Stump
2011-06-15 23:07 ` Ramana Radhakrishnan
0 siblings, 1 reply; 14+ messages in thread
From: Mike Stump @ 2011-06-15 17:29 UTC (permalink / raw)
To: Ramana Radhakrishnan; +Cc: Rainer Orth, gcc-patches
On Jun 15, 2011, at 9:06 AM, Ramana Radhakrishnan wrote:
>> After it has been determined how to check for PIE support, I'm checking
>> this in.
>
> I haven't bisected it and not investigated failures in detail because
> I'm about to walk out of the door. This patch might have broken
> testing with arm-linux-gnueabi cross with defaults set to v7-a. (
> configured with --with-arch=armv7-a --with-fpu=neon
> --with-float=-softfp) . The GNU ARM linker doesn't allow PIE modules
> where objects contain the MOVW_ABS_NC and MOVT_ABS relocations (which
> are actually absolute relocations) and thus we should require -fPIC /
> -fpic for these cases as well.
The patch isn't suitable as is. If -PIE requires -fPIC, then anything that adds it or tortures on it, should add both, or torture on both.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [testsuite] Run TLS torture tests with -fpic etc.
2011-06-15 17:29 ` Mike Stump
@ 2011-06-15 23:07 ` Ramana Radhakrishnan
0 siblings, 0 replies; 14+ messages in thread
From: Ramana Radhakrishnan @ 2011-06-15 23:07 UTC (permalink / raw)
To: Mike Stump; +Cc: Rainer Orth, gcc-patches
> The patch isn't suitable as is. If -PIE requires -fPIC, then anything that adds it or tortures on it, should add both, or torture on both.
The ABS relocs that I mentioned were from testglue.o which isn't built
PIE or PIC and that's the reason for the failures to show up. Maybe
the right solution is to rebuild <tool>*tg.o with anything that
tortures on PIE or PIC ?
Yes, I wasn't suggesting for a moment that this patch was suitable -
I'm seeing a high number of failures in cross-testing . It was a big
hammer 20 minutes before I left work to separate test failures from
these and the other failures that I'm seeing.
cheers
Ramana
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2011-06-15 22:07 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-30 17:45 [testsuite] Run TLS torture tests with -fpic etc 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
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
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).