This is the mail archive of the binutils@sources.redhat.com 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]

Re: [RFA:] bfd/elf-strtab.c: make i unsigned long to work aroundbug in egcs-1.1.2


On Sun, 11 Nov 2001, Alan Modra wrote:
> unsigned long is fine (Hmm, I suppose
> size_t is slightly more correct).

My doh.  Of course size_t.  It's even used elsewhere in that
file, so it must be fine as in needing no new includes or
autoconf stuff.

This is what I checked in:

	* elf-strtab.c (_bfd_elf_strtab_finalize): Make first variable i
	size_t.  Rename second i to j.

Index: elf-strtab.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-strtab.c,v
retrieving revision 1.1
diff -p -c -r1.1 elf-strtab.c
*** elf-strtab.c	2001/11/07 16:50:36	1.1
--- elf-strtab.c	2001/11/11 22:09:46
*************** _bfd_elf_strtab_finalize (tab)
*** 349,356 ****
  {
    struct elf_strtab_hash_entry **array, **a, **end, *e;
    htab_t lasttab = NULL, last4tab = NULL;
!   bfd_size_type size, amt, i;

    /* Now sort the strings by length, longest first.  */
    array = NULL;
    amt = tab->size * sizeof (struct elf_strtab_hash_entry *);
--- 349,362 ----
  {
    struct elf_strtab_hash_entry **array, **a, **end, *e;
    htab_t lasttab = NULL, last4tab = NULL;
!   bfd_size_type size, amt;

+   /* GCC 2.91.66 (egcs-1.1.2) on i386 miscompiles this function when i is
+      a 64-bit bfd_size_type: a 64-bit target or --enable-64-bit-bfd.
+      Besides, indexing with a long long wouldn't give anything but extra
+      cycles.  */
+   size_t i;
+
    /* Now sort the strings by length, longest first.  */
    array = NULL;
    amt = tab->size * sizeof (struct elf_strtab_hash_entry *);
*************** _bfd_elf_strtab_finalize (tab)
*** 380,386 ****
      {
        register hashval_t hash;
        unsigned int c;
!       unsigned int i;
        const unsigned char *s;
        PTR *p;

--- 386,392 ----
      {
        register hashval_t hash;
        unsigned int c;
!       unsigned int j;
        const unsigned char *s;
        PTR *p;

*************** _bfd_elf_strtab_finalize (tab)
*** 389,395 ****
  	{
  	  s = e->root.string + e->len - 1;
  	  hash = 0;
! 	  for (i = 0; i < 4; i++)
  	    {
  	      c = *--s;
  	      hash += c + (c << 17);
--- 395,401 ----
  	{
  	  s = e->root.string + e->len - 1;
  	  hash = 0;
! 	  for (j = 0; j < 4; j++)
  	    {
  	      c = *--s;
  	      hash += c + (c << 17);

brgds, H-P



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