diff options
author | Alan Modra <amodra@bigpond.net.au> | 2010-11-08 02:48:53 +0000 |
---|---|---|
committer | Alan Modra <amodra@bigpond.net.au> | 2010-11-08 02:48:53 +0000 |
commit | 7230711e31ddbf07c57cbb2f6fa365ef1ea5fca1 (patch) | |
tree | d48072fc2788ed4b3b3bd39b00ea4d17026119a8 /bfd/hash.c | |
parent | 110f62ff8cdaafe1f62d4ccf87acbf9ec54ec8c1 (diff) | |
download | gdb-7230711e31ddbf07c57cbb2f6fa365ef1ea5fca1.tar.gz |
bfd/
* hash.c (bfd_hash_hash): Extract from..
(bfd_hash_lookup): ..here.
(bfd_hash_rename): New function.
* section.c (bfd_rename_section): New function.
* bfd-in.h (bfd_hash_rename): Declare.
* bfd-in2.h: Regenerate.
* elf.c (_bfd_elf_make_section_from_shdr): Rename input sections
when compressing or decompressing. Don't assert name match.
* elf64-hppa.c (get_reloc_section): Don't assert name match.
* elfxx-ia64.c (get_reloc_section): Likewise.
binutils/
* objcopy.c (copy_main): No need to rename sections when compressing
or decompressing.
binutils/testsuite/
* binutils-all/objdump.W: Adjust expected result for debug section
rename.
Diffstat (limited to 'bfd/hash.c')
-rw-r--r-- | bfd/hash.c | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/bfd/hash.c b/bfd/hash.c index fc05923a5ca..e2fa3a91385 100644 --- a/bfd/hash.c +++ b/bfd/hash.c @@ -1,6 +1,6 @@ /* hash.c -- hash table routines for BFD Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2009 Free Software Foundation, Inc. + 2006, 2007, 2009, 2010 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> This file is part of BFD, the Binary File Descriptor library. @@ -412,20 +412,13 @@ bfd_hash_table_free (struct bfd_hash_table *table) table->memory = NULL; } -/* Look up a string in a hash table. */ - -struct bfd_hash_entry * -bfd_hash_lookup (struct bfd_hash_table *table, - const char *string, - bfd_boolean create, - bfd_boolean copy) +static inline unsigned long +bfd_hash_hash (const char *string, unsigned int *lenp) { const unsigned char *s; unsigned long hash; - unsigned int c; - struct bfd_hash_entry *hashp; unsigned int len; - unsigned int _index; + unsigned int c; hash = 0; len = 0; @@ -438,7 +431,25 @@ bfd_hash_lookup (struct bfd_hash_table *table, len = (s - (const unsigned char *) string) - 1; hash += len + (len << 17); hash ^= hash >> 2; + if (lenp != NULL) + *lenp = len; + return hash; +} + +/* Look up a string in a hash table. */ +struct bfd_hash_entry * +bfd_hash_lookup (struct bfd_hash_table *table, + const char *string, + bfd_boolean create, + bfd_boolean copy) +{ + unsigned long hash; + struct bfd_hash_entry *hashp; + unsigned int len; + unsigned int _index; + + hash = bfd_hash_hash (string, &len); _index = hash % table->size; for (hashp = table->table[_index]; hashp != NULL; @@ -535,6 +546,31 @@ bfd_hash_insert (struct bfd_hash_table *table, return hashp; } +/* Rename an entry in a hash table. */ + +void +bfd_hash_rename (struct bfd_hash_table *table, + const char *string, + struct bfd_hash_entry *ent) +{ + unsigned int _index; + struct bfd_hash_entry **pph; + + _index = ent->hash % table->size; + for (pph = &table->table[_index]; *pph != NULL; pph = &(*pph)->next) + if (*pph == ent) + break; + if (*pph == NULL) + abort (); + + *pph = ent->next; + ent->string = string; + ent->hash = bfd_hash_hash (string, NULL); + _index = ent->hash % table->size; + ent->next = table->table[_index]; + table->table[_index] = ent; +} + /* Replace an entry in a hash table. */ void |