dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0194-Remove-all-trampoline-support.-Add-Wtrampolines-when.patch

f96e0b
From 03cd56052af22492179742054c0e6c0382f85afb Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Sun, 3 Mar 2013 15:57:30 +0100
f96e0b
Subject: [PATCH 194/482] 	Remove all trampoline support. Add
f96e0b
 -Wtrampolines when 	present. Remove symbols used for trampolines to make 
f96e0b
 link fail if trampolines are present.
f96e0b
f96e0b
---
f96e0b
 ChangeLog             |  6 ++++++
f96e0b
 conf/Makefile.common  |  2 +-
f96e0b
 config.h.in           |  7 -------
f96e0b
 configure.ac          | 31 +++++++++++--------------------
f96e0b
 grub-core/kern/misc.c |  8 --------
f96e0b
 include/grub/libgcc.h |  8 --------
f96e0b
 include/grub/misc.h   |  4 ----
f96e0b
 7 files changed, 18 insertions(+), 48 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index e67ca9a..cacba37 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,11 @@
f96e0b
 2013-03-03  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	Remove all trampoline support. Add -Wtrampolines when
f96e0b
+	present. Remove symbols used for trampolines to make
f96e0b
+	link fail if trampolines are present.
f96e0b
+
f96e0b
+2013-03-03  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	* grub-core/script/execute.c (grub_script_arglist_to_argv): Move
f96e0b
 	append out of its parent.
f96e0b
 
f96e0b
diff --git a/conf/Makefile.common b/conf/Makefile.common
f96e0b
index 75c0a5e..c185a55 100644
f96e0b
--- a/conf/Makefile.common
f96e0b
+++ b/conf/Makefile.common
f96e0b
@@ -30,7 +30,7 @@ if COND_mips_loongson
f96e0b
   CPPFLAGS_PLATFORM = -DUSE_ASCII_FAILBACK
f96e0b
 endif
f96e0b
 if COND_mips
f96e0b
-  CFLAGS_PLATFORM += -mflush-func=grub_cpu_flush_cache
f96e0b
+  CFLAGS_PLATFORM += -mflush-func=grub_red_herring
f96e0b
   CCASFLAGS_PLATFORM = -march=mips3
f96e0b
 endif
f96e0b
 if COND_sparc64_ieee1275
f96e0b
diff --git a/config.h.in b/config.h.in
f96e0b
index 91afd98..621742c 100644
f96e0b
--- a/config.h.in
f96e0b
+++ b/config.h.in
f96e0b
@@ -11,7 +11,6 @@
f96e0b
 
f96e0b
 #if defined (GRUB_UTIL) || !defined (GRUB_MACHINE)
f96e0b
 #include <config-util.h>
f96e0b
-#define NESTED_FUNC_ATTR
f96e0b
 #else
f96e0b
 /* Define if C symbols get an underscore after compilation. */
f96e0b
 #define HAVE_ASM_USCORE @HAVE_ASM_USCORE@
f96e0b
@@ -49,10 +48,4 @@
f96e0b
 
f96e0b
 #define RE_ENABLE_I18N 1
f96e0b
 
f96e0b
-#if defined(__i386__)
f96e0b
-#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
f96e0b
-#else
f96e0b
-#define NESTED_FUNC_ATTR
f96e0b
-#endif
f96e0b
-
f96e0b
 #endif
f96e0b
diff --git a/configure.ac b/configure.ac
f96e0b
index 92b550a..038f429 100644
f96e0b
--- a/configure.ac
f96e0b
+++ b/configure.ac
f96e0b
@@ -357,21 +357,18 @@ AC_CHECK_HEADER([util.h], [
f96e0b
 ])
f96e0b
 AC_SUBST([LIBUTIL])
f96e0b
 
f96e0b
-AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_host_cc_wnotrampolines], [
f96e0b
+AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_host_cc_wtrampolines], [
f96e0b
   SAVED_CFLAGS="$CFLAGS"
f96e0b
-  # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
f96e0b
-  # in the event of later failures (since -Wno-* is always accepted, but
f96e0b
-  # produces a diagnostic if something else is wrong).
f96e0b
   CFLAGS="$HOST_CFLAGS -Wtrampolines"
f96e0b
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
f96e0b
 int va_arg_func (int fixed, va_list args);]], [[]])],
f96e0b
-      [grub_cv_host_cc_wnotrampolines=yes],
f96e0b
-      [grub_cv_host_cc_wnotrampolines=no])
f96e0b
+      [grub_cv_host_cc_wtrampolines=yes],
f96e0b
+      [grub_cv_host_cc_wtrampolines=no])
f96e0b
   CFLAGS="$SAVED_CFLAGS"
f96e0b
 ])
f96e0b
 
f96e0b
-if test x"$grub_host_cv_cc_wnotrampolines" = xyes ; then
f96e0b
-  HOST_CFLAGS="$HOST_CFLAGS -Wno-trampolines"
f96e0b
+if test x"$grub_host_cv_cc_wtrampolines" = xyes ; then
f96e0b
+  HOST_CFLAGS="$HOST_CFLAGS -Wtrampolines"
f96e0b
 fi
f96e0b
 
f96e0b
 #
f96e0b
@@ -621,9 +618,6 @@ fi
f96e0b
 # Compiler features.
f96e0b
 #
f96e0b
 
f96e0b
-# Need __enable_execute_stack() for nested function trampolines?
f96e0b
-grub_CHECK_ENABLE_EXECUTE_STACK
f96e0b
-
f96e0b
 # Position independent executable.
