]> gcc.gnu.org Git - gcc.git/commitdiff
configure.in (HAVE_LD_PIE): Check for ld -pie.
authorJakub Jelinek <jakub@redhat.com>
Tue, 3 Jun 2003 09:06:55 +0000 (11:06 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 3 Jun 2003 09:06:55 +0000 (11:06 +0200)
* configure.in (HAVE_LD_PIE): Check for ld -pie.
* config.in: Rebuilt.
* configure: Rebuilt.
* toplev.c (flag_pie, flag_shlib): New variables.
(f_options): Add -fpie and -fPIE.
(parse_options_and_default_flags): Set flag_pic if -fpie/-fPIE.
Set flag_shlib if flag_pic and not -fpie/-fPIE.
* flags.h (flag_pic, flag_shlib): Add.
* varasm.c (default_binds_local_p): Use flag_shlib instead of
flag_pic.
* gcc.c (LINK_PIE_SPEC): Define.
(LINK_COMMAND_SPEC): Use LINK_PIE_SPEC.
(option_map): Add --pie -> -pie mapping.
* config/sol2.h (ASM_SPEC): Handle -fpie the same way as -fpic
and -fPIE the same way as -fPIC.
* config/openbsd.h (ASM_SPEC): Likewise.
* config/frv/frv.h (ASM_SPEC): Likewise.
* config/arm/linux-gas.h (SUBTARGET_CPP_SPEC): Likewise.
* config/arm/semi.h (ASM_SPEC): Likewise.
* config/arm/netbsd-elf.h (SUBTARGET_EXTRA_ASM_SPEC): Likewise.
* config/freebsd-spec.h (FBSD_CPP_SPEC): Likewise.
* config/i386/beos-elf.h (CC1_SPEC): Likewise.
* config/i386/freebsd-aout.h (ASM_SPEC): Likewise.
* config/m68k/linux.h (CPP_SPEC): Likewise.
* config/m68k/netbsd.h (ASM_SPEC): Likewise.
* config/m68k/openbsd.h (ASM_SPEC): Likewise.
* config/m68k/netbsd-elf.h (ASM_SPEC): Likewise.
* config/mips/linux.h (SUBTARGET_CPP_SPEC): Likewise.
* config/mips/openbsd.h (SUBTARGET_ASM_SPEC): Likewise.
* config/pa/pa-linux.h (CPP_SPEC): Likewise.
* config/netbsd-aout.h (ASM_SPEC): Likewise.
* config/rs6000/sysv4.h (ASM_SPEC, CPP_SYSV_SPEC): Likewise.
* config/rs6000/vxworks.h (CPP_SPEC): Likewise.
* config/sparc/linux.h (CPP_SUBTARGET_SPEC, ASM_SPEC): Likewise.
* config/sparc/linux64.h (CPP_SUBTARGET_SPEC, ASM_SPEC): Likewise.
* config/sparc/sparc.h (ASM_SPEC): Likewise.
* config/sparc/sp64-elf.h (ASM_SPEC): Likewise.
* config/sparc/sysv4.h (ASM_SPEC): Likewise.
* config/sparc/netbsd-elf.h (ASM_SPEC): Likewise.
* config/sparc/openbsd64.h (ASM_SPEC): Likewise.
* config/cris/linux.h (CRIS_ASM_SUBTARGET_SPEC): Likewise.
* config/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Handle -pie.
Simplify.
* config/alpha/elf.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* config/i386/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* config/ia64/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* config/rs6000/sysv4.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* config/rs6000/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* config/sparc/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* config/sparc/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
* doc/invoke.texi: Document -pie, -fpie and -fPIE options.

From-SVN: r67359

41 files changed:
gcc/ChangeLog
gcc/config.in
gcc/config/alpha/elf.h
gcc/config/arm/linux-gas.h
gcc/config/arm/netbsd-elf.h
gcc/config/arm/semi.h
gcc/config/cris/linux.h
gcc/config/freebsd-spec.h
gcc/config/frv/frv.h
gcc/config/i386/beos-elf.h
gcc/config/i386/freebsd-aout.h
gcc/config/i386/linux64.h
gcc/config/ia64/linux.h
gcc/config/linux.h
gcc/config/m68k/linux.h
gcc/config/m68k/netbsd-elf.h
gcc/config/m68k/netbsd.h
gcc/config/m68k/openbsd.h
gcc/config/mips/linux.h
gcc/config/mips/openbsd.h
gcc/config/netbsd-aout.h
gcc/config/openbsd.h
gcc/config/pa/pa-linux.h
gcc/config/rs6000/linux64.h
gcc/config/rs6000/sysv4.h
gcc/config/rs6000/vxworks.h
gcc/config/sol2.h
gcc/config/sparc/linux.h
gcc/config/sparc/linux64.h
gcc/config/sparc/netbsd-elf.h
gcc/config/sparc/openbsd64.h
gcc/config/sparc/sp64-elf.h
gcc/config/sparc/sparc.h
gcc/config/sparc/sysv4.h
gcc/configure
gcc/configure.in
gcc/doc/invoke.texi
gcc/flags.h
gcc/gcc.c
gcc/toplev.c
gcc/varasm.c

index b628ed0649fd504f97e735dd076ac9291eed8f03..30b502ddb3a3f61e6839577c115e37940670c229 100644 (file)
@@ -1,3 +1,57 @@
+2003-06-03  Jakub Jelinek  <jakub@redhat.com>
+
+       * configure.in (HAVE_LD_PIE): Check for ld -pie.
+       * config.in: Rebuilt.
+       * configure: Rebuilt.
+       * toplev.c (flag_pie, flag_shlib): New variables.
+       (f_options): Add -fpie and -fPIE.
+       (parse_options_and_default_flags): Set flag_pic if -fpie/-fPIE.
+       Set flag_shlib if flag_pic and not -fpie/-fPIE.
+       * flags.h (flag_pic, flag_shlib): Add.
+       * varasm.c (default_binds_local_p): Use flag_shlib instead of
+       flag_pic.
+       * gcc.c (LINK_PIE_SPEC): Define.
+       (LINK_COMMAND_SPEC): Use LINK_PIE_SPEC.
+       (option_map): Add --pie -> -pie mapping.
+       * config/sol2.h (ASM_SPEC): Handle -fpie the same way as -fpic
+       and -fPIE the same way as -fPIC.
+       * config/openbsd.h (ASM_SPEC): Likewise.
+       * config/frv/frv.h (ASM_SPEC): Likewise.
+       * config/arm/linux-gas.h (SUBTARGET_CPP_SPEC): Likewise.
+       * config/arm/semi.h (ASM_SPEC): Likewise.
+       * config/arm/netbsd-elf.h (SUBTARGET_EXTRA_ASM_SPEC): Likewise.
+       * config/freebsd-spec.h (FBSD_CPP_SPEC): Likewise.
+       * config/i386/beos-elf.h (CC1_SPEC): Likewise.
+       * config/i386/freebsd-aout.h (ASM_SPEC): Likewise.
+       * config/m68k/linux.h (CPP_SPEC): Likewise.
+       * config/m68k/netbsd.h (ASM_SPEC): Likewise.
+       * config/m68k/openbsd.h (ASM_SPEC): Likewise.
+       * config/m68k/netbsd-elf.h (ASM_SPEC): Likewise.
+       * config/mips/linux.h (SUBTARGET_CPP_SPEC): Likewise.
+       * config/mips/openbsd.h (SUBTARGET_ASM_SPEC): Likewise.
+       * config/pa/pa-linux.h (CPP_SPEC): Likewise.
+       * config/netbsd-aout.h (ASM_SPEC): Likewise.
+       * config/rs6000/sysv4.h (ASM_SPEC, CPP_SYSV_SPEC): Likewise.
+       * config/rs6000/vxworks.h (CPP_SPEC): Likewise.
+       * config/sparc/linux.h (CPP_SUBTARGET_SPEC, ASM_SPEC): Likewise.
+       * config/sparc/linux64.h (CPP_SUBTARGET_SPEC, ASM_SPEC): Likewise.
+       * config/sparc/sparc.h (ASM_SPEC): Likewise.
+       * config/sparc/sp64-elf.h (ASM_SPEC): Likewise.
+       * config/sparc/sysv4.h (ASM_SPEC): Likewise.
+       * config/sparc/netbsd-elf.h (ASM_SPEC): Likewise.
+       * config/sparc/openbsd64.h (ASM_SPEC): Likewise.
+       * config/cris/linux.h (CRIS_ASM_SUBTARGET_SPEC): Likewise.
+       * config/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Handle -pie.
+       Simplify.
+       * config/alpha/elf.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * config/i386/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * config/ia64/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * config/rs6000/sysv4.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * config/rs6000/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * config/sparc/linux.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * config/sparc/linux64.h (STARTFILE_SPEC, ENDFILE_SPEC): Likewise.
+       * doc/invoke.texi: Document -pie, -fpie and -fPIE options.
+
 2003-06-03  Jakub Jelinek  <jakub@redhat.com>
 
        * builtins.c (expand_builtin_memcpy): Remove endp argument and endp
index ccaad9ee7b09d0787a94a45611345e17ab44379a..dca4a1bd656329b59b2d1275a7f16484ddb78c64 100644 (file)
 /* Define if your linker supports --eh-frame-hdr option. */
 #undef HAVE_LD_EH_FRAME_HDR
 
+/* Define if your linker supports -pie option. */
+#undef HAVE_LD_PIE
+
 /* Define if your MIPS libgloss linker scripts consistently include STARTUP directives. */
 #undef HAVE_MIPS_LIBGLOSS_STARTUP_DIRECTIVES
 
index 3ca8d6c7478d7a9cfb36b0784bc53d1e7863785b..abdb92af5014ada81072641ff8cda6d2480d8895 100644 (file)
@@ -413,11 +413,15 @@ void FN ()                                        \
    before entering `main'.   */
 
 #undef STARTFILE_SPEC
+#ifdef HAVE_LD_PIE
 #define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
-   crti.o%s %{static:crtbeginT.o%s}\
-   %{!static:%{shared:crtbeginS.o%s}%{!shared:crtbegin.o%s}}"
+  "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#else
+#define STARTFILE_SPEC \
+  "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#endif
 
 /* Provide a ENDFILE_SPEC appropriate for ELF.  Here we tack on the
    magical crtend.o file which provides part of the support for
@@ -427,7 +431,7 @@ void FN ()                                  \
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
-   %{shared:crtendS.o%s}%{!shared:crtend.o%s} crtn.o%s"
+   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* We support #pragma.  */
 #define HANDLE_SYSV_PRAGMA 1
index 37d788aeb9a60d4d0541386a2e97bb59ccf39341..f3ed5f8867002edd9ce93a3b4a8935720c87bb76 100644 (file)
@@ -31,7 +31,7 @@
 #define DEFAULT_SIGNED_CHAR 0
 
 #undef  SUBTARGET_CPP_SPEC
-#define SUBTARGET_CPP_SPEC  "%{posix:-D_POSIX_SOURCE} %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}"
+#define SUBTARGET_CPP_SPEC  "%{posix:-D_POSIX_SOURCE} %{fPIC|fPIE:-D__PIC__ -D__pic__} %{fpic|fpie:-D__PIC__ -D__pic__}"
 
 #undef  SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
index 1e4c9301fca1c41899521a41fa0c3143e90e2ad0..91ba9cd445c1758994acbd96b40e36a3e47c5646 100644 (file)
@@ -59,7 +59,7 @@
 
 #undef SUBTARGET_EXTRA_ASM_SPEC
 #define SUBTARGET_EXTRA_ASM_SPEC       \
-  "-matpcs %{fpic:-k} %{fPIC:-k}"
+  "-matpcs %{fpic|fpie:-k} %{fPIC|fPIE:-k}"
 
 /* Default floating point model is soft-VFP.
    FIXME: -mhard-float currently implies FPA.  */
index a7addee574ee1030293ee8470c89bf40c73e033e..8847f8c2369dbbc016adae98c24eb837513353ac 100644 (file)
@@ -59,7 +59,7 @@
    binutils can't.  */
 #ifndef ASM_SPEC
 #define ASM_SPEC "\
-%{fpic: -k} %{fPIC: -k} \
+%{fpic|fpie: -k} %{fPIC|fPIE: -k} \
 %{mbig-endian:-EB} \
 %{mcpu=*:-mcpu=%*} \
 %{march=*:-march=%*} \
index 6893d7f39b16e0bbc16aace11da83e5b2b72341d..288c2856ee636c4d1a8ffab0eb2074e42dc834dc 100644 (file)
@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA.  */
 #define CRIS_ASM_SUBTARGET_SPEC \
  "--em=criself\
   %{!fleading-underscore:--no-underscore}\
-  %{fPIC|fpic: --pic}"
+  %{fPIC|fpic|fPIE|fpie: --pic}"
 
 /* Provide a legacy -mlinux option.  */
 #undef CRIS_SUBTARGET_SWITCHES
index b71a2024d3380f39651386d30dd42a7e89fbcc56..2f4261b6abad18fa029a85c4c2df2f128bc01a3f 100644 (file)
@@ -78,7 +78,7 @@ Boston, MA 02111-1307, USA.  */
 
 #define FBSD_CPP_SPEC "                                                        \
   %(cpp_cpu)                                                           \
-  %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__}              \
+  %{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__}                           \
   %{posix:-D_POSIX_SOURCE}"
 
 /* Provide a STARTFILE_SPEC appropriate for FreeBSD.  Here we add
index f7d46c0ab80e29456ea845eb00a27086f1f851b4..4adcabae8284372b9fba0e410fbc590797f6a0f4 100644 (file)
@@ -86,7 +86,7 @@
     %{mmedia} %{mno-media} \
     %{mmuladd} %{mno-muladd} \
     %{mpack} %{mno-pack} \
-    %{fpic: -mpic} %{fPIC: -mPIC} %{mlibrary-pic}}"
+    %{fpic|fpie: -mpic} %{fPIC|fPIE: -mPIC} %{mlibrary-pic}}"
 
 /* Another C string constant used much like `LINK_SPEC'.  The difference
    between the two is that `STARTFILE_SPEC' is used at the very beginning of
index d36975606c672972ee9951e3d2f75c4e3d2b235f..075e16aefd5ec536d4697aa5f6ba006b4b7d502e 100644 (file)
@@ -78,7 +78,7 @@ Boston, MA 02111-1307, USA.  */
    CC1_SPEC is used for both cc1 and cc1plus.  */
 
 #undef CC1_SPEC
-#define CC1_SPEC "%{!no-fpic:%{!fPIC:-fpic}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}"
+#define CC1_SPEC "%{!no-fpic:%{!fno-pic:%{!fno-pie:%{!fpie:%{!fPIC:%{!fPIE:-fpic}}}}}} %{!Wmultichar: -Wno-multichar} %(cc1_cpu) %{profile:-p}"
 
 #undef CC1PLUS_SPEC
 #define CC1PLUS_SPEC "%{!Wctor-dtor-privacy:-Wno-ctor-dtor-privacy}"
index 48fea7fb64c1b6f8dec0f1a6cc81c29fc71a5d4d..da3202da451a0ae70ca9d6f0a3a6c965fd3fb698 100644 (file)
@@ -210,7 +210,7 @@ do {                                                                    \
   } while (0)
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
-#define ASM_SPEC   "%{fpic:-k} %{fPIC:-k}"
+#define ASM_SPEC   "%{fpic|fpie|fPIC|fPIE:-k}"
 #define LINK_SPEC \
   "%{p:%e`-p' not supported; use `-pg' and gprof(1)} \
    %{shared:-Bshareable} \
