Index: gcc/flags.h
===================================================================
--- gcc/flags.h	(revision 164932)
+++ gcc/flags.h	(working copy)
@@ -272,10 +272,6 @@ extern struct target_flag_state *this_ta
 /* Nonzero if subexpressions must be evaluated from left-to-right.  */
 extern int flag_evaluation_order;
 
-/* Value of the -G xx switch, and whether it was passed or not.  */
-extern unsigned HOST_WIDE_INT g_switch_value;
-extern bool g_switch_set;
-
 /* Whether to run the warn_unused_result attribute pass.  */
 extern bool flag_warn_unused_result;
 
Index: gcc/opts.c
===================================================================
--- gcc/opts.c	(revision 164932)
+++ gcc/opts.c	(working copy)
@@ -46,10 +46,6 @@ along with GCC; see the file COPYING3.  
 #include "except.h"
 #include "lto-streamer.h"
 
-/* Value of the -G xx switch, and whether it was passed or not.  */
-unsigned HOST_WIDE_INT g_switch_value;
-bool g_switch_set;
-
 /* True if we should exit after parsing options.  */
 bool exit_after_options;
 
Index: gcc/config/alpha/elf.h
===================================================================
--- gcc/config/alpha/elf.h	(revision 164932)
+++ gcc/config/alpha/elf.h	(working copy)
@@ -121,7 +121,7 @@ do {									\
 #undef  ASM_OUTPUT_ALIGNED_LOCAL
 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
 do {									\
-  if ((SIZE) <= g_switch_value)						\
+  if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value)		\
     switch_to_section (sbss_section);					\
   else									\
     switch_to_section (bss_section);					\
Index: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c	(revision 164932)
+++ gcc/config/alpha/alpha.c	(working copy)
@@ -215,11 +215,6 @@ alpha_handle_option (size_t code, const 
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      break;
-
     case OPT_mfp_regs:
       if (value == 0)
 	target_flags |= MASK_SOFT_FP;
@@ -487,7 +482,7 @@ alpha_option_override (void)
   }
 
   /* Default the definition of "small data" to 8 bytes.  */
-  if (!g_switch_set)
+  if (!global_options_set.x_g_switch_value)
     g_switch_value = 8;
 
   /* Infer TARGET_SMALL_DATA from -fpic/-fPIC.  */
@@ -775,7 +770,7 @@ alpha_in_small_data_p (const_tree exp)
 
       /* If this is an incomplete type with size 0, then we can't put it
 	 in sdata because it might be too big when completed.  */
-      if (size > 0 && (unsigned HOST_WIDE_INT) size <= g_switch_value)
+      if (size > 0 && size <= g_switch_value)
 	return true;
     }
 
Index: gcc/config/frv/frv.h
===================================================================
--- gcc/config/frv/frv.h	(revision 164932)
+++ gcc/config/frv/frv.h	(working copy)
@@ -2069,7 +2069,7 @@ extern int size_directive_output;
 #undef ASM_OUTPUT_ALIGNED_DECL_LOCAL
 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGN)	\
 do {                                                                   	\
-  if ((SIZE) > 0 && (SIZE) <= g_switch_value)				\
+  if ((SIZE) > 0 && (SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value)	\
     switch_to_section (get_named_section (NULL, ".sbss", 0));           \
   else                                                                 	\
     switch_to_section (bss_section);                                  	\
Index: gcc/config/frv/frv.c
===================================================================
--- gcc/config/frv/frv.c	(revision 164932)
+++ gcc/config/frv/frv.c	(working copy)
@@ -572,7 +572,7 @@ frv_const_unspec_p (rtx x, struct frv_un
 
 	  if (frv_small_data_reloc_p (unspec->symbol, unspec->reloc)
 	      && unspec->offset > 0
-	      && (unsigned HOST_WIDE_INT) unspec->offset < g_switch_value)
+	      && unspec->offset < g_switch_value)
 	    return true;
 	}
     }
@@ -611,11 +611,6 @@ frv_handle_option (size_t code, const ch
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
     case OPT_mcpu_:
       if (strcmp (arg, "simple") == 0)
 	frv_cpu_type = FRV_CPU_SIMPLE;
@@ -692,9 +687,8 @@ frv_option_override (void)
       if (!flag_pic)		/* -fPIC */
 	flag_pic = 2;
 
-      if (! g_switch_set)	/* -G0 */
+      if (!global_options_set.x_g_switch_value)	/* -G0 */
 	{
-	  g_switch_set = 1;
 	  g_switch_value = 0;
 	}
     }
@@ -786,7 +780,7 @@ frv_option_override (void)
     }
 
   /* Check for small data option */
