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