This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[VMS] Remove symbols hash in bfd/vms-alpha.c


Hello,

as the length of symbols on Alpha VMS is limited to 64 characters,
there is code in vms-alpha.c to hash and truncate symbols that exceed
this limit.

However this code duplicates a similar mechanism in gas, so better to
simply remove it.

Tested by rebuilding binutils for alpha-openvms

Committed to trunk.

Tristan.

bfd/
2013-07-09  Tristan Gingold  <gingold@adacore.com>

	* vms-alpha.c (struct vms_private_data_struct): Remove
	flag_hash_long_names and flag_show_after_trunc.
	(hash_string): Remove.
	(_bfd_vms_length_hash_symbol): Remove.
	(alpha_vms_write_exec): Remove call to _bfd_vms_length_hash_symbol.
	(_bfd_vms_write_egsd): Likewise.  Rewrite condition.
	(_bfd_vms_write_ehdr): Remove code that set removed flags.
	(_bfd_vms_write_etir): Remove call to _bfd_vms_length_hash_symbol.
	(vms_bfd_is_local_label_name): Remove trace call.


Index: vms-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-alpha.c,v
retrieving revision 1.56
diff -c -r1.56 vms-alpha.c
*** vms-alpha.c	2 Jul 2013 09:42:25 -0000	1.56
--- vms-alpha.c	9 Jul 2013 10:11:12 -0000
***************
*** 330,339 ****
  
    /* linkage index counter used by conditional store commands */
    unsigned int vms_linkage_index;
- 
-   /* see tc-alpha.c of gas for a description.  */
-   int flag_hash_long_names;	/* -+, hash instead of truncate */
-   int flag_show_after_trunc;	/* -H, show hashing/truncation */
  };
  
  #define PRIV2(abfd, name) \
--- 330,335 ----
***************
*** 2685,2772 ****
    return TRUE;
  }
  
- /* This hash routine borrowed from GNU-EMACS, and strengthened
-    slightly.  ERY.  */
- 
- static int
- hash_string (const char *ptr)
- {
-   const unsigned char *p = (unsigned char *) ptr;
-   const unsigned char *end = p + strlen (ptr);
-   unsigned char c;
-   int hash = 0;
- 
-   while (p != end)
-     {
-       c = *p++;
-       hash = ((hash << 3) + (hash << 15) + (hash >> 28) + c);
-     }
-   return hash;
- }
- 
- /* Generate a length-hashed VMS symbol name (limited to maxlen chars).  */
- 
- static char *
- _bfd_vms_length_hash_symbol (bfd *abfd, const char *in, int maxlen)
- {
-   unsigned long result;
-   int in_len;
-   char *new_name;
-   const char *old_name;
-   int i;
-   static char outbuf[EOBJ__C_SYMSIZ + 1];
-   char *out = outbuf;
- 
- #if VMS_DEBUG
-   vms_debug (4, "_bfd_vms_length_hash_symbol \"%s\"\n", in);
- #endif
- 
-   if (maxlen > EOBJ__C_SYMSIZ)
-     maxlen = EOBJ__C_SYMSIZ;
- 
-   /* Save this for later.  */
-   new_name = out;
- 
-   /* We may need to truncate the symbol, save the hash for later.  */
-   in_len = strlen (in);
- 
-   result = (in_len > maxlen) ? hash_string (in) : 0;
- 
-   old_name = in;
- 
-   /* Do the length checking.  */
-   if (in_len <= maxlen)
-     i = in_len;
-   else
-     {
-       if (PRIV (flag_hash_long_names))
- 	i = maxlen - 9;
-       else
- 	i = maxlen;
-     }
- 
-   strncpy (out, in, (size_t) i);
-   in += i;
-   out += i;
- 
-   if ((in_len > maxlen)
-       && PRIV (flag_hash_long_names))
-     sprintf (out, "_%08lx", result);
-   else
-     *out = 0;
- 
- #if VMS_DEBUG
-   vms_debug (4, "--> [%d]\"%s\"\n", (int)strlen (outbuf), outbuf);
- #endif
- 
-   if (in_len > maxlen
- 	&& PRIV (flag_hash_long_names)
- 	&& PRIV (flag_show_after_trunc))
-     printf (_("Symbol %s replaced by %s\n"), old_name, new_name);
- 
-   return outbuf;
- }
- 
  static void
  vector_grow1 (struct vector_type *vec, size_t elsz)
  {
--- 2681,2686 ----
***************
*** 3240,3246 ****
        for (i = 0; i < PRIV (gsd_sym_count); i++)
          {
            struct vms_symbol_entry *sym = PRIV (syms)[i];
-           char *hash;
            bfd_vma val;
            bfd_vma ep;
  
--- 3154,3159 ----
***************
*** 3267,3274 ****
  	  _bfd_vms_output_quad (recwr, ep);
  	  _bfd_vms_output_quad (recwr, val);
  	  _bfd_vms_output_long (recwr, 0);
!           hash = _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ__C_SYMSIZ);
!           _bfd_vms_output_counted (recwr, hash);
            _bfd_vms_output_end_subrec (recwr);
            if ((i % 5) == 4)
              _bfd_vms_output_end (abfd, recwr);
--- 3180,3186 ----
  	  _bfd_vms_output_quad (recwr, ep);
  	  _bfd_vms_output_quad (recwr, val);
  	  _bfd_vms_output_long (recwr, 0);
!           _bfd_vms_output_counted (recwr, sym->name);
            _bfd_vms_output_end_subrec (recwr);
            if ((i % 5) == 4)
              _bfd_vms_output_end (abfd, recwr);
***************
*** 3363,3370 ****
  	  else if ((*sname == 'l') && (strcmp (sname, "lcomm") == 0))
  	    sname = EVAX_LOCAL_NAME;
  	}