index 591e10df34b4ec455826d22db8e468014ab475b1..575cbee10cce4528c781fbdb04ce1b6da3965f24 100644 (file)
@@ -65,17 +65,6 @@ Boston, MA 02111-1307, USA.  */
       %{!m32:%{!dynamic-linker:-dynamic-linker /lib64/ld-linux-x86-64.so.2}}} \
     %{static:-static}}"
 
-#undef  STARTFILE_SPEC
-#define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-     %{!p:%{profile:gcrt1.o%s} %{!profile:crt1.o%s}}}} \
-   crti.o%s %{static:crtbeginT.o%s} \
-   %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
-
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
-
 #define MULTILIB_DEFAULTS { "m64" }
 
 /* Do code reading to identify a signal frame, and set the frame
index e1d60f7d8c48731db4bf0ade5f6364648a6436d6..c24c70c8d5a435f5ecbf6de5389507d2ea25983c 100644 (file)
@@ -21,18 +21,21 @@ do {                                                \
 
 /* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in.  */
 #undef STARTFILE_SPEC
+#ifdef HAVE_LD_PIE
 #define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-                      %{!p:%{profile:gcrt1.o%s} \
-                        %{!profile:crt1.o%s}}}} \
-   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+  "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#else
+#define STARTFILE_SPEC \
+  "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#endif
 
 /* Similar to standard Linux, but adding -ffast-math support.  */
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
-   %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* Define this for shared library support because it isn't in the main
    linux.h file.  */
