tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Fwd: Re: [PATCH] Add -static-pie to GCC driver to create static PIE



There was a discussion about static PIE on NetBSD.

I'm forwarding a current thread from GCC.


-------- Forwarded Message --------
Subject: Re: [PATCH] Add -static-pie to GCC driver to create static PIE
Date: Wed, 13 Sep 2017 11:12:23 +0200
From: Jakub Jelinek <jakub%redhat.com@localhost>
Reply-To: Jakub Jelinek <jakub%redhat.com@localhost>
To: Markus Trippelsdorf <markus%trippelsdorf.de@localhost>
CC: Aaron Sawdey <acsawdey%linux.vnet.ibm.com@localhost>, Joseph Myers
<joseph%codesourcery.com@localhost>, H.J. Lu <hjl.tools%gmail.com@localhost>, GCC Patches
<gcc-patches%gcc.gnu.org@localhost>, Segher Boessenkool <segher%kernel.crashing.org@localhost>

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

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index