f96e0b
 grub_CHECK_PIE
f96e0b
 [# Need that, because some distributions ship compilers that include
f96e0b
@@ -715,7 +709,7 @@ CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
f96e0b
 fi
f96e0b
 
f96e0b
 # Check for libgcc symbols
f96e0b
-AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x __ia64_trampoline __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
f96e0b
+AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x __udivsi3 __umoddi3 __udivdi3 __divsi3 __modsi3 __umodsi3 __moddi3 __divdi3 __ctzdi2 __ctzsi2)
f96e0b
 
f96e0b
 if test "x$TARGET_APPLE_CC" = x1 ; then
f96e0b
 CFLAGS="$TARGET_CFLAGS -nostdlib"
f96e0b
@@ -761,21 +755,18 @@ if test x"$grub_cv_cc_isystem" = xyes ; then
f96e0b
 fi
f96e0b
 fi
f96e0b
 
f96e0b
-AC_CACHE_CHECK([whether -Wno-trampolines work], [grub_cv_cc_wnotrampolines], [
f96e0b
+AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
f96e0b
   SAVED_CFLAGS="$CFLAGS"
f96e0b
-  # Test for -Wtrampolines rather than -Wno-trampolines to reduce confusion
f96e0b
-  # in the event of later failures (since -Wno-* is always accepted, but
f96e0b
-  # produces a diagnostic if something else is wrong).
f96e0b
   CFLAGS="$TARGET_CFLAGS -Wtrampolines"
f96e0b
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
f96e0b
 int va_arg_func (int fixed, va_list args);]], [[]])],
f96e0b
-      [grub_cv_cc_wnotrampolines=yes],
f96e0b
-      [grub_cv_cc_wnotrampolines=no])
f96e0b
+      [grub_cv_cc_wtrampolines=yes],
f96e0b
+      [grub_cv_cc_wtrampolines=no])
f96e0b
   CFLAGS="$SAVED_CFLAGS"
f96e0b
 ])
f96e0b
 
f96e0b
-if test x"$grub_cv_cc_wnotrampolines" = xyes ; then
f96e0b
-  TARGET_CFLAGS="$TARGET_CFLAGS -Wno-trampolines"
f96e0b
+if test x"$grub_cv_cc_wtrampolines" = xyes ; then
f96e0b
+  TARGET_CFLAGS="$TARGET_CFLAGS -Wtrampolines"
f96e0b
 fi
f96e0b
 
f96e0b
 # Restore the flags.
f96e0b
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
f96e0b
index c3203a0..6cb8f0e 100644
f96e0b
--- a/grub-core/kern/misc.c
f96e0b
+++ b/grub-core/kern/misc.c
f96e0b
@@ -1120,14 +1120,6 @@ grub_abort (void)
f96e0b
 void abort (void) __attribute__ ((alias ("grub_abort")));
f96e0b
 #endif
f96e0b
 
f96e0b
-#if NEED_ENABLE_EXECUTE_STACK && !defined(GRUB_UTIL) && !defined(GRUB_MACHINE_EMU)
f96e0b
-/* Some gcc versions generate a call to this function
f96e0b
-   in trampolines for nested functions.  */
f96e0b
-void __enable_execute_stack (void *addr __attribute__ ((unused)))
f96e0b
-{
f96e0b
-}
f96e0b
-#endif
f96e0b
-
f96e0b
 #if NEED_REGISTER_FRAME_INFO && !defined(GRUB_UTIL)
f96e0b
 void __register_frame_info (void)
f96e0b
 {
f96e0b
diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h
f96e0b
index 956d639..ca0d577 100644
f96e0b
--- a/include/grub/libgcc.h
f96e0b
+++ b/include/grub/libgcc.h
f96e0b
@@ -74,14 +74,6 @@ void EXPORT_FUNC (__ctzsi2) (void);
f96e0b
 # endif
f96e0b
 #endif
f96e0b
 
f96e0b
-# ifdef HAVE___IA64_TRAMPOLINE
f96e0b
-void EXPORT_FUNC (__ia64_trampoline) (void);
f96e0b
-# endif
f96e0b
-
f96e0b
-#ifdef HAVE___TRAMPOLINE_SETUP
f96e0b
-void EXPORT_FUNC (__trampoline_setup) (void);
f96e0b
-#endif
f96e0b
-
f96e0b
 #ifdef HAVE__RESTGPR_14_X
f96e0b
 void EXPORT_FUNC (_restgpr_14_x) (void);
f96e0b
 void EXPORT_FUNC (_restgpr_15_x) (void);
f96e0b
diff --git a/include/grub/misc.h b/include/grub/misc.h
f96e0b
index 33e6b73..11eeb22 100644
f96e0b
--- a/include/grub/misc.h
f96e0b
+++ b/include/grub/misc.h
f96e0b
@@ -382,10 +382,6 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
f96e0b
 					  grub_uint64_t d,
f96e0b
 					  grub_uint64_t *r);
f96e0b
 
f96e0b
-#if !defined(GRUB_UTIL) && NEED_ENABLE_EXECUTE_STACK
f96e0b
-void EXPORT_FUNC(__enable_execute_stack) (void *addr);
f96e0b
-#endif
f96e0b
-
f96e0b
 #if !defined(GRUB_UTIL) && NEED_REGISTER_FRAME_INFO
f96e0b
 void EXPORT_FUNC (__register_frame_info) (void);
f96e0b
 void EXPORT_FUNC (__deregister_frame_info) (void);
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b