Some distributions ship compilers that include -fPIE in the default specs (Gentoo Hardened)
PATCH 1/1 Some distributions ship compilers that include -fPIE in the default specs (Gentoo Hardened)
Hi
On Gentoo Hardened we compile with -fPIE in the default specs and grub fails to compile.
This patch check if the compiler use -fPIE in the default specs and add -fno-PIE to TARGET_CFLAGS.
aclocal.m4 renamed from aclocal.m4.zorry +28 -0
@@ -362,3 +362,31 @@ AC_MSG_RESULT([no]) [fi] ]) + +dnl Check if the C compiler supports `-fPIE'. +AC_DEFUN(grub_CHECK_PIE,[ +[# Position independent executable. +pie_possible=yes] +AC_MSG_CHECKING([whether `$CC' has `-fPIE' as default]) +# Is this a reliable test case? +AC_LANG_CONFTEST([[ +#ifdef __PIE__ +int main() { + return 0; +} +#else +#error NO __PIE__ DEFINED +#endif +]]) + +[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling +# `ac_compile' like this correct, after all? +if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then] + AC_MSG_RESULT([yes]) + [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? + rm -f conftest.s +else + pie_possible=no] + AC_MSG_RESULT([no]) +[fi] +])
configure.ac renamed from configure.ac.zorry +8 -0
@@ -251,6 +251,14 @@ # Compiler features. # +# Position independent executable. +grub_CHECK_PIE +[# Need that, because some distributions ship compilers that include +# `-fPIE' in the default specs. +if [ x"$pie_possible" = xyes ]; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" +fi] + # Smashing stack protector. grub_CHECK_STACK_PROTECTOR [# Need that, because some distributions ship compilers that include
---
Hardened-Development Overlay
Magnus Granberg (Zorry) <[email protected]>
Why not just check if the compiler accepts -fno-PIE and use it? No harm done if -fPIE wasn't default, right?
Quoted 71 lines · Magnus Granberg
Hi
On Gentoo Hardened we compile with -fPIE in the default specs and grub fails to compile.
This patch check if the compiler use -fPIE in the default specs and add(quoted diff) +0
-1-fno-PIE to TARGET_CFLAGS.aclocal.m4 2009-08-22 01:05:56.000000000 +0200 renamed from aclocal.m4.zorry 2008-02-03 14:11:28.000000000 +0100 +0
-0@@ -362,3 +362,31 @@ AC_MSG_RESULT([no])[fi]
])aclocal.m4 2009-08-22 01:05:56.000000000 +0200 renamed from aclocal.m4.zorry 2008-02-03 14:11:28.000000000 +0100 +28
-0+ +dnl Check if the C compiler supports `-fPIE'. +AC_DEFUN(grub_CHECK_PIE,[ +[# Position independent executable. +pie_possible=yes] +AC_MSG_CHECKING([whether `$CC' has `-fPIE' as default]) +# Is this a reliable test case? +AC_LANG_CONFTEST([[ +#ifdef __PIE__ +int main() { + return 0; +} +#else +#error NO __PIE__ DEFINED +#endif +]]) + +[# `$CC -c -o ...' might not be portable. But, oh, well... Is calling +# `ac_compile' like this correct, after all? +if eval "$ac_compile -S -o conftest.s" 2> /dev/null; then] + AC_MSG_RESULT([yes]) + [# Should we clear up other files as well, having called `AC_LANG_CONFTEST'? + rm -f conftest.s +else + pie_possible=no] + AC_MSG_RESULT([no]) +[fi] +])configure.ac 2009-09-01 01:05:34.000000000 +0200 renamed from configure.ac.zorry 2008-02-03 14:41:51.000000000 +0100 +8
-0@@ -251,6 +251,14 @@ # Compiler features. # +# Position independent executable. +grub_CHECK_PIE +[# Need that, because some distributions ship compilers that include +# `-fPIE' in the default specs. +if [ x"$pie_possible" = xyes ]; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" +fi] + # Smashing stack protector.grub_CHECK_STACK_PROTECTOR
[# Need that, because some distributions ship compilers that include---
Hardened-Development Overlay
Magnus Granberg (Zorry) <[email protected]>_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 6 lines · Magnus Granberg
Hi
On Gentoo Hardened we compile with -fPIE in the default specs and grub fails to compile.
This patch check if the compiler use -fPIE in the default specs and add -fno-PIE toTARGET_CFLAGS.
Committed. In the future, please include patches as text attachments.
Thanks
Signature · 5 lines
Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."