-  if (!g_switch_set)
+  if (!global_options_set.x_g_switch_value && !TARGET_LIBPIC)
     g_switch_value = SDATA_DEFAULT_SIZE;
 
   /* A C expression which defines the machine-dependent operand
@@ -9570,7 +9564,7 @@ frv_in_small_data_p (const_tree decl)
     }
 
   size = int_size_in_bytes (TREE_TYPE (decl));
-  if (size > 0 && (unsigned HOST_WIDE_INT) size <= g_switch_value)
+  if (size > 0 && size <= g_switch_value)
     return true;
 
   return false;
Index: gcc/config/m32r/m32r.c
===================================================================
--- gcc/config/m32r/m32r.c	(revision 164932)
+++ gcc/config/m32r/m32r.c	(working copy)
@@ -210,11 +210,6 @@ m32r_handle_option (size_t code, const c
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
     case OPT_m32r:
       target_flags &= ~(MASK_M32R2 | MASK_M32RX);
       return true;
@@ -270,7 +265,7 @@ m32r_init (void)
   m32r_punct_chars['@'] = 1; /* ??? no longer used */
 
   /* Provide default value if not specified.  */
-  if (!g_switch_set)
+  if (!global_options_set.x_g_switch_value)
     g_switch_value = SDATA_DEFAULT_SIZE;
 }
 
@@ -545,7 +540,7 @@ m32r_in_small_data_p (const_tree decl)
 	{
 	  int size = int_size_in_bytes (TREE_TYPE (decl));
 
-	  if (size > 0 && (unsigned HOST_WIDE_INT) size <= g_switch_value)
+	  if (size > 0 && size <= g_switch_value)
 	    return true;
 	}
     }
@@ -2106,7 +2101,7 @@ m32r_file_start (void)
 
   if (flag_verbose_asm)
     fprintf (asm_out_file,
-	     "%s M32R/D special options: -G " HOST_WIDE_INT_PRINT_UNSIGNED "\n",
+	     "%s M32R/D special options: -G %d\n",
 	     ASM_COMMENT_START, g_switch_value);
 
   if (TARGET_LITTLE_ENDIAN)