index 13f5b627dcacf1d26197bf1ba32d0830ee08ac56..ea322b36d8554bf81e037f0870f45c7df015bc07 100644 (file)
@@ -53,14 +53,14 @@ Boston, MA 02111-1307, USA.  */
                       %{!p:%{profile:gcrt1.o%s} \
                         %{!profile:crt1.o%s}}}} \
    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+#elif defined HAVE_LD_PIE
+#define STARTFILE_SPEC \
+  "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #else
 #define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
-                      %{!p:%{profile:gcrt1.o%s} \
-                        %{!profile:crt1.o%s}}}} \
-   crti.o%s %{static:crtbeginT.o%s}\
-   %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
+  "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #endif
 
 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
@@ -71,7 +71,7 @@ Boston, MA 02111-1307, USA.  */
 
 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
-  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* This is for -profile to use -lc_p instead of -lc.  */
 #ifndef CC1_SPEC
index 5b8bbd248862e4ad6e09c62bb59002e610b1fcda..9e81a0a810964b2886a2e92ae4e92219076ed7cf 100644 (file)
@@ -121,10 +121,10 @@ Boston, MA 02111-1307, USA.  */
 #undef CPP_SPEC
 #if TARGET_DEFAULT & MASK_68881
 #define CPP_SPEC \