-       else
- 	sname = _bfd_vms_length_hash_symbol (abfd, sname, EOBJ__C_SECSIZ);
  
        if (bfd_is_com_section (section))
  	new_flags = (EGPS__V_OVR | EGPS__V_REL | EGPS__V_GBL | EGPS__V_RD
--- 3275,3280 ----
***************
*** 3404,3421 ****
  
    for (symnum = 0; symnum < abfd->symcount; symnum++)
      {
-       char *hash;
- 
        symbol = abfd->outsymbols[symnum];
        old_flags = symbol->flags;
  
        /* Work-around a missing feature:  consider __main as the main entry
           point.  */
!       if (*(symbol->name) == '_')
! 	{
! 	  if (strcmp (symbol->name, "__main") == 0)
! 	    bfd_set_start_address (abfd, (bfd_vma)symbol->value);
! 	}
  
        /* Only put in the GSD the global and the undefined symbols.  */
        if (old_flags & BSF_FILE)
--- 3314,3326 ----
  
    for (symnum = 0; symnum < abfd->symcount; symnum++)
      {
        symbol = abfd->outsymbols[symnum];
        old_flags = symbol->flags;
  
        /* Work-around a missing feature:  consider __main as the main entry
           point.  */
!       if (symbol->name[0] == '_' && strcmp (symbol->name, "__main") == 0)
! 	bfd_set_start_address (abfd, (bfd_vma)symbol->value);
  
        /* Only put in the GSD the global and the undefined symbols.  */
        if (old_flags & BSF_FILE)
***************
*** 3508,3515 ****
  	  _bfd_vms_output_long (recwr, ca_psindx);
  	  _bfd_vms_output_long (recwr, psindx);
  	}
!       hash = _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ__C_SYMSIZ);
!       _bfd_vms_output_counted (recwr, hash);
  
        _bfd_vms_output_end_subrec (recwr);
      }
--- 3413,3419 ----
  	  _bfd_vms_output_long (recwr, ca_psindx);
  	  _bfd_vms_output_long (recwr, psindx);
  	}
!       _bfd_vms_output_counted (recwr, symbol->name);
  
        _bfd_vms_output_end_subrec (recwr);
      }
