public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o
@ 2015-06-25 11:40 H.J. Lu
  2015-06-25 15:35 ` H.J. Lu
  2015-06-28 14:14 ` H.J. Lu
  0 siblings, 2 replies; 4+ messages in thread
From: H.J. Lu @ 2015-06-25 11:40 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Joseph Myers, Magnus Granberg, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 1703 bytes --]

On Wed, Jun 10, 2015 at 6:20 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> On Tue, May 19, 2015 at 8:33 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>>> On Tue, 19 May 2015, H.J. Lu wrote:
>>>
>>>> > I think the whole thing should be posted as one patch, with both the
>>>> > target-independent changes and the target-specific changes for all
>>>> > targets.
>>>> >
>>>>
>>>> That is what makes me concerned.  I have some simple target-specified
>>>> patches which weren't reviewed for years. What will happen if no one
>>>
>>> For any unreviewed patch, keep pinging weekly.
>>>
>>>> reviews some simple target-specified changes due to
>>>>
>>>> 1. Reviewers don't have access to those targets.
>>>> 2. Target maintainers aren't review them.
>>>> 3. There are no clear maintainers for those targets.
>>>
>>> I've already said in
>>> <https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00593.html> that, given
>>> target maintainers CC:ed, I might be inclined to approve the patch on the
>>> basis of allowing them a week to test their target changes.
>>>
>>
>> Here is the complete patch.  Tested on Linux/x86-64.  It is also
>> available on hjl/pie/master branch in git mirror.
>
> I just noticed that with --enable-default-pie, while crtbeginS.o is
> linked into the executable, crtend.o is used, while with an explicit
> -pie, crtendS.o is taken.  Shouldn't GNU_USER_TARGET_ENDFILE_SPEC have
> the same treatment as GNU_USER_TARGET_STARTFILE_SPEC already did?
>
>         * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Use
>         PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
>

Here is a patch.  OK for trunk?

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Use-PIE_SPEC-NO_PIE_SPEC-for-crtend.o-crtendS.o.patch --]
[-- Type: text/x-patch, Size: 1466 bytes --]

From 50bebf531193c18efb0982ac119694aa9f650e44 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 25 Jun 2015 03:04:56 -0700
Subject: [PATCH 1/2] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o

We need to link with crtend.o and crtendS.o properly for GCC configured
to generate PIE by default.

	* config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Use
	PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
---
 gcc/config/gnu-user.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 2fcb55d..5b3576b 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -67,11 +67,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    object constructed before entering `main', followed by a normal
    GNU userspace "finalizer" file, `crtn.o'.  */
 
+#if defined HAVE_LD_PIE
+#define GNU_USER_TARGET_ENDFILE_SPEC \
+  "%{fvtable-verify=none:%s; \
+     fvtable-verify=preinit:vtv_end_preinit.o%s; \
+     fvtable-verify=std:vtv_end.o%s} \
+   %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \
+   %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s"
+#else
 #define GNU_USER_TARGET_ENDFILE_SPEC \
   "%{fvtable-verify=none:%s; \
      fvtable-verify=preinit:vtv_end_preinit.o%s; \
      fvtable-verify=std:vtv_end.o%s} \
    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC GNU_USER_TARGET_ENDFILE_SPEC
 
-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o
  2015-06-25 11:40 [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o H.J. Lu
@ 2015-06-25 15:35 ` H.J. Lu
  2015-06-28 14:14 ` H.J. Lu
  1 sibling, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2015-06-25 15:35 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Joseph Myers, Magnus Granberg, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]