-  "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+  "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
 #else
 #define CPP_SPEC \
-  "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
+  "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
 #endif
 
 /* We override the ASM_SPEC from svr4.h because we must pass -m68040 down
index 2d24d4a602ebb1d7ca2a7b4b5b6f3af4ab267e8e..0787c6accd642114007ec3acce6d3bbbc992417e 100644 (file)
@@ -105,7 +105,7 @@ Boston, MA 02111-1307, USA.  */
 #define ASM_SPEC \
   "%(asm_default_spec) \
     %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \
-    %{fpic:-k} %{fPIC:-k -K}"
+    %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
index 69a88afe0d59bd794f272d9eff57b16bf1a671fe..382adc0fa17df742e40985f7c909133fffc6d417 100644 (file)
@@ -31,7 +31,7 @@
   "%{!msoft-float:-D__HAVE_68881__ -D__HAVE_FPU__} %(netbsd_cpp_spec)"
 
 #undef ASM_SPEC
-#define ASM_SPEC "%{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{m68030} %{m68040} %{m68060} %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
index be185dbdc86540993a88a59b352b0b840e90547f..48e9eb91e1d1f3dbe01f2f7eced8a43a9d201ca8 100644 (file)
@@ -46,7 +46,7 @@ Boston, MA 02111-1307, USA.  */
 
 /* m68k as needs to know about the processor subtype.  */
 #undef ASM_SPEC
-#define ASM_SPEC "%{m68030} %{m68040} %{m68060} %{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{m68030} %{m68040} %{m68060} %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
index 8f81bc4497a61e03e90752a3f295de678977608b..9986fa312f8914c3ca4fc65a38a7c1b02ab19506 100644 (file)
@@ -163,7 +163,7 @@ void FN ()                                                  \
 #undef  SUBTARGET_CPP_SPEC
 #define SUBTARGET_CPP_SPEC "\
 %{fno-PIC:-U__PIC__ -U__pic__} %{fno-pic:-U__PIC__ -U__pic__} \
-%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} \
+%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} \
 %{pthread:-D_REENTRANT}"
 
 /* From iris5.h */
index 73a81926be4879801b00c8136aaabb7ecfdbdc77..8b1c124cf8e5082671ea6427a455aa28e5534f74 100644 (file)
@@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA.  */
 /* Definitions needed for OpenBSD, to avoid picking mips 'defaults'.  */
 
 /* GAS must know this.  */
-#define SUBTARGET_ASM_SPEC "%{fPIC:-KPIC}"
+#define SUBTARGET_ASM_SPEC "%{fPIC|fPIE:-KPIC}"
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
index f7eb1bf14495dae679ebf351ce736da9acd1a2be..f77fc2e2d9b9608c02ea0c97c119aba35e0fbdf7 100644 (file)
@@ -39,7 +39,7 @@ Boston, MA 02111-1307, USA.  */
    with the options for generating PIC code.  */
 
 #undef ASM_SPEC
-#define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
index 7eeb8fef06f1a8cfd21c70c2f5849fed8cc582fc..00f645dd9800718fb24a7e7913f80dcc75b301c8 100644 (file)
@@ -106,7 +106,7 @@ Boston, MA 02111-1307, USA.  */
    still uses a special flavor of gas that needs to be told when generating 
    pic code.  */
 #undef ASM_SPEC
-#define ASM_SPEC "%{fpic:-k} %{fPIC:-k -K}"
+#define ASM_SPEC "%{fpic|fpie:-k} %{fPIC|fPIE:-k -K}"
 #endif
 
 /* Since we use gas, stdin -> - is a good idea.  */
