On Thu, Oct 9, 2014 at 3:34 PM, Cary Coutant <ccout...@google.com> wrote: >>>> If adding a new option, you need to document it in invoke.texi. >>> >>> Patch updated. >> >> Is this alright for google/gcc-4_9? > > +no-pie > +Driver RejectNegative Negative(pie) > +Create a position dependent executable > > I'd suggest adding an alias for "-no-pie" (meaning "--no-pie") -- see > earlier in common.opt where "-pie" is declared as an alias for "pie", > and similarly for "-shared".
Patch Updated. Thanks Sri > > I wonder about the spelling -- should it be "-no-pie" or "-nopie"? GCC > options seem to favor "no" options without a hyphen, but it's not very > consistent, so it's probably good the way you've spelled it -- it > better matches the way the linker option is spelled (albeit without > the "f"). > > -cary
Add a negative for option -pie: -no-pie builds a position dependent executable. Note that -no-pie also negates a prior -shared. Index: gcc.c =================================================================== --- gcc.c (revision 212826) +++ gcc.c (working copy) @@ -672,9 +672,9 @@ proper position among the other output files. */ #ifndef LINK_PIE_SPEC #ifdef HAVE_LD_PIE -#define LINK_PIE_SPEC "%{pie:-pie} " +#define LINK_PIE_SPEC "%{pie:-pie} %{no-pie:}" #else -#define LINK_PIE_SPEC "%{pie:} " +#define LINK_PIE_SPEC "%{pie:} %{no-pie:}" #endif #endif @@ -3135,6 +3135,7 @@ display_help (void) fputs (_(" -c Compile and assemble, but do not link\n"), stdout); fputs (_(" -o <file> Place the output into <file>\n"), stdout); fputs (_(" -pie Create a position independent executable\n"), stdout); + fputs (_(" -no-pie Create a position dependent executable\n"), stdout); fputs (_(" -shared Create a shared library\n"), stdout); fputs (_("\ -x <language> Specify the language of the following input files\n\ Index: common.opt =================================================================== --- common.opt (revision 212826) +++ common.opt (working copy) @@ -322,6 +322,9 @@ Common Alias(Wpedantic) -pedantic-errors Common Alias(pedantic-errors) +-no-pie +Driver Alias(no-pie) + -pie Driver Alias(pie) @@ -2841,7 +2844,7 @@ x Driver Joined Separate shared -Driver RejectNegative Negative(pie) +Driver RejectNegative Negative(no-pie) Create a shared library shared-libgcc @@ -2885,6 +2888,10 @@ Driver symbolic Driver +no-pie +Driver RejectNegative Negative(pie) +Create a position dependent executable + pie Driver RejectNegative Negative(shared) Create a position independent executable Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 212826) +++ doc/invoke.texi (working copy) @@ -462,7 +462,7 @@ Objective-C and Objective-C++ Dialects}. @item Linker Options @xref{Link Options,,Options for Linking}. @gccoptlist{@var{object-file-name} -l@var{library} @gol --nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic @gol +-nostartfiles -nodefaultlibs -no-pie -nostdlib -pie -rdynamic @gol -s -static -static-libgcc -static-libstdc++ @gol -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol -shared -shared-libgcc -symbolic @gol @@ -10574,6 +10574,11 @@ These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified. +@item -no-pie +@opindex no-pie +Produce a position dependent executable. This is the negative of option +@option{-pie} which produces a position independent executable. + @item -nostdlib @opindex nostdlib Do not use the standard system startup files or libraries when linking. Index: testsuite/gcc.dg/option_no-pie.c =================================================================== --- testsuite/gcc.dg/option_no-pie.c (revision 0) +++ testsuite/gcc.dg/option_no-pie.c (revision 0) @@ -0,0 +1,7 @@ +/* { dg-do link { target pie } } */ +/* { dg-options "-no-pie" } */ + +int main(void) +{ + return 0; +}