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]
Other format: [Raw text]

Re: just a little nitpik in bfd


Hi H.J.

> If you believe you didn't introduce any new bugs, check it in. I
> will fix the testcases if necessary. I know it can be quite tricky.

Well there were 6 new failures in all (vers 6 & 15, ELF weak data
first, last, first common & last common) which I felt were too many
to ignore.

If you like though, try applying this patch and then see if you can
fix up the failures.  I would love to know why changing the hashing
algorithm is affecting the tests though.  I would have thought that
the algorithm was completely hidden inside BFD.

Cheers
        Nick

*** /sources/sourceware/bfd/hash.c	Mon May 20 13:56:16 2002
--- tmp/hash.c.new	Mon May 20 12:53:28 2002
*************** bfd_hash_lookup (table, string, create, 
*** 365,384 ****
    register unsigned long hash;
    register unsigned int c;
    struct bfd_hash_entry *hashp;
-   unsigned int len;
    unsigned int index;
  
    hash = 0;
-   len = 0;
    s = (const unsigned char *) string;
!   while ((c = *s++) != '\0')
!     {
!       hash += c + (c << 17);
!       hash ^= hash >> 2;
!     }
!   len = (s - (const unsigned char *) string) - 1;
!   hash += len + (len << 17);
!   hash ^= hash >> 2;
  
    index = hash % table->size;
    for (hashp = table->table[index];
--- 365,379 ----
    register unsigned long hash;
    register unsigned int c;
    struct bfd_hash_entry *hashp;
    unsigned int index;
  
    hash = 0;
    s = (const unsigned char *) string;
! 
!   /* Hashing function stolen from libiberty/hashtab.c:htab_hash_string()
!      which should be pretty good for hashing identifiers.  */
!   while ((c = *s++) != 0)
!     hash = hash * 67 + c - 113;
  
    index = hash % table->size;
    for (hashp = table->table[index];
*************** bfd_hash_lookup (table, string, create, 
*** 401,407 ****
        char *new;
  
        new = (char *) objalloc_alloc ((struct objalloc *) table->memory,
! 				     len + 1);
        if (!new)
  	{
  	  bfd_set_error (bfd_error_no_memory);
--- 396,402 ----
        char *new;
  
        new = (char *) objalloc_alloc ((struct objalloc *) table->memory,
! 				     s - (const unsigned char *) string);
        if (!new)
  	{
  	  bfd_set_error (bfd_error_no_memory);


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