index 1c8266af57aec7f9a383c7efd497a5b0e3ea6c53..fa20da08ed52532eb90437e0fbdb7435a1654602 100644 (file)
@@ -66,7 +66,7 @@ Boston, MA 02111-1307, USA.  */
   while (0)
 
 #undef CPP_SPEC
-#define CPP_SPEC "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
+#define CPP_SPEC "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
 
 #undef LIB_SPEC
 #define LIB_SPEC \
index bd3a6a85b1802c119048e3572bf2f593a4886059..5a31366dbf2b51f340a5f86c49b4cbfcbcb2520a 100644 (file)
 #endif
 
 #undef  STARTFILE_LINUX_SPEC
+#ifdef HAVE_LD_PIE
 #define STARTFILE_LINUX_SPEC "\
-%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} crti.o%s \
-%{static:crtbeginT.o%s} \
-%{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
+%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} crti.o%s \
+%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#else
+#define STARTFILE_LINUX_SPEC "\
+%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}} crti.o%s \
+%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+#endif
 
 #undef  ENDFILE_LINUX_SPEC
 #define ENDFILE_LINUX_SPEC "\
-%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 #undef  TOC_SECTION_ASM_OP
 #define TOC_SECTION_ASM_OP "\t.section\t\".toc\",\"aw\""
index d266c283ccad416772dd19c6f94c847f038ac8e0..d91dd3d89154829a3b566649bc310cb454bcdbc7 100644 (file)
@@ -810,7 +810,7 @@ extern int fixuplabelno;
 #define        ASM_SPEC "%(asm_cpu) \
 %{.s: %{mregnames} %{mno-regnames}} %{.S: %{mregnames} %{mno-regnames}} \
 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
