[Bug driver/80044] Specifying both -static and -pie insanity

2017-08-08 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80044
Bug 80044 depends on bug 81523, which changed state.

Bug 81523 Summary: -static -pie behaves differently depending on if 
--enable-default-pie is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81523

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

[Bug driver/80044] Specifying both -static and -pie insanity

2017-03-16 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80044

--- Comment #3 from Andrew Pinski  ---
see PR 7516

[Bug driver/80044] Specifying both -static and -pie insanity

2017-03-16 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80044

Alan Modra  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #2 from Alan Modra  ---
I think I'm wasting everybody's time with this issue.

[Bug driver/80044] Specifying both -static and -pie insanity

2017-03-16 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80044

--- Comment #1 from Alan Modra  ---
Revising my original comments..

According to the gcc docs -static is supposed to just prevent linking with
dynamic libraries.  I agree that this is traditional linker behaviour.

That means, for example, that -shared -static ought to create a shared library
but any libraries linked should be static libraries.  Presumably those
libraries would have been compiled PIC.

Similarly, -pie -static ought to create a PIE but any libraries linked should
be static libraries, presumably also compiled as PIC.  Of course on most Linux
systems static libraries are not PIC so aren't suitable for use in a PIE. 
However, there isn't really a fundamental reason the option combination should
not be allowed.

It is true that -pie -static chooses wrong startup files, and doesn't pass a
-dynamic-linker option to ld.  That is a bug.

Also, an explicit -pie -static when gcc is configured for --enable-default-pie
ought to behave the same as -pie -static when PIEs are not default.  ie. gcc
should produce a PIE, not a static executable in that case.