]> git.proxmox.com Git - grub2.git/commitdiff
2009-09-03 Magnus Granberg <zorry@ume.nu>
authorrobertmh <robertmh@localhost>
Thu, 3 Sep 2009 16:32:14 +0000 (16:32 +0000)
committerrobertmh <robertmh@localhost>
Thu, 3 Sep 2009 16:32:14 +0000 (16:32 +0000)
        * aclocal.m4: Add grub_CHECK_PIE. It check if the compiler
        include -fPIE in the default specs.
        * configure.ac: Check if pie_possible is yes and add -fno-PIE
        to TARGET_CFLAGS.

ChangeLog
aclocal.m4
configure.ac

index 84c051eeea54f3712017e0831cdfb9172adc3e12..fda47fe51c94da2809360835ed973935382b44b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-03  Magnus Granberg  <zorry@ume.nu>
+
+       * aclocal.m4: Add grub_CHECK_PIE. It check if the compiler
+       include -fPIE in the default specs.
+       * configure.ac: Check if pie_possible is yes and add -fno-PIE
+       to TARGET_CFLAGS.
+
 2009-09-03  Felix Zielcke  <fzielcke@z-51.de>
 
        * INSTALL: Note that GNU Bison 2.3 or later is required.
index bde935dc94853d839611f0140605eb37d26c9706..313b241fa48bd9934a29faf0512a8cd48a23a495 100644 (file)
@@ -413,3 +413,31 @@ else
 [fi
 rm -rf testdir]
 ])
+
+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]
+])
index cddd9fe2dd4e39709b89509b691c183ed47c3a34..3c4c6dce6f96fa319377b8c713e2410058617259 100644 (file)
@@ -346,6 +346,14 @@ fi
 # Need __enable_execute_stack() for nested function trampolines?
 grub_CHECK_ENABLE_EXECUTE_STACK
 
+# 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