This is the mail archive of the 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]

Add __pie__ and __PIE__ cpp macros

Thanks to Kaveh's patch, we now consistently implement the equivalent of:

  %{fpic:-D__pic__=1 -D__PIC__=1}
  %{fPIC:-D__pic__=2 -D__PIC__=2}

This patch does the same for:

  %{fpie:-D__pie__=1 -D__PIE__=1}
  %{fPIE:-D__pie__=2 -D__PIE__=2}

I'll use it in a follow-up testsuite patch.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also regression-tested
on i586-wrs-vxworks.  OK to install?


	* doc/invoke.texi (-fpie, -fPIE): Document __pie__ and __PIE__.
	* c-cppbuiltin.c (c_cpp_builtins): Define them.

Index: gcc/doc/invoke.texi
--- gcc/doc/invoke.texi	(revision 123084)
+++ gcc/doc/invoke.texi	(working copy)
@@ -14210,6 +14210,10 @@ generated position independent code can 
 Usually these options are used when @option{-pie} GCC option will be
 used during linking.
+@option{-fpie} and @option{-fPIE} both define the macros
+@code{__pie__} and @code{__PIE__}.  The macros have the value 1
+for @option{-fpie} and 2 for @option{-fPIE}.
 @item -fno-jump-tables
 @opindex fno-jump-tables
 Do not use jump tables for switch statements even where it would be
Index: gcc/c-cppbuiltin.c
--- gcc/c-cppbuiltin.c	(revision 123084)
+++ gcc/c-cppbuiltin.c	(working copy)
@@ -532,6 +532,11 @@ c_cpp_builtins (cpp_reader *pfile)
       builtin_define_with_int_value ("__pic__", flag_pic);
       builtin_define_with_int_value ("__PIC__", flag_pic);
+  if (flag_pie)
+    {
+      builtin_define_with_int_value ("__pie__", flag_pie);
+      builtin_define_with_int_value ("__PIE__", flag_pie);
+    }
   if (flag_iso)
     cpp_define (pfile, "__STRICT_ANSI__");

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