This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add -static-pie to GCC driver to create static PIE
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Markus Trippelsdorf <markus at trippelsdorf dot de>
- Cc: Aaron Sawdey <acsawdey at linux dot vnet dot ibm dot com>, Joseph Myers <joseph at codesourcery dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Segher Boessenkool <segher at kernel dot crashing dot org>
- Date: Wed, 13 Sep 2017 11:12:23 +0200
- Subject: Re: [PATCH] Add -static-pie to GCC driver to create static PIE
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B53218553C
- References: <20170808221841.GA16793@gmail.com> <alpine.DEB.2.20.1708281607010.13583@digraph.polyomino.org.uk> <CAMe9rOrHPm362i+YsUhf5br6kh3UkDSs5RBX=xz4JVAmPBc4Yg@mail.gmail.com> <alpine.DEB.2.20.1709121619500.28643@digraph.polyomino.org.uk> <1505242116.20208.1.camel@linux.vnet.ibm.com> <20170913065739.GC280@x4>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Sep 13, 2017 at 08:57:39AM +0200, Markus Trippelsdorf wrote:
> On 2017.09.12 at 13:48 -0500, Aaron Sawdey wrote:
> > On Tue, 2017-09-12 at 16:20 +0000, Joseph Myers wrote:
> > > On Mon, 28 Aug 2017, H.J. Lu wrote:
> > >
> > > > Here is the updated patch. OK for trunk?
> > >
> > > OK.
> >
> > This seems to be causing an issue for me on powerpc:
> >
> > ../../trunk/gcc/config/rs6000/sysv4.h:819:0: error: "LINK_EH_SPEC" redefined [-Werror]
> > # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
>
> It will cause problems on other platforms as well:
>
> gcc/config/alpha/elf.h:171:#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
> gcc/config/alpha/vms.h:209:#define LINK_EH_SPEC "vms-dwarf2eh.o%s "
> gcc/config/dragonfly.h:64:#define LINK_EH_SPEC "--eh-frame-hdr"
> gcc/config/freebsd.h:48:#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
> gcc/config/gnu-user.h:135:#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
> gcc/config/netbsd.h:128:#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
> gcc/config/openbsd.h:139:#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
> gcc/config/powerpcspe/sysv4.h:808:# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
> gcc/config/rs6000/sysv4.h:819:# define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
> gcc/config/sol2.h:375:#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
Most of these aren't including gnu-user.h and then the other header.
It is only rs6000/sysv4.h and powerpcspe/sysv4.h where gnu-user.h is
(sometimes, which is why you can't remove it from there altogether)
included first, and alpha/elf.h where gnu-user.h is not included, yet it is
a linux target where you probably want to handle it similarly.
Although, perhaps -static-pie should be supported by other ELF targets like
Solaris, NetBSD, OpenBSD, FreeBSD and therefore the other LINK_EH_SPEC that
have !static:--eh-frame-hdr should be tweaked too.
I'd say the urgent thing is to patch rs6000/sysv4.h to match the new
gnu-user.h definition. Reorganizing headers so that for linux and hurd
it is solely gnu-user.h that defines this kind of macros is lots of work.
Jakub