From 38578b77a619b7afa7a8f3abf341a9db8fd71bf1 Mon Sep 17 00:00:00 2001 From: andreast Date: Tue, 9 Jun 2015 20:01:54 +0000 Subject: Backport PIE support for FreeBSD from GCC trunk. Approved by: gerald --- lang/gcc5-devel/files/patch-pie-support | 73 +++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 lang/gcc5-devel/files/patch-pie-support (limited to 'lang/gcc5-devel/files') diff --git a/lang/gcc5-devel/files/patch-pie-support b/lang/gcc5-devel/files/patch-pie-support new file mode 100644 index 000000000000..7fc70b40e715 --- /dev/null +++ b/lang/gcc5-devel/files/patch-pie-support @@ -0,0 +1,73 @@ +--- gcc/config/freebsd-spec.h.orig 2015-01-05 13:33:28.000000000 +0100 ++++ gcc/config/freebsd-spec.h 2015-05-19 12:13:47.863772000 +0200 +@@ -66,8 +66,9 @@ + "%{!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 @@ + `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 +--- gcc/config/i386/freebsd.h.orig 2015-01-05 13:33:28.000000000 +0100 ++++ gcc/config/i386/freebsd.h 2015-05-19 12:13:47.865132000 +0200 +@@ -59,28 +59,15 @@ + #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}" +- +-/* 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 ENDFILE_SPEC +-#define ENDFILE_SPEC \ +- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s" ++/* Use the STARTFILE_SPEC from config/freebsd-spec.h. */ ++ ++#undef STARTFILE_SPEC ++#define STARTFILE_SPEC FBSD_STARTFILE_SPEC ++ ++/* 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 +--- gcc/testsuite/lib/target-supports.exp.orig 2015-03-26 00:35:54.000000000 +0100 ++++ gcc/testsuite/lib/target-supports.exp 2015-05-19 12:13:47.868191000 +0200 +@@ -952,6 +952,7 @@ + + proc check_effective_target_pie { } { + if { [istarget *-*-darwin\[912\]*] ++ || [istarget *-*-freebsd*] + || [istarget *-*-linux*] + || [istarget *-*-gnu*] } { + return 1; -- cgit