diff mbox

[google/gcc-4_9] Add gcc driver option -no-pie

Message ID CAAs8Hmx_vfqP+wGm_X3uMaV9BuNcCDPd92D1+qe9V4hQmo=0TQ@mail.gmail.com
State New
Headers show

Commit Message

Sriraman Tallam Oct. 6, 2014, 11:19 p.m. UTC
On Mon, Oct 6, 2014 at 3:22 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> If adding a new option, you need to document it in invoke.texi.

Patch updated.

Thanks
Sri

>
> --
> Joseph S. Myers
> joseph@codesourcery.com
Add a negative for option -pie: -no-pie builds a position dependent executable.
Note that -no-pie also negates a prior -shared.

Comments

Sriraman Tallam Oct. 9, 2014, 9:21 p.m. UTC | #1
On Mon, Oct 6, 2014 at 4:19 PM, Sriraman Tallam <tmsriram@google.com> wrote:
> On Mon, Oct 6, 2014 at 3:22 PM, Joseph S. Myers <joseph@codesourcery.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?

Sri

>
> Thanks
> Sri
>
>>
>> --
>> Joseph S. Myers
>> joseph@codesourcery.com
Cary Coutant Oct. 9, 2014, 10:34 p.m. UTC | #2
>>> 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".

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
diff mbox

Patch

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