This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80044

--- Comment #1 from Alan Modra <amodra at gmail dot com> ---
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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]