On Thu, Jun 25, 2015 at 4:37 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Jun 10, 2015 at 6:20 AM, Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>
>>> On Tue, May 19, 2015 at 8:33 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>>>> On Tue, 19 May 2015, H.J. Lu wrote:
>>>>
>>>>> > I think the whole thing should be posted as one patch, with both the
>>>>> > target-independent changes and the target-specific changes for all
>>>>> > targets.
>>>>> >
>>>>>
>>>>> That is what makes me concerned.  I have some simple target-specified
>>>>> patches which weren't reviewed for years. What will happen if no one
>>>>
>>>> For any unreviewed patch, keep pinging weekly.
>>>>
>>>>> reviews some simple target-specified changes due to
>>>>>
>>>>> 1. Reviewers don't have access to those targets.
>>>>> 2. Target maintainers aren't review them.
>>>>> 3. There are no clear maintainers for those targets.
>>>>
>>>> I've already said in
>>>> <https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00593.html> that, given
>>>> target maintainers CC:ed, I might be inclined to approve the patch on the
>>>> basis of allowing them a week to test their target changes.
>>>>
>>>
>>> Here is the complete patch.  Tested on Linux/x86-64.  It is also
>>> available on hjl/pie/master branch in git mirror.
>>
>> I just noticed that with --enable-default-pie, while crtbeginS.o is
>> linked into the executable, crtend.o is used, while with an explicit
>> -pie, crtendS.o is taken.  Shouldn't GNU_USER_TARGET_ENDFILE_SPEC have
>> the same treatment as GNU_USER_TARGET_STARTFILE_SPEC already did?
>>
>>         * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Use
>>         PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
>>
>
> Here is a patch.  OK for trunk?
>

This patch requires:

https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01782.html

since "pie" may not be used in any SPECs.  Here is the updated
combined patch.  OK to install?

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Use-PIE_SPEC-NO_PIE_SPEC-for-crtend.o-crtendS.o.patch --]
[-- Type: text/x-patch, Size: 2177 bytes --]