***************
*** 3527,3534 ****
  {
    asymbol *symbol;
    unsigned int symnum;
-   int had_case = 0;
-   int had_file = 0;
    struct vms_rec_wr *recwr = &PRIV (recwr);
  
    vms_debug2 ((2, "vms_write_ehdr (%p)\n", abfd));
--- 3431,3436 ----
***************
*** 3548,3569 ****
  
        if (symbol->flags & BSF_FILE)
  	{
- 	  if (CONST_STRNEQ ((char *)symbol->name, "<CASE:"))
- 	    {
- 	      PRIV (flag_hash_long_names) = symbol->name[6] - '0';
- 	      PRIV (flag_show_after_trunc) = symbol->name[7] - '0';
- 
- 	      if (had_file)
- 		break;
- 	      had_case = 1;
- 	      continue;
- 	    }
- 
  	  _bfd_vms_output_dump (recwr, (unsigned char *) symbol->name,
  				(int) strlen (symbol->name));
! 	  if (had_case)
! 	    break;
! 	  had_file = 1;
  	}
      }
  
--- 3450,3458 ----
  
        if (symbol->flags & BSF_FILE)
  	{
  	  _bfd_vms_output_dump (recwr, (unsigned char *) symbol->name,
  				(int) strlen (symbol->name));
! 	  break;
  	}
      }
  
***************
*** 3799,3805 ****
  	      asection *sec = sym->section;
  	      bfd_boolean defer = defer_reloc_p (rptr);
  	      unsigned int slen;
- 	      char *hash;
  
  	      if (pass2_in_progress)
  		{
--- 3688,3693 ----
***************
*** 3838,3850 ****
  		    {
  		      bfd_vma addend = rptr->addend;
  		      slen = strlen ((char *) sym->name);
- 		      hash = _bfd_vms_length_hash_symbol
-                         (abfd, sym->name, EOBJ__C_SYMSIZ);
  		      etir_output_check (abfd, section, curr_addr, slen);
  		      if (addend)
  			{
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
! 			  _bfd_vms_output_counted (recwr, hash);
  			  _bfd_vms_output_end_subrec (recwr);
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
  			  _bfd_vms_output_long (recwr, (unsigned long) addend);
--- 3726,3736 ----
  		    {
  		      bfd_vma addend = rptr->addend;
  		      slen = strlen ((char *) sym->name);
  		      etir_output_check (abfd, section, curr_addr, slen);
  		      if (addend)
  			{
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
! 			  _bfd_vms_output_counted (recwr, sym->name);
  			  _bfd_vms_output_end_subrec (recwr);
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_LW);
  			  _bfd_vms_output_long (recwr, (unsigned long) addend);
***************
*** 3858,3864 ****
  			{
  			  _bfd_vms_output_begin_subrec
                              (recwr, ETIR__C_STO_GBL_LW);
! 			  _bfd_vms_output_counted (recwr, hash);
  			  _bfd_vms_output_end_subrec (recwr);
  			}
  		    }
--- 3744,3750 ----
  			{
  			  _bfd_vms_output_begin_subrec
                              (recwr, ETIR__C_STO_GBL_LW);
! 			  _bfd_vms_output_counted (recwr, sym->name);
  			  _bfd_vms_output_end_subrec (recwr);
  			}
  		    }
***************
*** 3893,3905 ****
  		    {
  		      bfd_vma addend = rptr->addend;
  		      slen = strlen ((char *) sym->name);
- 		      hash = _bfd_vms_length_hash_symbol
-                         (abfd, sym->name, EOBJ__C_SYMSIZ);
  		      etir_output_check (abfd, section, curr_addr, slen);
  		      if (addend)
  			{
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
! 			  _bfd_vms_output_counted (recwr, hash);
  			  _bfd_vms_output_end_subrec (recwr);
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_QW);
  			  _bfd_vms_output_quad (recwr, addend);
--- 3779,3789 ----
  		    {
  		      bfd_vma addend = rptr->addend;
  		      slen = strlen ((char *) sym->name);
  		      etir_output_check (abfd, section, curr_addr, slen);
  		      if (addend)
  			{
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_GBL);
! 			  _bfd_vms_output_counted (recwr, sym->name);
  			  _bfd_vms_output_end_subrec (recwr);
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STA_QW);
  			  _bfd_vms_output_quad (recwr, addend);
***************
*** 3912,3918 ****
  		      else
  			{
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_GBL);
! 			  _bfd_vms_output_counted (recwr, hash);
  			  _bfd_vms_output_end_subrec (recwr);
  			}
  		    }
--- 3796,3802 ----
  		      else
  			{
  			  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_GBL);
! 			  _bfd_vms_output_counted (recwr, sym->name);
  			  _bfd_vms_output_end_subrec (recwr);
  			}
  		    }
