gcc: add poison parameters detection

Add the logic that, if not configured with "--enable-target-optspace",
gcc will meet error when build target app with "-Os" option.
This could avoid potential binary crash.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>

Index: gcc-4_5-branch/gcc/config.in
===================================================================
--- gcc-4_5-branch.orig/gcc/config.in
+++ gcc-4_5-branch/gcc/config.in
@@ -138,6 +138,12 @@
 #endif
 
 
+/* Define to enable target optspace support. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_TARGET_OPTSPACE
+#endif
+
+
 /* Define if you want all operations on RTL (the basic data structure of the
    optimizer and back end) to be checked for dynamic type safety at runtime.
    This is quite expensive. */
Index: gcc-4_5-branch/gcc/configure
===================================================================
--- gcc-4_5-branch.orig/gcc/configure
+++ gcc-4_5-branch/gcc/configure
@@ -915,6 +915,7 @@ enable_version_specific_runtime_libs
 with_slibdir
 enable_poison_system_directories
 enable_plugin
+enable_target_optspace
 '
       ac_precious_vars='build_alias
 host_alias
@@ -25658,6 +25659,13 @@ $as_echo "#define ENABLE_PLUGIN 1" >>con
 
 fi
 
+if test x"$enable_target_optspace" != x; then :
+
+$as_echo "#define ENABLE_TARGET_OPTSPACE 1" >>confdefs.h
+
+fi
+
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)
 
Index: gcc-4_5-branch/gcc/configure.ac
===================================================================
--- gcc-4_5-branch.orig/gcc/configure.ac
+++ gcc-4_5-branch/gcc/configure.ac
@@ -4659,6 +4659,11 @@ if test x"$enable_plugin" = x"yes"; then
   AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.])
 fi
 
+AC_SUBST(enable_target_optspace)
+if test x"$enable_target_optspace" != x; then
+  AC_DEFINE(ENABLE_TARGET_OPTSPACE, 1, [Define to enable target optspace support.])
+fi
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)
 
Index: gcc-4_5-branch/gcc/opts.c
===================================================================
--- gcc-4_5-branch.orig/gcc/opts.c
+++ gcc-4_5-branch/gcc/opts.c
@@ -953,6 +953,11 @@ decode_options (unsigned int argc, const
   else
     set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);
 
+#ifndef ENABLE_TARGET_OPTSPACE
+  if (optimize_size == 1)
+    error ("Do not use -Os option if --enable-target-optspace is not set.");
+#endif
+
   if (first_time_p)
     {
       /* Initialize whether `char' is signed.  */
