diff mbox

[PING] ] gcc/config/freebsd-spec.h: Fix building PIE

Message ID alpine.LNX.2.00.1208262316300.5727@ghan.fvgr
State New
Headers show

Commit Message

Gerald Pfeifer Aug. 26, 2012, 9:28 p.m. UTC
I have tested this patch on i386-unknown-freebsd10.0 and volunteer
to create a ChangeLog and apply if approved.

Any reviewer?

On Tue, 8 May 2012, Alexis Ballier wrote:
> For the record, there's a similar logic in FreeBSD's gcc: 
> http://svnweb.freebsd.org/base/head/contrib/gcc/config/freebsd-spec.h?revision=200038&view=markup

Thanks for the patch, Alexis.  One question: why do we have the same
in freebsd-spec.h and i386/freebsd.h.  Isn't there a way to simplify
this?  Like omitting this from i386/freebsd.h at all?

Gerald

---
 gcc/config/freebsd-spec.h |    9 +++------
 gcc/config/i386/freebsd.h |    9 +++------
 2 files changed, 6 insertions(+), 12 deletions(-)

Comments

Alexis Ballier Aug. 29, 2012, 3:25 p.m. UTC | #1
Hi Gerald,

On Sun, 26 Aug 2012 23:28:49 +0200 (CEST)
Gerald Pfeifer <gerald@pfeifer.com> wrote:

> I have tested this patch on i386-unknown-freebsd10.0 and volunteer
> to create a ChangeLog and apply if approved.

Thanks for taking care of this, I thought this patch had been
completely forgotten :)
FWIW, the git commit message was supposed to be the ChangeLog entry
(imho it is rather pointless to include it in the patch since it will
most likely conflict when/if it gets applied)

> 
> Any reviewer?
> 
> On Tue, 8 May 2012, Alexis Ballier wrote:
> > For the record, there's a similar logic in FreeBSD's gcc: 
> > http://svnweb.freebsd.org/base/head/contrib/gcc/config/freebsd-spec.h?revision=200038&view=markup
> 
> Thanks for the patch, Alexis.  One question: why do we have the same
> in freebsd-spec.h and i386/freebsd.h.  Isn't there a way to simplify
> this?  Like omitting this from i386/freebsd.h at all?

To be honest, I don't know why we have the same in these two headers
and wondered the same. I suppose it is possible to simply remove it
from i386/freebsd.h but I didn't test this since I didn't want to mix a
bugfix for PIE and cleanup of the code within the same patch.

Regards,

Alexis.

[...]
diff mbox

Patch

diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h
index 770a3d1..2808582 100644
--- a/gcc/config/freebsd-spec.h
+++ b/gcc/config/freebsd-spec.h
@@ -64,11 +64,8 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 	before entering `main'.  */
    
 #define FBSD_STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-		       %{!p:%{profile:gcrt1.o%s} \
-			 %{!profile:crt1.o%s}}}} \
-   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+  "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+   crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 
 /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
    the magical crtend.o file (see crtstuff.c) which provides part of 
@@ -77,7 +74,7 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 	`crtn.o'.  */
 
 #define FBSD_ENDFILE_SPEC \
-  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as
    required by the user-land thread model.  Before __FreeBSD_version
diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h
index 649274d..dd69e43 100644
--- a/gcc/config/i386/freebsd.h
+++ b/gcc/config/i386/freebsd.h
@@ -67,11 +67,8 @@  along with GCC; see the file COPYING3.  If not see
    
 #undef	STARTFILE_SPEC
 #define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-		       %{!p:%{profile:gcrt1.o%s} \
-			 %{!profile:crt1.o%s}}}} \
-   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+  "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+   crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 
 /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
    the magical crtend.o file (see crtstuff.c) which provides part of 
@@ -81,7 +78,7 @@  along with GCC; see the file COPYING3.  If not see
 
 #undef	ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* Provide a LINK_SPEC appropriate for FreeBSD.  Here we provide support
    for the special GCC options -static and -shared, which allow us to