This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] -fpie/-fPIE/-pie GCC support
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Ulrich Drepper <drepper at redhat dot com>
- Date: Mon, 2 Jun 2003 22:03:28 +0200
- Subject: [PATCH] -fpie/-fPIE/-pie GCC support
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This patch is the GCC side of Position Independent Executable support
which has been commited this week to binutils trunk.
The patch adds -pie option which is for linking, similarly to -shared.
This may select different crt files etc. and pass appropriate options
down to the linker.
Also, it adds -fpie/-fPIE options which are similar to -fpic/-fPIC,
with the difference that the GCC can assume the created position independent
code will be always linked into an executable (whether position independent
or not). ATM the difference is in binds_local - like in non-fpic code
GCC can assume any non-common object defined in the same module, even if
not static, will be in the same binary (which means GOT relative accesses
to such variables, ability to inline non-static functions at -O3, etc.).
Bootstrapped/regtested on i386-redhat-linux.
Ok for trunk?
2003-06-02 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.
--- gcc/doc/invoke.texi.jj 2003-05-31 15:38:31.000000000 -0400
+++ gcc/doc/invoke.texi 2003-06-01 16:04:29.000000000 -0400
@@ -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, @sam
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
--- gcc/toplev.c.jj 2003-06-01 09:41:26.000000000 -0400
+++ gcc/toplev.c 2003-06-01 13:54:35.000000000 -0400
@@ -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_
{"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,
@@ -5379,6 +5393,11 @@ parse_options_and_default_flags (argc, a
}
}
+ 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
--- gcc/config/sol2.h.jj 2003-05-21 06:24:37.000000000 -0400
+++ gcc/config/sol2.h 2003-06-01 12:45:48.000000000 -0400
@@ -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) \
"
--- gcc/config/openbsd.h.jj 2003-05-21 06:24:37.000000000 -0400
+++ gcc/config/openbsd.h 2003-06-01 12:11:32.000000000 -0400
@@ -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. */
--- gcc/config/linux.h.jj 2003-02-26 09:54:37.000000000 -0500
+++ gcc/config/linux.h 2003-06-01 15:48:45.000000000 -0400
@@ -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
--- gcc/config/frv/frv.h.jj 2003-05-21 06:24:38.000000000 -0400
+++ gcc/config/frv/frv.h 2003-06-01 12:12:14.000000000 -0400
@@ -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
--- gcc/config/alpha/elf.h.jj 2003-05-21 06:24:37.000000000 -0400
+++ gcc/config/alpha/elf.h 2003-06-01 14:41:54.000000000 -0400
@@ -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
--- gcc/config/arm/linux-gas.h.jj 2003-02-12 08:00:23.000000000 -0500
+++ gcc/config/arm/linux-gas.h 2003-06-01 12:13:32.000000000 -0400
@@ -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"
--- gcc/config/arm/semi.h.jj 2003-04-15 05:33:56.000000000 -0400
+++ gcc/config/arm/semi.h 2003-06-01 12:14:15.000000000 -0400
@@ -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=%*} \
--- gcc/config/arm/netbsd-elf.h.jj 2003-02-12 08:00:23.000000000 -0500
+++ gcc/config/arm/netbsd-elf.h 2003-06-01 12:13:53.000000000 -0400
@@ -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. */
--- gcc/config/freebsd-spec.h.jj 2003-05-21 06:24:37.000000000 -0400
+++ gcc/config/freebsd-spec.h 2003-06-01 12:39:39.000000000 -0400
@@ -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
--- gcc/config/i386/beos-elf.h.jj 2003-05-21 06:24:38.000000000 -0400
+++ gcc/config/i386/beos-elf.h 2003-06-01 12:18:43.000000000 -0400
@@ -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}"
--- gcc/config/i386/freebsd-aout.h.jj 2003-05-05 05:56:12.000000000 -0400
+++ gcc/config/i386/freebsd-aout.h 2003-06-01 12:19:50.000000000 -0400
@@ -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} \
--- gcc/config/i386/linux64.h.jj 2003-05-21 06:24:38.000000000 -0400
+++ gcc/config/i386/linux64.h 2003-06-01 14:54:51.000000000 -0400
@@ -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
--- gcc/config/ia64/linux.h.jj 2003-03-26 10:56:04.000000000 -0500
+++ gcc/config/ia64/linux.h 2003-06-01 14:58:05.000000000 -0400
@@ -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. */
--- gcc/config/m68k/linux.h.jj 2003-05-21 06:24:39.000000000 -0400
+++ gcc/config/m68k/linux.h 2003-06-01 12:21:14.000000000 -0400
@@ -122,18 +122,18 @@ Boston, MA 02111-1307, USA. */
#ifdef USE_GNULIBC_1
#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}"
+ "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{!msoft-float:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
#else
#define CPP_SPEC \
- "%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
+ "%{fPIC|fpic|fPIE|fpie:-D__PIC__ -D__pic__} %{m68881:-D__HAVE_68881__} %{posix:-D_POSIX_SOURCE}"
#endif
#else
#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
#endif
--- gcc/config/m68k/netbsd.h.jj 2003-01-08 09:53:47.000000000 -0500
+++ gcc/config/m68k/netbsd.h 2003-06-01 12:21:50.000000000 -0400
@@ -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
--- gcc/config/m68k/openbsd.h.jj 2003-05-21 06:24:39.000000000 -0400
+++ gcc/config/m68k/openbsd.h 2003-06-01 12:22:01.000000000 -0400
@@ -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
--- gcc/config/m68k/netbsd-elf.h.jj 2003-05-21 06:24:39.000000000 -0400
+++ gcc/config/m68k/netbsd-elf.h 2003-06-01 12:22:23.000000000 -0400
@@ -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
--- gcc/config/mips/linux.h.jj 2003-05-31 15:38:27.000000000 -0400
+++ gcc/config/mips/linux.h 2003-06-01 12:25:14.000000000 -0400
@@ -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 */
--- gcc/config/mips/openbsd.h.jj 2003-01-08 09:53:58.000000000 -0500
+++ gcc/config/mips/openbsd.h 2003-06-01 12:25:34.000000000 -0400
@@ -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
--- gcc/config/pa/pa-linux.h.jj 2003-05-21 06:24:41.000000000 -0400
+++ gcc/config/pa/pa-linux.h 2003-06-01 12:26:25.000000000 -0400
@@ -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 \
--- gcc/config/netbsd-aout.h.jj 2003-01-08 09:52:39.000000000 -0500
+++ gcc/config/netbsd-aout.h 2003-06-01 12:39:57.000000000 -0400
@@ -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
--- gcc/config/rs6000/sysv4.h.jj 2003-06-01 09:50:38.000000000 -0400
+++ gcc/config/rs6000/sysv4.h 2003-06-01 15:02:41.000000000 -0400
@@ -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} \
--- gcc/config/rs6000/vxworks.h.jj 2003-05-21 06:24:42.000000000 -0400
+++ gcc/config/rs6000/vxworks.h 2003-06-01 12:30:14.000000000 -0400
@@ -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 \
--- gcc/config/rs6000/linux64.h.jj 2003-06-01 09:50:37.000000000 -0400
+++ gcc/config/rs6000/linux64.h 2003-06-01 15:00:43.000000000 -0400
@@ -215,14 +215,19 @@
#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\""
--- gcc/config/sparc/linux.h.jj 2003-05-21 06:24:43.000000000 -0400
+++ gcc/config/sparc/linux.h 2003-06-01 15:05:36.000000000 -0400
@@ -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
--- gcc/config/sparc/linux64.h.jj 2003-05-21 06:24:43.000000000 -0400
+++ gcc/config/sparc/linux64.h 2003-06-01 15:07:04.000000000 -0400
@@ -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)"
--- gcc/config/sparc/sparc.h.jj 2003-05-21 06:24:43.000000000 -0400
+++ gcc/config/sparc/sparc.h 2003-06-01 12:37:39.000000000 -0400
@@ -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
--- gcc/config/sparc/sp64-elf.h.jj 2003-05-21 06:24:43.000000000 -0400
+++ gcc/config/sparc/sp64-elf.h 2003-06-01 12:38:00.000000000 -0400
@@ -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) \
"
--- gcc/config/sparc/sysv4.h.jj 2003-05-17 04:59:03.000000000 -0400
+++ gcc/config/sparc/sysv4.h 2003-06-01 12:38:21.000000000 -0400
@@ -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
--- gcc/config/sparc/netbsd-elf.h.jj 2003-05-26 17:04:27.000000000 -0400
+++ gcc/config/sparc/netbsd-elf.h 2003-06-01 12:38:41.000000000 -0400
@@ -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)"
--- gcc/config/sparc/openbsd64.h.jj 2003-05-21 06:24:43.000000000 -0400
+++ gcc/config/sparc/openbsd64.h 2003-06-01 12:39:05.000000000 -0400
@@ -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) \
"
--- gcc/config/cris/linux.h.jj 2003-05-21 06:24:38.000000000 -0400
+++ gcc/config/cris/linux.h 2003-06-01 12:40:25.000000000 -0400
@@ -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
--- gcc/flags.h.jj 2003-05-31 15:38:25.000000000 -0400
+++ gcc/flags.h 2003-06-01 13:56:44.000000000 -0400
@@ -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. */
--- gcc/varasm.c.jj 2003-05-17 04:58:56.000000000 -0400
+++ gcc/varasm.c 2003-06-01 14:00:38.000000000 -0400
@@ -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
--- gcc/gcc.c.jj 2003-05-26 17:04:24.000000000 -0400
+++ gcc/gcc.c 2003-06-01 15:16:06.000000000 -0400
@@ -664,6 +664,14 @@ proper position among the other output f
#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 f
#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_ma
{"--param", "--param", "a"},
{"--pedantic", "-pedantic", 0},
{"--pedantic-errors", "-pedantic-errors", 0},
+ {"--pie", "-pie", 0},
{"--pipe", "-pipe", 0},
{"--prefix", "-B", "a"},
{"--preprocess", "-E", 0},
--- gcc/configure.in.jj 2003-06-01 09:50:36.000000000 -0400
+++ gcc/configure.in 2003-06-01 14:17:42.000000000 -0400
@@ -2631,6 +2631,24 @@ if test x"$gcc_cv_ld_eh_frame_hdr" = xye
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*-*-*)
--- gcc/config.in.jj 2003-04-25 11:49:40.000000000 -0400
+++ gcc/config.in 2003-06-01 14:18:54.000000000 -0400
@@ -631,6 +631,9 @@
/* 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
--- gcc/configure.jj 2003-06-01 09:50:36.000000000 -0400
+++ gcc/configure 2003-06-01 14:18:34.000000000 -0400
@@ -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"
Jakub