From 8ea0dcb9e0ccebfc03bbe1b52a096c65c8e4d11c Mon Sep 17 00:00:00 2001 From: Andreas Tobler Date: Mon, 18 May 2015 20:37:18 +0200 Subject: [PATCH] freebsd-spec.h (FBSD_STARTFILE_SPEC): Add the bits to build pie executables. 2015-05-18 Andreas Tobler gcc: * config/freebsd-spec.h (FBSD_STARTFILE_SPEC): Add the bits to build pie executables. (FBSD_ENDFILE_SPEC): Likewise. * config/i386/freebsd.h (STARTFILE_SPEC): Remove and use the one from config/freebsd-spec.h. (ENDFILE_SPEC): Likewise. gcc/testsuite: * lib/target-supports.exp (check_effective_target_pie): Add *-*-freebsd* to the family of pie capable targets. From-SVN: r223308 --- gcc/ChangeLog | 9 +++++++++ gcc/config/freebsd-spec.h | 7 ++++--- gcc/config/i386/freebsd.h | 27 +++++++-------------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/lib/target-supports.exp | 1 + 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dd2c97fdf25..c00a8789d45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-05-18 Andreas Tobler + + * config/freebsd-spec.h (FBSD_STARTFILE_SPEC): Add the bits to build + pie executables. + (FBSD_ENDFILE_SPEC): Likewise. + * config/i386/freebsd.h (STARTFILE_SPEC): Remove and use the one from + config/freebsd-spec.h. + (ENDFILE_SPEC): Likewise. + 2015-05-18 Uros Bizjak Richard Henderson diff --git a/gcc/config/freebsd-spec.h b/gcc/config/freebsd-spec.h index e3fa912f079..9341db789eb 100644 --- a/gcc/config/freebsd-spec.h +++ b/gcc/config/freebsd-spec.h @@ -66,8 +66,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see "%{!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}" + %{!profile: \ + %{pie: Scrt1.o%s;:crt1.o%s}}}}} \ + crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" /* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on the magical crtend.o file (see crtstuff.c) which provides part of @@ -76,7 +77,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see `crtn.o'. */ #define FBSD_ENDFILE_SPEC \ - "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" + "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" /* Provide a LIB_SPEC appropriate for FreeBSD as configured and as required by the user-land thread model. Before __FreeBSD_version diff --git a/gcc/config/i386/freebsd.h b/gcc/config/i386/freebsd.h index ff73aeaaa1d..6ce160ed409 100644 --- a/gcc/config/i386/freebsd.h +++ b/gcc/config/i386/freebsd.h @@ -59,28 +59,15 @@ along with GCC; see the file COPYING3. If not see #define SUBTARGET_EXTRA_SPECS \ { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER } -/* Provide a STARTFILE_SPEC appropriate for FreeBSD. Here we add - the magical crtbegin.o file (see crtstuff.c) which provides part - of the support for getting C++ file-scope static object constructed - before entering `main'. */ - -#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 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" +/* Use the STARTFILE_SPEC from config/freebsd-spec.h. */ -/* Provide a ENDFILE_SPEC appropriate for FreeBSD. Here we tack on - the magical crtend.o file (see crtstuff.c) which provides part of - the support for getting C++ file-scope static object constructed - before entering `main', followed by a normal "finalizer" file, - `crtn.o'. */ +#undef STARTFILE_SPEC +#define STARTFILE_SPEC FBSD_STARTFILE_SPEC -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ - "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" +/* Use the ENDFILE_SPEC from config/freebsd-spec.h. */ + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC FBSD_ENDFILE_SPEC /* Provide a LINK_SPEC appropriate for FreeBSD. Here we provide support for the special GCC options -static and -shared, which allow us to diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8a29d995a4f..c4b77b36dba 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-12 Andreas Tobler + + * lib/target-supports.exp (check_effective_target_pie): Add *-*-freebsd* + to the family of pie capable targets. + 2015-05-18 Alex Velenko * gcc.target/arm/bics_1.c : New testcase. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 3728927dccc..e3f824a63ae 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -954,6 +954,7 @@ proc check_effective_target_shared { } { proc check_effective_target_pie { } { if { [istarget *-*-darwin\[912\]*] + || [istarget *-*-freebsd*] || [istarget *-*-linux*] || [istarget *-*-gnu*] } { return 1;