From 130ebd65884ae2ca4507ed6c689206d46a568e9f Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Thu, 25 Jun 2015 03:04:56 -0700
Subject: [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o

We need to link with crtend.o and crtendS.o properly for GCC configured
to generate PIE by default.  When PIE is enabled by default, -pie is
treated as nop in driver.  We should simply validate it, instead of issue
an error, since "pie" may not be used in any SPECs.

	* gcc.c (driver_handle_option): Validate -pie if PIE is enabled
	by default.
	* config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Use
	PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
---
 gcc/config/gnu-user.h | 9 +++++++++
 gcc/gcc.c             | 5 +++++
 2 files changed, 14 insertions(+)

diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 2fcb55d..5b3576b 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -67,11 +67,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    object constructed before entering `main', followed by a normal
    GNU userspace "finalizer" file, `crtn.o'.  */
 
+#if defined HAVE_LD_PIE
+#define GNU_USER_TARGET_ENDFILE_SPEC \
+  "%{fvtable-verify=none:%s; \
+     fvtable-verify=preinit:vtv_end_preinit.o%s; \
+     fvtable-verify=std:vtv_end.o%s} \
+   %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \
+   %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s"
+#else
 #define GNU_USER_TARGET_ENDFILE_SPEC \
   "%{fvtable-verify=none:%s; \
      fvtable-verify=preinit:vtv_end_preinit.o%s; \
      fvtable-verify=std:vtv_end.o%s} \
    %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
+#endif
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC GNU_USER_TARGET_ENDFILE_SPEC
 
diff --git a/gcc/gcc.c b/gcc/gcc.c
index d77c6c5..0f29b78 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3893,6 +3893,11 @@ driver_handle_option (struct gcc_options *opts,
       save_switch ("-o", 1, &arg, validated, true);
       return true;
 
+#ifdef ENABLE_DEFAULT_PIE
+    case OPT_pie:
+      /* -pie is turned on by default.  */
+#endif
+
     case OPT_static_libgcc:
     case OPT_shared_libgcc:
     case OPT_static_libgfortran:
-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o
  2015-06-25 11:40 [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o H.J. Lu
  2015-06-25 15:35 ` H.J. Lu
@ 2015-06-28 14:14 ` H.J. Lu
  2015-06-29 20:57   ` Joseph Myers
  1 sibling, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2015-06-28 14:14 UTC (permalink / raw)
  To: Rainer Orth, Joseph Myers, Magnus Granberg, GCC Patches

On Thu, Jun 25, 2015 at 04:37:29AM -0700, H.J. Lu wrote:
> On Wed, Jun 10, 2015 at 6:20 AM, Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
> > "H.J. Lu" <hjl.tools@gmail.com> writes:
> >
> >> On Tue, May 19, 2015 at 8:33 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> >>> On Tue, 19 May 2015, H.J. Lu wrote:
> >>>
> >>>> > I think the whole thing should be posted as one patch, with both the
> >>>> > target-independent changes and the target-specific changes for all
> >>>> > targets.
> >>>> >
> >>>>
> >>>> That is what makes me concerned.  I have some simple target-specified
> >>>> patches which weren't reviewed for years. What will happen if no one
> >>>
> >>> For any unreviewed patch, keep pinging weekly.
> >>>
> >>>> reviews some simple target-specified changes due to
> >>>>
> >>>> 1. Reviewers don't have access to those targets.
> >>>> 2. Target maintainers aren't review them.
> >>>> 3. There are no clear maintainers for those targets.
> >>>
> >>> I've already said in
> >>> <https://gcc.gnu.org/ml/gcc-patches/2015-05/msg00593.html> that, given
> >>> target maintainers CC:ed, I might be inclined to approve the patch on the
> >>> basis of allowing them a week to test their target changes.
> >>>
> >>
> >> Here is the complete patch.  Tested on Linux/x86-64.  It is also
> >> available on hjl/pie/master branch in git mirror.
> >
> > I just noticed that with --enable-default-pie, while crtbeginS.o is
> > linked into the executable, crtend.o is used, while with an explicit
> > -pie, crtendS.o is taken.  Shouldn't GNU_USER_TARGET_ENDFILE_SPEC have
> > the same treatment as GNU_USER_TARGET_STARTFILE_SPEC already did?
> >
> >         * config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Use
> >         PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
> >
> 
> Here is a patch.  OK for trunk?
> 
> Thanks.

I'd like to check in this patch.  Any comments, objections?

Thanks.

H.J.
> From 50bebf531193c18efb0982ac119694aa9f650e44 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Thu, 25 Jun 2015 03:04:56 -0700
> Subject: [PATCH 1/2] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o
> 
> We need to link with crtend.o and crtendS.o properly for GCC configured
> to generate PIE by default.
> 
> 	* config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Use
> 	PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.
> ---
>  gcc/config/gnu-user.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
> index 2fcb55d..5b3576b 100644
> --- a/gcc/config/gnu-user.h
> +++ b/gcc/config/gnu-user.h
> @@ -67,11 +67,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>     object constructed before entering `main', followed by a normal
>     GNU userspace "finalizer" file, `crtn.o'.  */
>  
> +#if defined HAVE_LD_PIE
> +#define GNU_USER_TARGET_ENDFILE_SPEC \
> +  "%{fvtable-verify=none:%s; \
> +     fvtable-verify=preinit:vtv_end_preinit.o%s; \
> +     fvtable-verify=std:vtv_end.o%s} \
> +   %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \
> +   %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s"
> +#else
>  #define GNU_USER_TARGET_ENDFILE_SPEC \
>    "%{fvtable-verify=none:%s; \
>       fvtable-verify=preinit:vtv_end_preinit.o%s; \
>       fvtable-verify=std:vtv_end.o%s} \
>     %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
> +#endif
>  #undef  ENDFILE_SPEC
>  #define ENDFILE_SPEC GNU_USER_TARGET_ENDFILE_SPEC
>  
> -- 
> 2.1.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o
  2015-06-28 14:14 ` H.J. Lu
@ 2015-06-29 20:57   ` Joseph Myers
  0 siblings, 0 replies; 4+ messages in thread
From: Joseph Myers @ 2015-06-29 20:57 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Rainer Orth, Magnus Granberg, GCC Patches

On Sun, 28 Jun 2015, H.J. Lu wrote:

> > Here is a patch.  OK for trunk?
> > 
> > Thanks.
> 
> I'd like to check in this patch.  Any comments, objections?
> 
> Thanks.
> 
> H.J.
> > From 50bebf531193c18efb0982ac119694aa9f650e44 Mon Sep 17 00:00:00 2001
> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > Date: Thu, 25 Jun 2015 03:04:56 -0700
> > Subject: [PATCH 1/2] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o
> > 
> > We need to link with crtend.o and crtendS.o properly for GCC configured
> > to generate PIE by default.
> > 
> > 	* config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Use
> > 	PIE_SPEC and NO_PIE_SPEC if HAVE_LD_PIE is defined.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-29 20:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 11:40 [PATCH] Use PIE_SPEC/NO_PIE_SPEC for crtend.o/crtendS.o H.J. Lu
2015-06-25 15:35 ` H.J. Lu
2015-06-28 14:14 ` H.J. Lu
2015-06-29 20:57   ` Joseph Myers

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).