[RFC] allow -G to take a range

DJ Delorie dj@redhat.com
Fri Jun 13 21:58:00 GMT 2003


Ok, I'm working on some ideas for optimizing the use of .sdata, for
cases where it's overflowing in a given application.  Here's the first
one - allow the user to further limit the types of things that get put
into .sdata.  This is untested, as I wanted to get some feedback about
how well received this would be before putting the time into testing.

The idea here is that gcc will accept either "-Gn" or "-Gm-n", where
m is the minimum (defaults to zero for compatibility) and n is the
maximum.  Thus, one could specify "-G 4-4" to allow *only* 4-byte
objects in .sdata, under the assumption that 1-byte and 2-byte objects
are either not speed critical or cause wasted space in .sdata due to
the alignment filler.

Comments?

Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.221
diff -p -2 -r1.221  bfd/bfd-in2.h
*** bfd/bfd-in2.h	12 Jun 2003 07:23:30 -0000	1.221
--- bfd/bfd-in2.h	13 Jun 2003 21:54:19 -0000
*************** unsigned int
*** 3927,3932 ****
--- 3927,3938 ----
  bfd_get_gp_size PARAMS ((bfd *abfd));
  
+ unsigned int
+ bfd_get_gp_min_size PARAMS ((bfd *abfd));
+ 
  void
  bfd_set_gp_size PARAMS ((bfd *abfd, unsigned int i));
+ 
+ void
+ bfd_set_gp_min_size PARAMS ((bfd *abfd, unsigned int i));
  
  bfd_vma
Index: bfd/bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.49
diff -p -2 -r1.49  bfd/bfd.c
*** bfd/bfd.c	17 May 2003 00:41:45 -0000	1.49
--- bfd/bfd.c	13 Jun 2003 21:54:19 -0000
*************** bfd_get_gp_size (abfd)
*** 861,864 ****
--- 861,891 ----
  /*
  FUNCTION
+ 	bfd_get_gp_min_size
+ 
+ SYNOPSIS
+ 	unsigned int bfd_get_gp_min_size (bfd *abfd);
+ 
+ DESCRIPTION
+ 	Return the minimum size of objects to be optimized using the GP
+ 	register under MIPS ECOFF.  This is typically set by the <<-G>>
+ 	argument to the compiler, assembler or linker.
+ */
+ 
+ unsigned int
+ bfd_get_gp_min_size (abfd)
+      bfd *abfd;
+ {
+   if (abfd->format == bfd_object)
+     {
+       if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+ 	return ecoff_data (abfd)->gp_min_size;
+       else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+ 	return elf_gp_min_size (abfd);
+     }
+   return 0;
+ }
+ 
+ /*
+ FUNCTION
  	bfd_set_gp_size
  
*************** bfd_set_gp_size (abfd, i)
*** 885,888 ****
--- 912,946 ----
    else if (abfd->xvec->flavour == bfd_target_elf_flavour)
      elf_gp_size (abfd) = i;
+ }
+ 
+ /*
+ FUNCTION
+ 	bfd_set_gp_min_size
+ 
+ SYNOPSIS
+ 	void bfd_set_gp_min_size (bfd *abfd, unsigned int i);
+ 
+ DESCRIPTION
+ 	Set the minimum size of objects to be optimized using the GP
+ 	register under ECOFF or MIPS ELF.  This is typically set by
+ 	the <<-G>> argument to the compiler, assembler or linker.
+ */
+ 
+ void
+ bfd_set_gp_min_size (abfd, i)
+      bfd *abfd;
+      unsigned int i;
+ {
+   /* Don't try to set GP size on an archive or core file!  */
+   if (abfd->format != bfd_object)
+     return;
+ 
+   if (i < 1)
+     i = 1;
+ 
+   if (abfd->xvec->flavour == bfd_target_ecoff_flavour)
+     ecoff_data (abfd)->gp_min_size = i;
+   else if (abfd->xvec->flavour == bfd_target_elf_flavour)
+     elf_gp_min_size (abfd) = i;
  }
  