***************
*** 3949,3968 ****
  		    (recwr, (unsigned long) rptr->addend);
                    if (rptr->addend > PRIV (vms_linkage_index))
                      PRIV (vms_linkage_index) = rptr->addend;
! 		  hash = _bfd_vms_length_hash_symbol
!                     (abfd, sym->name, EOBJ__C_SYMSIZ);
! 		  _bfd_vms_output_counted (recwr, hash);
  		  _bfd_vms_output_byte (recwr, 0);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
  		case ALPHA_R_CODEADDR:
  		  slen = strlen ((char *) sym->name);
- 		  hash = _bfd_vms_length_hash_symbol
-                     (abfd, sym->name, EOBJ__C_SYMSIZ);
  		  etir_output_check (abfd, section, curr_addr, slen);
  		  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_CA);
! 		  _bfd_vms_output_counted (recwr, hash);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
--- 3833,3848 ----
  		    (recwr, (unsigned long) rptr->addend);
                    if (rptr->addend > PRIV (vms_linkage_index))
                      PRIV (vms_linkage_index) = rptr->addend;
! 		  _bfd_vms_output_counted (recwr, sym->name);
  		  _bfd_vms_output_byte (recwr, 0);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
  		case ALPHA_R_CODEADDR:
  		  slen = strlen ((char *) sym->name);
  		  etir_output_check (abfd, section, curr_addr, slen);
  		  _bfd_vms_output_begin_subrec (recwr, ETIR__C_STO_CA);
! 		  _bfd_vms_output_counted (recwr, sym->name);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
***************
*** 3980,3988 ****
  		  _bfd_vms_output_long
  		    (recwr, (unsigned long) section->target_index);
  		  _bfd_vms_output_quad (recwr, rptr->addend);
! 		  _bfd_vms_output_counted
! 		    (recwr, _bfd_vms_length_hash_symbol
!                      (abfd, udata->origname, EOBJ__C_SYMSIZ));
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
--- 3860,3866 ----
  		  _bfd_vms_output_long
  		    (recwr, (unsigned long) section->target_index);
  		  _bfd_vms_output_quad (recwr, rptr->addend);
! 		  _bfd_vms_output_counted (recwr, udata->origname);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
***************
*** 4005,4013 ****
  		  _bfd_vms_output_long
  		    (recwr, (unsigned long) udata->bsym->section->target_index);
  		  _bfd_vms_output_quad (recwr, rptr->addend);
! 		  _bfd_vms_output_counted
! 		    (recwr, _bfd_vms_length_hash_symbol
!                      (abfd, udata->origname, EOBJ__C_SYMSIZ));
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
--- 3883,3889 ----
  		  _bfd_vms_output_long
  		    (recwr, (unsigned long) udata->bsym->section->target_index);
  		  _bfd_vms_output_quad (recwr, rptr->addend);
! 		  _bfd_vms_output_counted (recwr, udata->origname);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
***************
*** 4025,4033 ****
  		  _bfd_vms_output_long
  		    (recwr, (unsigned long) section->target_index);
  		  _bfd_vms_output_quad (recwr, rptr->addend);
! 		  _bfd_vms_output_counted
! 		    (recwr, _bfd_vms_length_hash_symbol
!                      (abfd, udata->origname, EOBJ__C_SYMSIZ));
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
--- 3901,3907 ----
  		  _bfd_vms_output_long
  		    (recwr, (unsigned long) section->target_index);
  		  _bfd_vms_output_quad (recwr, rptr->addend);
! 		  _bfd_vms_output_counted (recwr, udata->origname);
  		  _bfd_vms_output_end_subrec (recwr);
  		  break;
  
***************
*** 9248,9254 ****
  vms_bfd_is_local_label_name (bfd * abfd ATTRIBUTE_UNUSED,
  			     const char *name)
  {
-   vms_debug2 ((1, "vms_bfd_is_local_label_name (%p, %s)\n", abfd, name));
    return name[0] == '$';
  }
  

--- 9122,9127 ----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]