]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* configure.ac: Build stage2 with -fno-reorder-functions to prevent
authorColin Watson <cjwatson@ubuntu.com>
Mon, 26 Sep 2011 09:15:32 +0000 (10:15 +0100)
committerColin Watson <cjwatson@ubuntu.com>
Mon, 26 Sep 2011 09:15:32 +0000 (10:15 +0100)
unlikely-to-be-executed functions being reordered before _start with
GCC 4.6.
Fixes Ubuntu bug #837815.

ChangeLog
configure.ac

index 565a4325b3c8306258a715a7e74ce8b97b48ef0f..3f51b8b37688ca36b52f881aa401071c0e711422 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-26  Colin Watson  <cjwatson@ubuntu.com>
+
+       * configure.ac: Build stage2 with -fno-reorder-functions to prevent
+       unlikely-to-be-executed functions being reordered before _start with
+       GCC 4.6.
+       Fixes Ubuntu bug #837815.
+
 2010-01-25  Robert Millan  <rmh.grub@aybabtu.com>
 
        * stage2/imgact_aout.h: Rewrite using aout.h from GRUB 1.97.2 as
index f462677a66b4087a871b98efdedd594068c5c1b1..c862eb2e666f5d678b6ccfdb885b9ef8650a91a4 100644 (file)
@@ -114,6 +114,22 @@ if test "x$ac_cv_prog_gcc" = xyes; then
     if test "x$grub_cv_cc_no_stack_protector" = xyes; then
       STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector"
     fi
+    # GCC >= 3.3 supports -fno-reorder-functions; this defends us against
+    # unlikely-to-be-executed functions being linked before _start with GCC
+    # >= 4.6.
+    AC_CACHE_CHECK([whether gcc has -fno-reorder-functions],
+                  no_reorder_functions_flag, [
+      saved_CFLAGS=$CFLAGS
+      CFLAGS="-fno-reorder-functions"
+      AC_TRY_COMPILE(,
+                    ,
+                    no_reorder_functions_flag=yes,
+                    no_reorder_functions_flag=no)
+      CFLAGS=$saved_CFLAGS
+    ])
+    if test "x$no_reorder_functions_flag" = xyes; then
+      STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-reorder-functions"
+    fi
   fi
 fi