Index: bfd/ecoff.c
===================================================================
RCS file: /cvs/src/src/bfd/ecoff.c,v
retrieving revision 1.25
diff -p -2 -r1.25  bfd/ecoff.c
*** bfd/ecoff.c	8 Jun 2003 14:06:38 -0000	1.25
--- bfd/ecoff.c	13 Jun 2003 21:54:20 -0000
*************** _bfd_ecoff_mkobject_hook (abfd, filehdr,
*** 141,144 ****
--- 141,145 ----
    ecoff = ecoff_data (abfd);
    ecoff->gp_size = 8;
+   ecoff->gp_min_size = 1;
    ecoff->sym_filepos = internal_f->f_symptr;
  
*************** ecoff_set_symbol_info (abfd, ecoff_sym, 
*** 797,801 ****
        break;
      case scCommon:
!       if (asym->value > ecoff_data (abfd)->gp_size)
  	{
  	  asym->section = bfd_com_section_ptr;
--- 798,803 ----
        break;
      case scCommon:
!       if (asym->value > ecoff_data (abfd)->gp_size
! 	  || asym->value < ecoff_data (abfd)->gp_min_size)
  	{
  	  asym->section = bfd_com_section_ptr;
*************** ecoff_link_add_externals (abfd, info, ex
*** 3954,3958 ****
  	  break;
  	case scCommon:
! 	  if (value > ecoff_data (abfd)->gp_size)
  	    {
  	      section = bfd_com_section_ptr;
--- 3956,3961 ----
  	  break;
  	case scCommon:
! 	  if (value > ecoff_data (abfd)->gp_size
! 	      || value < ecoff_data (abfd)->gp_min_size)
  	    {
  	      section = bfd_com_section_ptr;
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.98
diff -p -2 -r1.98  bfd/elf-bfd.h
*** bfd/elf-bfd.h	3 Jun 2003 22:27:22 -0000	1.98
--- bfd/elf-bfd.h	13 Jun 2003 21:54:20 -0000
*************** struct elf_obj_tdata
*** 1160,1163 ****
--- 1160,1164 ----
    bfd_vma gp;				/* The gp value */
    unsigned int gp_size;			/* The gp size */
+   unsigned int gp_min_size;		/* The gp minimum size */
  
    Elf_Internal_Shdr **group_sect_ptr;
*************** struct elf_obj_tdata
*** 1294,1297 ****
--- 1295,1299 ----
  #define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
  #define elf_gp_size(bfd)	(elf_tdata(bfd) -> gp_size)
+ #define elf_gp_min_size(bfd)	(elf_tdata(bfd) -> gp_min_size)
  #define elf_sym_hashes(bfd)	(elf_tdata(bfd) -> sym_hashes)
  #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
Index: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.5
diff -p -2 -r1.5  bfd/elf32-frv.c
*** bfd/elf32-frv.c	30 Nov 2002 08:39:37 -0000	1.5
--- bfd/elf32-frv.c	13 Jun 2003 21:54:20 -0000
*************** elf32_frv_add_symbol_hook (abfd, info, s
*** 909,913 ****
    if (sym->st_shndx == SHN_COMMON
        && !info->relocateable
!       && (int)sym->st_size <= (int)bfd_get_gp_size (abfd))
      {
        /* Common symbols less than or equal to -G nn bytes are
--- 909,914 ----
    if (sym->st_shndx == SHN_COMMON
        && !info->relocateable
!       && (int)sym->st_size <= (int)bfd_get_gp_size (abfd)
!       && (int)sym->st_size >= (int)bfd_get_gp_min_size (abfd))
      {
        /* Common symbols less than or equal to -G nn bytes are
Index: bfd/elf32-i370.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i370.c,v
retrieving revision 1.26
diff -p -2 -r1.26  bfd/elf32-i370.c
*** bfd/elf32-i370.c	30 Nov 2002 08:39:37 -0000	1.26
--- bfd/elf32-i370.c	13 Jun 2003 21:54:20 -0000
*************** i370_elf_adjust_dynamic_symbol (info, h)
*** 633,637 ****
       only if there were actually SDAREL relocs for that symbol.  */
  
!   if (h->size <= elf_gp_size (dynobj))
      s = bfd_get_section_by_name (dynobj, ".dynsbss");
    else
--- 633,638 ----
       only if there were actually SDAREL relocs for that symbol.  */
  
!   if (h->size <= elf_gp_size (dynobj)
!       && h->size >= elf_gp_min_size (dynobj))
      s = bfd_get_section_by_name (dynobj, ".dynsbss");
    else
*************** i370_elf_adjust_dynamic_symbol (info, h)
*** 647,651 ****
        asection *srel;
  
!       if (h->size <= elf_gp_size (dynobj))
  	srel = bfd_get_section_by_name (dynobj, ".rela.sbss");
        else
--- 648,653 ----
        asection *srel;
  
!       if (h->size <= elf_gp_size (dynobj)
! 	  && h->size >= elf_gp_min_size (dynobj))
  	srel = bfd_get_section_by_name (dynobj, ".rela.sbss");
        else
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.83
diff -p -2 -r1.83  bfd/elf32-ppc.c
*** bfd/elf32-ppc.c	31 May 2003 07:55:10 -0000	1.83
--- bfd/elf32-ppc.c	13 Jun 2003 21:54:21 -0000
*************** ppc_elf_adjust_dynamic_symbol (info, h)
*** 2583,2587 ****
       only if there were actually SDAREL relocs for that symbol.  */
  
!   if (h->size <= elf_gp_size (htab->elf.dynobj))
      s = htab->dynsbss;
    else
--- 2583,2588 ----
       only if there were actually SDAREL relocs for that symbol.  */
  
!   if (h->size <= elf_gp_size (htab->elf.dynobj)
!       && h->size >= elf_gp_min_size (htab->elf.dynobj))
      s = htab->dynsbss;
    else
*************** ppc_elf_adjust_dynamic_symbol (info, h)
*** 2597,2601 ****
        asection *srel;
  
!       if (h->size <= elf_gp_size (htab->elf.dynobj))
  	srel = htab->relsbss;
        else
--- 2598,2603 ----
        asection *srel;
  
!       if (h->size <= elf_gp_size (htab->elf.dynobj)
! 	  && h->size >= elf_gp_min_size (htab->elf.dynobj))
  	srel = htab->relsbss;
        else
*************** ppc_elf_add_symbol_hook (abfd, info, sym
*** 4028,4031 ****
--- 4030,4034 ----
        && !info->relocateable
        && sym->st_size <= elf_gp_size (abfd)
+       && sym->st_size >= elf_gp_min_size (abfd)
        && info->hash->creator->flavour == bfd_target_elf_flavour)
      {
*************** ppc_elf_finish_dynamic_symbol (output_bf
*** 4153,4157 ****
        BFD_ASSERT (h->dynindx != -1);
  
!       if (h->size <= elf_gp_size (htab->elf.dynobj))
  	s = htab->relsbss;
        else
--- 4156,4161 ----
        BFD_ASSERT (h->dynindx != -1);
  
!       if (h->size <= elf_gp_size (htab->elf.dynobj)
! 	  && h->size >= elf_gp_min_size (htab->elf.dynobj))
  	s = htab->relsbss;
        else
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.99
diff -p -2 -r1.99  bfd/elf64-alpha.c
*** bfd/elf64-alpha.c	30 May 2003 15:50:11 -0000	1.99
--- bfd/elf64-alpha.c	13 Jun 2003 21:54:22 -0000
*************** elf64_alpha_add_symbol_hook (abfd, info,
*** 2467,2471 ****
    if (sym->st_shndx == SHN_COMMON
        && !info->relocateable
!       && sym->st_size <= elf_gp_size (abfd))
      {
        /* Common symbols less than or equal to -G nn bytes are
--- 2467,2472 ----
    if (sym->st_shndx == SHN_COMMON
        && !info->relocateable
!       && sym->st_size <= elf_gp_size (abfd)
!       && sym->st_size >= elf_gp_min_size (abfd))
      {
        /* Common symbols less than or equal to -G nn bytes are
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.83
diff -p -2 -r1.83  bfd/elfxx-ia64.c
*** bfd/elfxx-ia64.c	30 May 2003 15:50:10 -0000	1.83
--- bfd/elfxx-ia64.c	13 Jun 2003 21:54:22 -0000
*************** elfNN_ia64_add_symbol_hook (abfd, info, 
*** 1343,1347 ****
    if (sym->st_shndx == SHN_COMMON
        && !info->relocateable
!       && sym->st_size <= elf_gp_size (abfd))
      {
        /* Common symbols less than or equal to -G nn bytes are
--- 1343,1348 ----
    if (sym->st_shndx == SHN_COMMON
        && !info->relocateable
!       && sym->st_size <= elf_gp_size (abfd)
!       && sym->st_size >= elf_gp_min_size (abfd))
      {
        /* Common symbols less than or equal to -G nn bytes are
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.59
diff -p -2 -r1.59  bfd/elfxx-mips.c
*** bfd/elfxx-mips.c	11 Jun 2003 21:01:48 -0000	1.59
--- bfd/elfxx-mips.c	13 Jun 2003 21:54:24 -0000
*************** _bfd_mips_elf_symbol_processing (abfd, a
*** 4194,4197 ****
--- 4194,4198 ----
  	 treated as SHN_MIPS_SCOMMON symbols on IRIX5.  */
        if (asym->value > elf_gp_size (abfd)
+ 	  || asym->value < elf_gp_min_size (abfd)
  	  || IRIX_COMPAT (abfd) == ict_irix6)
  	break;
*************** _bfd_mips_elf_add_symbol_hook (abfd, inf
*** 4721,4724 ****
--- 4722,4726 ----
  	 treated as SHN_MIPS_SCOMMON symbols.  */
        if (sym->st_size > elf_gp_size (abfd)
+ 	  || sym->st_size < elf_gp_min_size (abfd)
  	  || IRIX_COMPAT (abfd) == ict_irix6)
  	break;
Index: bfd/libecoff.h
===================================================================
RCS file: /cvs/src/src/bfd/libecoff.h,v
retrieving revision 1.12
diff -p -2 -r1.12  bfd/libecoff.h
*** bfd/libecoff.h	30 Nov 2002 08:39:39 -0000	1.12
--- bfd/libecoff.h	13 Jun 2003 21:54:24 -0000
*************** typedef struct ecoff_tdata
*** 103,106 ****
--- 103,107 ----
       linker.  */
    unsigned int gp_size;
+   unsigned int gp_min_size;
  
    /* The register masks.  When linking, all the masks found in the
Index: gas/ecoff.c
===================================================================
RCS file: /cvs/src/src/gas/ecoff.c,v
retrieving revision 1.15
diff -p -2 -r1.15  gas/ecoff.c
*** gas/ecoff.c	27 Aug 2002 11:09:42 -0000	1.15
--- gas/ecoff.c	13 Jun 2003 21:54:25 -0000
*************** ecoff_frob_symbol (sym)
*** 3615,3618 ****
--- 3615,3619 ----
    if (S_IS_COMMON (sym)
        && S_GET_VALUE (sym) > 0
+       && S_GET_VALUE (sym) >= bfd_get_gp_min_size (stdoutput)
        && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
      {
*************** ecoff_build_symbols (backend, buf, bufen
*** 4080,4083 ****
--- 4081,4085 ----
  			      s = symbol_get_obj (as_sym)->ecoff_extern_size;
  			      if (s == 0
+ 				  || s < bfd_get_gp_min_size (stdoutput)
  				  || s > bfd_get_gp_size (stdoutput))
  				sc = sc_Undefined;
*************** ecoff_build_symbols (backend, buf, bufen
*** 4094,4097 ****
--- 4096,4101 ----
  			    {
  			      if (S_GET_VALUE (as_sym) > 0
+ 				  && (S_GET_VALUE (as_sym)
+ 				      >= bfd_get_gp_min_size (stdoutput))
  				  && (S_GET_VALUE (as_sym)
  				      <= bfd_get_gp_size (stdoutput)))
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.64
diff -p -2 -r1.64  gas/read.c
*** gas/read.c	11 Jun 2003 23:16:57 -0000	1.64
--- gas/read.c	13 Jun 2003 21:54:25 -0000
*************** s_lcomm_internal (needs_align, bytes_p)
*** 2006,2010 ****
      {
        /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss.  */
!       if ((unsigned) temp <= bfd_get_gp_size (stdoutput))
  	{
  	  bss_seg = subseg_new (".sbss", 1);
--- 2006,2011 ----
      {
        /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss.  */
!       if ((unsigned) temp <= bfd_get_gp_size (stdoutput)
! 	  && (unsigned) temp >= bfd_get_gp_min_size (stdoutput))
  	{
  	  bss_seg = subseg_new (".sbss", 1);
Index: gas/config/tc-alpha.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-alpha.c,v
retrieving revision 1.58
diff -p -2 -r1.58  gas/config/tc-alpha.c
*** gas/config/tc-alpha.c	5 Jun 2003 03:27:03 -0000	1.58
--- gas/config/tc-alpha.c	13 Jun 2003 21:54:26 -0000
*************** static int alpha_flag_relax;
*** 452,455 ****
--- 452,456 ----
  /* What value to give to bfd_set_gp_size.  */
  static int g_switch_value = 8;
+ static int g_switch_min_value = 1;
  
  #ifdef OBJ_EVAX
*************** md_begin ()
*** 889,892 ****
--- 890,894 ----
    /* So .sbss will get used for tiny objects.  */
    bfd_set_gp_size (stdoutput, g_switch_value);
+   bfd_set_gp_min_size (stdoutput, g_switch_min_value);
  
  #ifdef OBJ_ECOFF
*************** md_parse_option (c, arg)
*** 1053,1057 ****
  
      case 'G':
!       g_switch_value = atoi (arg);
        break;
  
--- 1055,1062 ----
  
      case 'G':
!       if (strchr (arg+1, '-'))
! 	sscanf ("%u-%u", &g_switch_min_value, &g_switch_value);
!       else
! 	g_switch_value = atoi (arg);
        break;
  
Index: gas/config/tc-frv.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-frv.c,v
retrieving revision 1.7
diff -p -2 -r1.7  gas/config/tc-frv.c
*** gas/config/tc-frv.c	21 May 2003 12:07:55 -0000	1.7
--- gas/config/tc-frv.c	13 Jun 2003 21:54:26 -0000
*************** size_t md_longopts_size = sizeof (md_lon
*** 245,248 ****
--- 245,249 ----
  /* What value to give to bfd_set_gp_size.  */
  static int g_switch_value = 8;
+ static int g_switch_min_value = 1;
  
  int
*************** md_parse_option (c, arg)
*** 257,261 ****
  
      case 'G':
!       g_switch_value = atoi (arg);
        if (! g_switch_value)
  	frv_flags |= EF_FRV_G0;
--- 258,265 ----
  
      case 'G':
!       if (strchr (arg+1, '-'))
! 	sscanf ("%u-%u", &g_switch_min_value, &g_switch_value);
!       else
! 	g_switch_value = atoi (arg);
        if (! g_switch_value)
  	frv_flags |= EF_FRV_G0;
*************** md_parse_option (c, arg)
*** 393,396 ****
--- 397,401 ----
        frv_pic_flag = "-mlibrary-pic";
        g_switch_value = 0;
+       g_switch_min_value = 0;
        break;
  
*************** md_begin ()
*** 459,462 ****
--- 464,468 ----
    /* Set up gp size so we can put local common items in .sbss */
    bfd_set_gp_size (stdoutput, g_switch_value);
+   bfd_set_gp_min_size (stdoutput, g_switch_min_value);
  
    frv_vliw_reset (& vliw, frv_mach, frv_flags);
Index: gas/config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.216
diff -p -2 -r1.216  gas/config/tc-mips.c
*** gas/config/tc-mips.c	12 Jun 2003 05:45:50 -0000	1.216
--- gas/config/tc-mips.c	13 Jun 2003 21:54:28 -0000
*************** static int mips_7000_hilo_fix;
*** 383,386 ****
--- 383,387 ----
  /* The size of the small data section.  */
  static unsigned int g_switch_value = 8;
+ static unsigned int g_switch_min_value = 1;
  /* Whether the -G option was used.  */
  static int g_switch_seen = 0;
*************** md_begin ()
*** 1302,1306 ****
  
    if (USE_GLOBAL_POINTER_OPT)
!     bfd_set_gp_size (stdoutput, g_switch_value);
  
    if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
--- 1303,1310 ----
  
    if (USE_GLOBAL_POINTER_OPT)
!     {
!       bfd_set_gp_size (stdoutput, g_switch_value);
!       bfd_set_gp_min_size (stdoutput, g_switch_min_value);
!     }
  
    if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
*************** md_parse_option (c, arg)
*** 10992,10995 ****
--- 10996,11000 ----
  	}
        g_switch_value = 0x7fffffff;
+       g_switch_min_value = 1;
        break;
  
*************** md_parse_option (c, arg)
*** 11028,11031 ****
--- 11033,11037 ----
  	}
        g_switch_value = 0;
+       g_switch_min_value = 0;
        break;
  
*************** md_parse_option (c, arg)
*** 11059,11062 ****
--- 11065,11070 ----
  	  return 0;
  	}
+       else if (strchr (arg+1, '-'))
+ 	sscanf ("%u-%u", &g_switch_min_value, &g_switch_value);
        else
  	g_switch_value = atoi (arg);
*************** mips_after_parse_args ()
*** 11208,11211 ****
--- 11216,11220 ----
  	as_bad (_("-G not supported in this configuration."));
        g_switch_value = 0;
+       g_switch_min_value = 0;
      }
  
*************** s_option (x)
*** 12353,12357 ****
--- 12362,12368 ----
  	    as_warn (_("-G may not be used with SVR4 PIC code"));
  	  g_switch_value = 0;
+ 	  g_switch_min_value = 0;
  	  bfd_set_gp_size (stdoutput, 0);
+ 	  bfd_set_gp_min_size (stdoutput, 0);
  	}
      }
*************** s_abicalls (ignore)
*** 12574,12579 ****
--- 12585,12592 ----
  	as_warn (_("-G may not be used with SVR4 PIC code"));
        g_switch_value = 0;
+       g_switch_min_value = 0;
      }
    bfd_set_gp_size (stdoutput, 0);
+   bfd_set_gp_min_size (stdoutput, 0);
    demand_empty_rest_of_line ();
  }
*************** nopic_need_relax (sym, before_relaxing)
*** 13177,13181 ****
  		   || (symbol_get_obj (sym)->ecoff_extern_size != 0
  		       && (symbol_get_obj (sym)->ecoff_extern_size
! 			   <= g_switch_value))
  #endif
  		   /* We must defer this decision until after the whole
--- 13190,13196 ----
  		   || (symbol_get_obj (sym)->ecoff_extern_size != 0
  		       && (symbol_get_obj (sym)->ecoff_extern_size
! 			   <= g_switch_value)
! 		       && (symbol_get_obj (sym)->ecoff_extern_size
! 			   >= g_switch_min_value))
  #endif
  		   /* We must defer this decision until after the whole
*************** nopic_need_relax (sym, before_relaxing)
*** 13188,13191 ****
--- 13203,13207 ----
  		       && S_GET_VALUE (sym) == 0)
  		   || (S_GET_VALUE (sym) != 0
+ 		       && S_GET_VALUE (sym) >= g_switch_min_value
  		       && S_GET_VALUE (sym) <= g_switch_value)))
  	change = 0;
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.113
diff -p -2 -r1.113  ld/ldlang.c
*** ld/ldlang.c	9 May 2003 16:12:07 -0000	1.113
--- ld/ldlang.c	13 Jun 2003 21:54:28 -0000
*************** open_output (name)
*** 1950,1953 ****
--- 1950,1954 ----
  
    bfd_set_gp_size (output, g_switch_value);
+   bfd_set_gp_min_size (output, g_switch_min_value);
    return output;
  }
*************** ldlang_add_file (entry)
*** 4081,4084 ****
--- 4082,4086 ----
    entry->the_bfd->usrdata = (PTR) entry;
    bfd_set_gp_size (entry->the_bfd, g_switch_value);
+   bfd_set_gp_min_size (entry->the_bfd, g_switch_min_value);
  
    /* Look through the sections and check for any which should not be
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.70
diff -p -2 -r1.70  ld/ldmain.c
*** ld/ldmain.c	30 May 2003 15:50:11 -0000	1.70
--- ld/ldmain.c	13 Jun 2003 21:54:28 -0000
*************** bfd *output_bfd = 0;
*** 82,85 ****
--- 82,86 ----
  /* Set by -G argument, for MIPS ECOFF target.  */
  int g_switch_value = 8;
+ int g_switch_min_value = 1;
  
  /* Nonzero means print names of input files as processed.  */
Index: ld/ldmain.h
===================================================================
RCS file: /cvs/src/src/ld/ldmain.h,v
retrieving revision 1.6
diff -p -2 -r1.6  ld/ldmain.h
*** ld/ldmain.h	7 May 2003 04:14:57 -0000	1.6
--- ld/ldmain.h	13 Jun 2003 21:54:28 -0000
*************** extern bfd_boolean whole_archive;
*** 35,38 ****
--- 35,39 ----
  extern bfd_boolean demangling;
  extern int g_switch_value;
+ extern int g_switch_min_value;
  extern const char *output_filename;
  extern struct bfd_link_info link_info;
Index: ld/lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.63
diff -p -2 -r1.63  ld/lexsup.c
*** ld/lexsup.c	30 May 2003 15:50:11 -0000	1.63
--- ld/lexsup.c	13 Jun 2003 21:54:29 -0000
*************** parse_args (argc, argv)
*** 745,748 ****
--- 745,753 ----
  	    char *end;
  	    g_switch_value = strtoul (optarg, &end, 0);
+ 	    if (*end == '-')
+ 	      {
+ 		g_switch_min_value = g_switch_value;
+ 		g_switch_value = strtoul (end+1, &end, 0);
+ 	      }
  	    if (*end)
  	      einfo (_("%P%F: invalid number `%s'\n"), optarg);



More information about the Binutils mailing list