This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Handle "-shared -pie" and "-pie -shared" properly
- From: "H.J. Lu" <hjl at lucon dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 3 Jul 2007 15:20:56 -0700
- Subject: PATCH: Handle "-shared -pie" and "-pie -shared" properly
On Tue, Jul 03, 2007 at 12:05:56PM -0700, H.J. Lu wrote:
> On Tue, Jul 03, 2007 at 08:50:29PM +0200, Andreas Schwab wrote:
> > "H.J. Lu" <hjl@lucon.org> writes:
> >
> > > Where is it documented.
> >
> > Nowhere.
> >
> > > Gcc 4.3 just passes "-shared -pie" to linker. I don't see gcc driver
> > > remove -pie.
> >
> > Look at the use of Scrt1.o. It's much of a mess.
> >
>
> Gcc currently ignores -pie when there is a -shared due to treatment
> of Scrt1.o. However, this behavior is undocumted. We like to
> match the linker behavior with gcc.
>
> Is this gcc behavior intentional? Will this gcc behavior ever
> change? Can we document this gcc behavior?
>
> BTW, this is another problem which can be handled like:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26885
>
>
This will make sure that -shared and -pie will override each other.
Should I put them in common.opt?
H.J.
---
2007-07-03 H.J. Lu <hongjiu.lu@intel.com>
* config/linux.opt: Add shared and pie.
--- gcc/config/linux.opt.pie 2006-11-18 06:26:22.000000000 -0800
+++ gcc/config/linux.opt 2007-07-03 15:07:48.000000000 -0700
@@ -27,3 +27,11 @@ Use uClibc instead of GNU libc
mglibc
Target RejectNegative Report InverseMask(UCLIBC, GLIBC) Var(linux_uclibc) VarExists
Use GNU libc instead of uClibc
+
+shared
+Target RejectNegative Negative(pie)
+Create a shared library
+
+pie
+Target RejectNegative Negative(shared)
+Create a position independent executable