On Mon, Oct 6, 2014 at 3:22 PM, Joseph S. Myers <jos...@codesourcery.com> wrote:
> If adding a new option, you need to document it in invoke.texi.

Patch updated.

Thanks
Sri

>
> --
> Joseph S. Myers
> jos...@codesourcery.com
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: 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;
+}
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: common.opt
===================================================================
--- common.opt  (revision 212826)
+++ common.opt  (working copy)
@@ -2841,7 +2841,7 @@ x
 Driver Joined Separate
 
 shared
-Driver RejectNegative Negative(pie)
+Driver RejectNegative Negative(no-pie)
 Create a shared library
 
 shared-libgcc
@@ -2885,6 +2885,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

Reply via email to