-%{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
+%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \
 %{memb|msdata|msdata=eabi: -memb} \
 %{mlittle|mlittle-endian:-mlittle; \
   mbig|mbig-endian      :-mbig;    \
@@ -947,8 +947,8 @@ extern int fixuplabelno;
 
 #define CPP_SYSV_SPEC \
 "%{mrelocatable*: -D_RELOCATABLE} \
-%{fpic: -D__PIC__=1 -D__pic__=1} \
-%{!fpic: %{fPIC: -D__PIC__=2 -D__pic__=2}}"
+%{fpic|fpie: -D__PIC__=1 -D__pic__=1} \
+%{!fpic: %{fPIC|fPIE: -D__PIC__=2 -D__pic__=2}}"
 
 /* Override rs6000.h definition.  */
 #undef CPP_SPEC
@@ -1107,12 +1107,16 @@ extern int fixuplabelno;
 %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \
 %{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \
 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+#elif defined HAVE_LD_PIE
+#define        STARTFILE_LINUX_SPEC "\
+%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
+%{mnewlib:ecrti.o%s;:crti.o%s} \
+%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #else
 #define        STARTFILE_LINUX_SPEC "\
-%{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \
-%{mnewlib: ecrti.o%s} %{!mnewlib: crti.o%s} \
-%{static:crtbeginT.o%s} \
-%{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
+%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}} \
+%{mnewlib:ecrti.o%s;:crti.o%s} \
+%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #endif
 
 #define        ENDFILE_LINUX_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s} \
index 6a5c7e98e985853cbd2feb44e162cee2844919ab..e7a70922e7ac88036490bdfe73a7647673676312 100644 (file)
@@ -48,8 +48,8 @@
    t860: -DCPU=PPC860 -D_SOFT_FLOAT ; \
        : -DCPU=PPC604}  \
  %{!msoft-float:-D__hardfp}       \
- %{fpic: -D__PIC__=1 -D__pic__=1 ; \
-   fPIC: -D__PIC__=2 -D__pic__=2 } \
+ %{fpic|fpie: -D__PIC__=1 -D__pic__=1 ; \
+   fPIC|fPIE: -D__PIC__=2 -D__pic__=2 } \
  %(cpp_cpu)"
 
 #define CC1_SPEC \
index 8dfe8e73a670bf2e33ea415f250d3cdb1af887c2..92353cff87e1bc33a557891c003253adac389059 100644 (file)
@@ -81,7 +81,7 @@ Boston, MA 02111-1307, USA.  */
 #undef ASM_SPEC
 #define ASM_SPEC "\
 %{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
-%{fpic:-K PIC} %{fPIC:-K PIC} \
+%{fpic|fpie|fPIC|fPIE:-K PIC} \
 %(asm_cpu) \
 "
 
index 23f5892dd19e1b41064a6bed8ca488e3777f1e36..63ce3b95e68fa7e7110ca9e792c81af90bb5fc43 100644 (file)
@@ -57,12 +57,14 @@ Boston, MA 02111-1307, USA.  */
   "%{!shared: \
      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
+#elif defined HAVE_LD_PIE
+#define STARTFILE_SPEC \
+  "%{!shared: %{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #else
 #define STARTFILE_SPEC \
-  "%{!shared: \
-     %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
-   crti.o%s %{static:crtbeginT.o%s}\
-   %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
+  "%{!shared: %{pg|p:gcrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #endif
 
 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
@@ -74,7 +76,7 @@ Boston, MA 02111-1307, USA.  */
 #undef  ENDFILE_SPEC
 #define ENDFILE_SPEC \
   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
-   %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
+   %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
 
 /* This is for -profile to use -lc_p instead of -lc.  */
 #undef CC1_SPEC
@@ -112,11 +114,11 @@ Boston, MA 02111-1307, USA.  */
 #undef CPP_SUBTARGET_SPEC
 #ifdef USE_GNULIBC_1
 #define CPP_SUBTARGET_SPEC \
-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
+"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
 %{mlong-double-128:-D__LONG_DOUBLE_128__}"
 #else
 #define CPP_SUBTARGET_SPEC \
-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
+"%{fPIC|fPIE|fpic|fpie:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} \
 %{pthread:-D_REENTRANT} %{mlong-double-128:-D__LONG_DOUBLE_128__}"
 #endif
 
@@ -192,8 +194,8 @@ Boston, MA 02111-1307, USA.  */
    It's safe to pass -s always, even if -g is not used.  */
 #undef ASM_SPEC
 #define ASM_SPEC \
-  "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} \
-   %{fPIC:-K PIC} %(asm_cpu) %(asm_relax)"
+  "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
+   %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu) %(asm_relax)"
 
 /* Same as sparc.h */
 #undef DBX_REGISTER_NUMBER
index aed067d9eacdef2d36a8482cf17b39be003ba5be..ecdd5204ee6ae3ca1795099c00ca399a01bb49ef 100644 (file)
@@ -66,10 +66,15 @@ Boston, MA 02111-1307, USA.  */
    
 #undef  STARTFILE_SPEC
 
+#ifdef HAVE_LD_PIE
 #define STARTFILE_SPEC \
-  "%{!shared:%{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
-   crti.o%s %{static:crtbeginT.o%s}\
-   %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
+  "%{!shared:%{pg|p:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
+#else
+#define STARTFILE_SPEC \
+  "%{!shared:%{pg|p:gcrt1.o%s;:crt1.o%s}}\
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbeginS.o%s}"
+#endif
 
 /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
    the GNU/Linux magical crtend.o file (see crtstuff.c) which
@@ -80,7 +85,7 @@ Boston, MA 02111-1307, USA.  */
 #undef  ENDFILE_SPEC
 
 #define ENDFILE_SPEC \
-  "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s\
+  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s\
    %{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
 
 /* The GNU C++ standard library requires that these macros be defined.  */
@@ -124,8 +129,7 @@ Boston, MA 02111-1307, USA.  */
 
 #undef CPP_SUBTARGET_SPEC
 #define CPP_SUBTARGET_SPEC "\
-%{fPIC:-D__PIC__ -D__pic__} \
-%{fpic:-D__PIC__ -D__pic__} \
+%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} \
 %{posix:-D_POSIX_SOURCE} \
 %{pthread:-D_REENTRANT} \
 "
@@ -254,7 +258,7 @@ Boston, MA 02111-1307, USA.  */
 %{T} \
 %{Ym,*} \
 %{Wa,*:%*} \
--s %{fpic:-K PIC} %{fPIC:-K PIC} \
+-s %{fpic|fPIC|fpie|fPIE:-K PIC} \
 %{mlittle-endian:-EL} \
 %(asm_cpu) %(asm_arch) %(asm_relax)"
 
index a20fce4edc84d038c17043e51c16db87a0bae263..06783f3bf5ceb6bd5f556f2d8c8b98a669873bdb 100644 (file)
@@ -86,7 +86,7 @@ Boston, MA 02111-1307, USA.  */
 #define USER_LABEL_PREFIX ""
 
 #undef ASM_SPEC
-#define ASM_SPEC "%{fpic:-K PIC} %{fPIC:-K PIC} %{V} %{v:%{!V:-V}} \
+#define ASM_SPEC "%{fpic|fPIC|fpie|fPIE:-K PIC} %{V} %{v:%{!V:-V}} \
 %{mlittle-endian:-EL} \
 %(asm_cpu) %(asm_arch) %(asm_relax)"
 
index 96ddf7949af3cbf56a741cbe985d9ff1ec4d7209..e13c8862554b9530428e8feee497dacc0ff41bec 100644 (file)
@@ -53,7 +53,7 @@ Boston, MA 02111-1307, USA.  */
 
 #undef ASM_SPEC
 #define ASM_SPEC "\
-%{v:-V} -s %{fpic:-K PIC} %{fPIC:-K PIC} \
+%{v:-V} -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
 %{mlittle-endian:-EL} \
 %(asm_cpu) %(asm_arch) \
 "
index f442fd86fc665e6dd9985c64ca95081e7621d1a1..2782d688c51429b4afe93bd9e847abd9ca6b120c 100644 (file)
@@ -56,7 +56,7 @@ Boston, MA 02111-1307, USA.  */
 
 #undef ASM_SPEC
 #define ASM_SPEC "\
-%{v:-V} -s %{fpic:-K PIC} %{fPIC:-K PIC} \
+%{v:-V} -s %{fpic|fPIC|fpie|fPIE:-K PIC} \
 %{mlittle-endian:-EL} \
 %(asm_cpu) %(asm_arch) \
 "
index 3ec9cded6e84fc761a04c87ca76545c87121ce72..e08e4030ec7db3a6a24cd38b2a09d50948a9b303 100644 (file)
@@ -336,7 +336,7 @@ extern enum cmodel sparc_cmodel;
 /* Special flags to the Sun-4 assembler when using pipe for input.  */
 
 #define ASM_SPEC "\
-%{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \
+%{R} %{!pg:%{!p:%{fpic|fPIC|fpie|fPIE:-k}}} %{keep-local-as-symbols:-L} \
 %(asm_cpu) %(asm_relax)"
 
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
index 1d153c03e663e0a80357b147d688d0e852c042a9..80defea56fc11d868b02d96bff6afa8fc9361290 100644 (file)
@@ -59,7 +59,7 @@ Boston, MA 02111-1307, USA.  */
 #undef ASM_SPEC
 #define ASM_SPEC \
   "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
-   %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
+   %{fpic|fPIC|fpie|fPIE:-K PIC} %(asm_cpu)"
 
 /* Define the names of various pseudo-op used by the SPARC/svr4 assembler.
    Note that many of these are different from the typical pseudo-ops used
index fe5e6b39f7a0dc285a2a7667e278de5203537de7..c03bd4d179a1629d042b4214f11a24cc37e049a4 100755 (executable)
@@ -8838,11 +8838,32 @@ EOF
 fi
 echo "$ac_t""$gcc_cv_ld_eh_frame_hdr" 1>&6
 
+echo $ac_n "checking linker position independent executable support""... $ac_c" 1>&6
+echo "configure:8843: checking linker position independent executable support" >&5
+gcc_cv_ld_pie=no
+if test $in_tree_ld = yes ; then
+  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 15 -o "$gcc_cv_gld_major_version" -gt 2 && grep 'EMUL = elf' ../ld/Makefile > /dev/null; then
+    gcc_cv_ld_pie=yes
+  fi
+elif test x$gcc_cv_ld != x; then
+       # Check if linker supports -pie option
+       if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then
+               gcc_cv_ld_pie=yes
+       fi
+fi
+if test x"$gcc_cv_ld_pie" = xyes; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_LD_PIE 1
+EOF
+
+fi
+echo "$ac_t""$gcc_cv_ld_pie" 1>&6
+
 # Miscellaneous target-specific checks.
 case "$target" in
   mips*-*-*)
     echo $ac_n "checking whether libgloss uses STARTUP directives consistently""... $ac_c" 1>&6
-echo "configure:8846: checking whether libgloss uses STARTUP directives consistently" >&5
+echo "configure:8867: checking whether libgloss uses STARTUP directives consistently" >&5
     gcc_cv_mips_libgloss_startup=no
     gcc_cv_libgloss_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/libgloss
     if test "x$exec_prefix" = xNONE; then
@@ -8870,7 +8891,7 @@ EOF
     echo "$ac_t""$gcc_cv_mips_libgloss_startup" 1>&6
 
     echo $ac_n "checking whether the assembler has explicit relocation support""... $ac_c" 1>&6
-echo "configure:8874: checking whether the assembler has explicit relocation support" >&5
+echo "configure:8895: checking whether the assembler has explicit relocation support" >&5
     if test x$gcc_cv_mips_explicit_relocs = x; then
       gcc_cv_mips_explicit_relocs=no
       if test x$gcc_cv_as != x; then
@@ -9065,7 +9086,7 @@ fi
 
 
 echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
-echo "configure:9069: checking whether to enable maintainer-specific portions of Makefiles" >&5
+echo "configure:9090: checking whether to enable maintainer-specific portions of Makefiles" >&5
     # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
 if test "${enable_maintainer_mode+set}" = set; then
   enableval="$enable_maintainer_mode"
index f0e5d752474595dd57aef73dcf7a9117f121b9d7..a37f1ccfba3b0d389736801db4ad06a779d3730d 100644 (file)
@@ -2631,6 +2631,24 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xyes; then
 fi
 AC_MSG_RESULT($gcc_cv_ld_eh_frame_hdr)
 
+AC_MSG_CHECKING(linker position independent executable support)
+gcc_cv_ld_pie=no
+if test $in_tree_ld = yes ; then
+  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 15 -o "$gcc_cv_gld_major_version" -gt 2 && grep 'EMUL = elf' ../ld/Makefile > /dev/null; then
+    gcc_cv_ld_pie=yes
+  fi
+elif test x$gcc_cv_ld != x; then
+       # Check if linker supports -pie option
+       if $gcc_cv_ld --help 2>/dev/null | grep -- -pie > /dev/null; then
+               gcc_cv_ld_pie=yes
+       fi
+fi
+if test x"$gcc_cv_ld_pie" = xyes; then
+       AC_DEFINE(HAVE_LD_PIE, 1,
+[Define if your linker supports -pie option.])
+fi
+AC_MSG_RESULT($gcc_cv_ld_pie)
+
 # Miscellaneous target-specific checks.
 case "$target" in
   mips*-*-*)
index d7539d29ed78f37f35cd02efabcca70b06a02dab..17584dba87b16e60d606db65d1c65e1876a4622b 100644 (file)
@@ -310,7 +310,7 @@ in the following sections.
 @item Linker Options
 @xref{Link Options,,Options for Linking}.
 @gccoptlist{@var{object-file-name}  -l@var{library} @gol
--nostartfiles  -nodefaultlibs  -nostdlib @gol
+-nostartfiles  -nodefaultlibs  -nostdlib -pie @gol
 -s  -static  -static-libgcc  -shared  -shared-libgcc  -symbolic @gol
 -Wl,@var{option}  -Xlinker @var{option} @gol
 -u @var{symbol}}
@@ -672,7 +672,7 @@ in the following sections.
 -fasynchronous-unwind-tables @gol
 -finhibit-size-directive  -finstrument-functions @gol
 -fno-common  -fno-ident  -fno-gnu-linker @gol
--fpcc-struct-return  -fpic  -fPIC @gol
+-fpcc-struct-return  -fpic  -fPIC -fpie -fPIE @gol
 -freg-struct-return  -fshared-data  -fshort-enums @gol
 -fshort-double  -fshort-wchar @gol
 -fverbose-asm  -fpack-struct  -fstack-check @gol
@@ -4815,6 +4815,13 @@ library subroutines.  (For example, @samp{__main}, used to ensure C++
 constructors will be called; @pxref{Collect2,,@code{collect2}, gccint,
 GNU Compiler Collection (GCC) Internals}.)
 
+@item -pie
+@opindex pie
+Produce a position independent executable on targets which support it.
+For predictable results, you must also specify the same set of options
+that were used to generate code (@option{-fpie}, @option{-fPIE},
+or model suboptions) when you specify this option.
+
 @item -s
 @opindex s
 Remove all symbol table and relocation information from the executable.
@@ -11040,6 +11047,15 @@ and the SPARC.
 Position-independent code requires special support, and therefore works
 only on certain machines.
 
+@item -fpie
+@itemx -fPIE
+@opindex fpie
+@opindex fPIE
+These options are similar to @option{-fpic} and @option{-fPIC}, but
+generated position independent code can be only linked into executables.
+Usually these options are used when @option{-pie} GCC option will be
+used during linking.
+
 @item -ffixed-@var{reg}
 @opindex ffixed
 Treat the register named @var{reg} as a fixed register; generated code
index c90428816d76b96651d2fb301c1d199fa01f08b8..766b24dc4d7464a565a03a71ac167bd3775100fc 100644 (file)
@@ -462,6 +462,16 @@ extern int flag_pedantic_errors;
 
 extern int flag_pic;
 
+/* Nonzero if we are compiling position independent code for executable.
+   1 vs 2 for a target-dependent "small" or "large" mode.  */
+      
+extern int flag_pie;
+      
+/* Nonzero if we are compiling code for a shared library, zero for
+   executable.  */
+
+extern int flag_shlib;
+
 /* Nonzero means generate extra code for exception handling and enable
    exception handling.  */
 
index 1b79f5486b7b3d018bfde3dbd29dfa86130d30b2..e71a0e85f2f861775c98078cf6541ca0bf0618a9 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -664,6 +664,14 @@ proper position among the other output files.  */
 #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G"
 #endif
 
+#ifndef LINK_PIE_SPEC
+#ifdef HAVE_LD_PIE
+#define LINK_PIE_SPEC "%{pie:-pie} "
+#else
+#define LINK_PIE_SPEC "%{pie:} "
+#endif
+#endif
+
 /* -u* was put back because both BSD and SysV seem to support it.  */
 /* %{static:} simply prevents an error message if the target machine
    doesn't handle -static.  */
@@ -673,8 +681,8 @@ proper position among the other output files.  */
 #ifndef LINK_COMMAND_SPEC
 #define LINK_COMMAND_SPEC "\
 %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
-    %(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t}\
-    %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
+    %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
+    %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
     %{static:} %{L*} %(link_libgcc) %o %{fprofile-arcs:-lgcov}\
     %{!nostdlib:%{!nodefaultlibs:%(link_gcc_c_sequence)}}\
     %{!A:%{!nostdlib:%{!nostartfiles:%E}}} %{T*} }}}}}}"
