aboutsummaryrefslogtreecommitdiff
blob: 5171844b11b0757ce74da41e77d0d20839c10501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2010-03-19	Magnus Granberg		<zorry@ume.nu>

		# #139277 #168834 #281246
		* configure.ac: Check if the compiler
		compile with -fPIE as default. If add -nopie
		to STAGE1_CFLAGS and STAGE2_CFLAGS.

--- a/configure.ac	2010-03-07 15:39:03.000000000 +0100
+++ b/configure.ac	2010-03-09 13:04:12.000000000 +0100
@@ -107,6 +107,20 @@
     if test "x$grub_cv_cc_no_stack_protector" = xyes; then
       STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector"
     fi
+    # Position Independent Executables, but GRUB doesn't want this feature.
+    AC_CACHE_CHECK([whether gcc has -fPIE on as default], grub_cv_cc_fpie, [
+      AC_TRY_COMPILE(,[
+		#if ! defined (__PIC__) || ! defined (__PIE__)
+		#error
+		#endif
+		],
+            grub_cv_cc_fpie=yes,
+            grub_cv_cc_fpie=no)
+    ])
+    if test "x$grub_cv_cc_fpie" = xyes; then
+      STAGE1_CFLAGS="$STAGE1_CFLAGS -nopie"
+      STAGE2_CFLAGS="$STAGE2_CFLAGS -nopie"
+    fi
   fi
 fi