Index: gcc/config/m32r/m32r.h
===================================================================
--- gcc/config/m32r/m32r.h	(revision 164932)
+++ gcc/config/m32r/m32r.h	(working copy)
@@ -1227,7 +1227,8 @@ L2:     .word STATIC
   do									\
     {									\
       if (! TARGET_SDATA_NONE						\
-	  && (SIZE) > 0 && (SIZE) <= g_switch_value)			\
+	  && (SIZE) > 0							\
+	  && (SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value)		\
 	fprintf ((FILE), "%s", SCOMMON_ASM_OP);				\
       else								\
 	fprintf ((FILE), "%s", COMMON_ASM_OP);				\
@@ -1240,7 +1241,8 @@ L2:     .word STATIC
   do									\
     {									\
       if (! TARGET_SDATA_NONE						\
-          && (SIZE) > 0 && (SIZE) <= g_switch_value)			\
+          && (SIZE) > 0							\
+	  && (SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value)		\
         switch_to_section (get_named_section (NULL, ".sbss", 0));	\
       else								\
         switch_to_section (bss_section);				\
Index: gcc/config/microblaze/microblaze.c
===================================================================
--- gcc/config/microblaze/microblaze.c	(revision 164932)
+++ gcc/config/microblaze/microblaze.c	(working copy)
@@ -1279,11 +1279,6 @@ microblaze_handle_option (size_t code,
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
     case OPT_mno_clearbss:
       flag_zero_initialized_in_bss = 0;
       warning (0, "-mno-clearbss is deprecated; use -fno-zero-initialized-in-bss");
@@ -1304,8 +1299,9 @@ microblaze_option_override (void)
   register enum machine_mode mode;
   int ver;
 
-  microblaze_section_threshold =
-    g_switch_set ? g_switch_value : MICROBLAZE_DEFAULT_GVALUE;
+  microblaze_section_threshold = (global_options_set.x_g_switch_value
+				  ? g_switch_value
+				  : MICROBLAZE_DEFAULT_GVALUE);
 
   /* Check the MicroBlaze CPU version for any special action to be done.  */
   if (microblaze_select_cpu == NULL)
Index: gcc/config/lm32/lm32.h
===================================================================
--- gcc/config/lm32/lm32.h	(revision 164932)
+++ gcc/config/lm32/lm32.h	(working copy)
@@ -429,7 +429,7 @@ enum reg_class
 #undef  ASM_OUTPUT_ALIGNED_LOCAL
 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN)		\
 do {									\
-  if ((SIZE) <= g_switch_value)						\
+  if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value)		\
     switch_to_section (sbss_section);					\
   else									\
     switch_to_section (bss_section);					\
@@ -446,7 +446,7 @@ do {									\
 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)		\
 do 									\
 {									\
-  if ((SIZE) <= g_switch_value)						\
+  if ((SIZE) <= (unsigned HOST_WIDE_INT) g_switch_value)		\
     {									\
       switch_to_section (sbss_section);					\
       (*targetm.asm_out.globalize_label) (FILE, NAME);			\
Index: gcc/config/lm32/lm32.c
===================================================================
--- gcc/config/lm32/lm32.c	(revision 164932)
+++ gcc/config/lm32/lm32.c	(working copy)
@@ -75,11 +75,8 @@ static bool lm32_can_eliminate (const in
 static bool
 lm32_legitimate_address_p (enum machine_mode mode, rtx x, bool strict);
 static HOST_WIDE_INT lm32_compute_frame_size (int size);
-static bool lm32_handle_option (size_t code, const char *arg, int value);
 static void lm32_option_override (void);
 
-#undef TARGET_HANDLE_OPTION
-#define TARGET_HANDLE_OPTION lm32_handle_option
 #undef TARGET_OPTION_OVERRIDE
 #define TARGET_OPTION_OVERRIDE lm32_option_override
 #undef TARGET_ADDRESS_COST
@@ -698,23 +695,6 @@ lm32_setup_incoming_varargs (CUMULATIVE_
     }
 }
 
-/* Implement TARGET_HANDLE_OPTION.  */
-
-static bool
-lm32_handle_option (size_t code, const char *arg ATTRIBUTE_UNUSED, int value)
-{
-  switch (code)
-    {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
-    default:
-      return true;
-    }
-}
-
 /* Override command line options.  */
 static void
 lm32_option_override (void)
@@ -797,7 +777,7 @@ lm32_in_small_data_p (const_tree exp)
 
       /* If this is an incomplete type with size 0, then we can't put it
          in sdata because it might be too big when completed.  */
-      if (size > 0 && (unsigned HOST_WIDE_INT) size <= g_switch_value)
+      if (size > 0 && size <= g_switch_value)
 	return true;
     }
 
Index: gcc/config/g.opt
===================================================================
--- gcc/config/g.opt	(revision 164932)
+++ gcc/config/g.opt	(working copy)
@@ -24,7 +24,7 @@
 ; Please try to keep this file in ASCII collating order.
 
 G
-Target Joined Separate UInteger
+Target Joined Separate UInteger Var(g_switch_value)
 -G<number>	Put global and static data smaller than <number> bytes into a special section (on some targets)
 
 ; This comment is to ensure we retain the blank line above.
Index: gcc/config/ia64/ia64.c
===================================================================
--- gcc/config/ia64/ia64.c	(revision 164932)
+++ gcc/config/ia64/ia64.c	(working copy)
@@ -5566,11 +5566,6 @@ ia64_handle_option (size_t code, const c
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
     case OPT_mfixed_range_:
       fix_range (arg);
       return true;
@@ -5627,7 +5622,9 @@ ia64_option_override (void)
     flag_ira_loop_pressure = 1;
 
 
-  ia64_section_threshold = g_switch_set ? g_switch_value : IA64_DEFAULT_GVALUE;
+  ia64_section_threshold = (global_options_set.x_g_switch_value
+			    ? g_switch_value
+			    : IA64_DEFAULT_GVALUE);
 
   init_machine_status = ia64_init_machine_status;
 
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 164932)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -3996,11 +3996,6 @@ rs6000_handle_option (size_t code, const
 
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      break;
-
     case OPT_mno_power:
       target_flags &= ~(MASK_POWER | MASK_POWER2
 			| MASK_MULTIPLE | MASK_STRING);
@@ -4425,7 +4420,7 @@ rs6000_file_start (void)
 
       if (rs6000_sdata && g_switch_value)
 	{
-	  fprintf (file, "%s -G " HOST_WIDE_INT_PRINT_UNSIGNED, start,
+	  fprintf (file, "%s -G %d", start,
 		   g_switch_value);
 	  start = "";
 	}
@@ -5416,7 +5411,7 @@ small_data_operand (rtx op ATTRIBUTE_UNU
       /* We have to be careful here, because it is the referenced address
 	 that must be 32k from _SDA_BASE_, not just the symbol.  */
       summand = INTVAL (XEXP (sum, 1));
-      if (summand < 0 || (unsigned HOST_WIDE_INT) summand > g_switch_value)
+      if (summand < 0 || summand > g_switch_value)
 	return 0;
 
       sym_ref = XEXP (sum, 0);
@@ -24834,7 +24829,7 @@ rs6000_elf_in_small_data_p (const_tree d
       HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl));
 
       if (size > 0
-	  && (unsigned HOST_WIDE_INT) size <= g_switch_value
+	  && size <= g_switch_value
 	  /* If it's not public, and we're not going to reference it there,
 	     there's no need to put it in the small data section.  */
 	  && (rs6000_sdata != SDATA_DATA || TREE_PUBLIC (decl)))
Index: gcc/config/rs6000/vxworks.h
===================================================================
--- gcc/config/rs6000/vxworks.h	(revision 164932)
+++ gcc/config/rs6000/vxworks.h	(working copy)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler.  Vxworks PowerPC version.
-   Copyright (C) 1996, 2000, 2002, 2003, 2004, 2005, 2007, 2009
+   Copyright (C) 1996, 2000, 2002, 2003, 2004, 2005, 2007, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by CodeSourcery, LLC.
 
@@ -141,7 +141,7 @@ VXWORKS_ADDITIONAL_CPP_SPEC
 	rs6000_float_gprs = 1;			\
       }						\
 						\
-  if (!g_switch_set)				\
+  if (!global_options_set.x_g_switch_value)	\
     g_switch_value = SDATA_DEFAULT_SIZE;	\
   VXWORKS_OVERRIDE_OPTIONS;			\
   } while (0)
Index: gcc/config/rs6000/sysv4.h
===================================================================
--- gcc/config/rs6000/sysv4.h	(revision 164932)
+++ gcc/config/rs6000/sysv4.h	(working copy)
@@ -81,7 +81,7 @@ extern const char *rs6000_tls_size_strin
 
 #define SUBTARGET_OVERRIDE_OPTIONS					\
 do {									\
-  if (!g_switch_set)							\
+  if (!global_options_set.x_g_switch_value)				\
     g_switch_value = SDATA_DEFAULT_SIZE;				\
 									\
   if (rs6000_abi_name == NULL)						\
Index: gcc/config/score/score3.c
===================================================================
--- gcc/config/score/score3.c	(revision 164932)
+++ gcc/config/score/score3.c	(working copy)
@@ -641,11 +641,13 @@ score3_option_override (void)
 {
   flag_pic = false;
   if (!flag_pic)
-    score3_sdata_max = g_switch_set ? g_switch_value : SCORE3_DEFAULT_SDATA_MAX;
+    score3_sdata_max = (global_options_set.x_g_switch_value
+			? g_switch_value
+			: SCORE3_DEFAULT_SDATA_MAX);
   else
     {
       score3_sdata_max = 0;
-      if (g_switch_set && (g_switch_value != 0))
+      if (global_options_set.x_g_switch_value && (g_switch_value != 0))
         warning (0, "-fPIC and -G are incompatible");
     }
 
Index: gcc/config/score/score7.c
===================================================================
--- gcc/config/score/score7.c	(revision 164932)
+++ gcc/config/score/score7.c	(working copy)
@@ -640,11 +640,13 @@ score7_option_override (void)
 {
   flag_pic = false;
   if (!flag_pic)
-    score7_sdata_max = g_switch_set ? g_switch_value : SCORE7_DEFAULT_SDATA_MAX;
+    score7_sdata_max = (global_options_set.x_g_switch_value
+			? g_switch_value
+			: SCORE7_DEFAULT_SDATA_MAX);
   else
     {
       score7_sdata_max = 0;
-      if (g_switch_set && (g_switch_value != 0))
+      if (global_options_set.x_g_switch_value && (g_switch_value != 0))
         warning (0, "-fPIC and -G are incompatible");
     }
 
Index: gcc/config/score/score.c
===================================================================
--- gcc/config/score/score.c	(revision 164932)
+++ gcc/config/score/score.c	(working copy)
@@ -295,11 +295,6 @@ score_handle_option (size_t code, const 
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
     case OPT_mscore7d:
       target_flags &= ~(MASK_ALL_CPU_BITS);
       target_flags |= MASK_SCORE7 | MASK_SCORE7D;
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	(revision 164932)
+++ gcc/config/mips/mips.c	(working copy)
@@ -15442,11 +15442,6 @@ mips_handle_option (size_t code, const c
 {
   switch (code)
     {
-    case OPT_G:
-      g_switch_value = value;
-      g_switch_set = true;
-      return true;
-
     case OPT_mabi_:
       if (strcmp (arg, "32") == 0)
 	mips_abi = ABI_32;
@@ -15527,7 +15522,7 @@ mips_option_override (void)
     TARGET_INTERLINK_MIPS16 = 1;
 
   /* Set the small data limit.  */
-  mips_small_data_threshold = (g_switch_set
+  mips_small_data_threshold = (global_options_set.x_g_switch_value
 			       ? g_switch_value
 			       : MIPS_DEFAULT_GVALUE);
 