@@ -1021,6 +1029,7 @@ static const struct option_map option_map[] =
    {"--param", "--param", "a"},
    {"--pedantic", "-pedantic", 0},
    {"--pedantic-errors", "-pedantic-errors", 0},
+   {"--pie", "-pie", 0},
    {"--pipe", "-pipe", 0},
    {"--prefix", "-B", "a"},
    {"--preprocess", "-E", 0},
index 6a6e076cd54c02dcfaa36bc2bff8759499190056..660b4e1efaccc655223f758cafb68d016b203418 100644 (file)
@@ -759,6 +759,17 @@ int flag_delayed_branch;
 
 int flag_pic;
 
+/* Nonzero if we are compiling position independent code for executable.
+   The value is 1 if we are doing "small" pic; value is 2 if we're doing
+   "large" pic.  */
+
+int flag_pie;
+
+/* Nonzero if we are compiling code for a shared library, zero for
+   executable.  */
+
+int flag_shlib;
+
 /* Set to the default thread-local storage (tls) model to use.  */
 
 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
@@ -1156,6 +1167,9 @@ static const lang_independent_options f_options[] =
   {"pic", &flag_pic, 1,
    N_("Generate position independent code, if possible") },
   {"PIC", &flag_pic, 2, ""},
+  {"pie", &flag_pie, 1,
+   N_("Generate position independent code for executables, if possible") },
+  {"PIE", &flag_pie, 2, ""},
   {"exceptions", &flag_exceptions, 1,
    N_("Enable exception handling") },
   {"unwind-tables", &flag_unwind_tables, 1,
@@ -5338,6 +5352,11 @@ parse_options_and_default_flags (int argc, char **argv)
        }
     }
 
+  if (flag_pie)
+    flag_pic = flag_pie;
+  if (flag_pic && !flag_pie)
+    flag_shlib = 1;
+
   if (flag_no_inline == 2)
     flag_no_inline = 0;
   else
index 0e9014aaa2fefb0293af3ef600bbda76e17913e9..cf2722cf2e8ee510d4cc5f25f6784f132ff2c407 100644 (file)
@@ -5280,7 +5280,7 @@ bool
 default_binds_local_p (exp)
      tree exp;
 {
-  return default_binds_local_p_1 (exp, flag_pic);
+  return default_binds_local_p_1 (exp, flag_shlib);
 }
 
 bool
This page took 0.125186 seconds and 5 git commands to generate.