diff options
author | Alan Modra <amodra@gmail.com> | 2011-04-20 12:52:16 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2011-04-20 12:52:16 +0000 |
commit | 8ad17b3a2ce2deb3b6fe599924747a93da5a6a65 (patch) | |
tree | 03f4fbe6b24b1676abbec5eefb15ec8ff4c7ab7d | |
parent | 7bca32d788b5b06024cf34f01ae6bef16751e5ca (diff) | |
download | binutils-gdb-8ad17b3a2ce2deb3b6fe599924747a93da5a6a65.tar.gz |
bfd/
* hash.c (bfd_default_hash_table_size): Make it an unsigned long.
(bfd_hash_table_init_n): Overflow checking.
(bfd_hash_set_default_size): Return current size. Take unsigned long
arg. Add 65537 to hash_size primes.
* bfd-in.h (bfd_hash_set_default_size): Update prototype.
* bfd-in2.h: Regenerate.
gas/
* hash.c (set_gas_hash_table_size): Use bfd_hash_set_default_size.
(hash_new_sized): New function, split out from..
(hash_new): ..here.
ld/
* ld.h (ld_config_type <hash_table_size>): Make it an unsigned long.
-rw-r--r-- | bfd/ChangeLog | 9 | ||||
-rw-r--r-- | bfd/bfd-in.h | 2 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 2 | ||||
-rw-r--r-- | bfd/hash.c | 25 | ||||
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/hash.c | 38 | ||||
-rw-r--r-- | ld/ChangeLog | 4 | ||||
-rw-r--r-- | ld/ld.h | 2 |
8 files changed, 48 insertions, 40 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index fec3d20fe1c..4c9d8c2743d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2011-04-20 Alan Modra <amodra@gmail.com> + + * hash.c (bfd_default_hash_table_size): Make it an unsigned long. + (bfd_hash_table_init_n): Overflow checking. + (bfd_hash_set_default_size): Return current size. Take unsigned long + arg. Add 65537 to hash_size primes. + * bfd-in.h (bfd_hash_set_default_size): Update prototype. + * bfd-in2.h: Regenerate. + 2011-04-20 Jan Kratochvil <jan.kratochvil@redhat.com> * elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Fix +1 overrun of diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 5f0f4b53425..d5368977912 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -432,7 +432,7 @@ extern void bfd_hash_traverse /* Allows the default size of a hash table to be configured. New hash tables allocated using bfd_hash_table_init will be created with this size. */ -extern void bfd_hash_set_default_size (bfd_size_type); +extern unsigned long bfd_hash_set_default_size (unsigned long); /* This structure is used to keep track of stabs in sections information while linking. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 2c795b6cbbd..76836b15c82 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -439,7 +439,7 @@ extern void bfd_hash_traverse /* Allows the default size of a hash table to be configured. New hash tables allocated using bfd_hash_table_init will be created with this size. */ -extern void bfd_hash_set_default_size (bfd_size_type); +extern unsigned long bfd_hash_set_default_size (unsigned long); /* This structure is used to keep track of stabs in sections information while linking. */ diff --git a/bfd/hash.c b/bfd/hash.c index e2fa3a91385..7147b71a851 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, 2010 Free Software Foundation, Inc. + 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> This file is part of BFD, the Binary File Descriptor library. @@ -352,7 +352,7 @@ higher_prime_number (unsigned long n) return *low; } -static size_t bfd_default_hash_table_size = DEFAULT_SIZE; +static unsigned long bfd_default_hash_table_size = DEFAULT_SIZE; /* Create a new hash table, given a number of entries. */ @@ -364,9 +364,15 @@ bfd_hash_table_init_n (struct bfd_hash_table *table, unsigned int entsize, unsigned int size) { - unsigned int alloc; + unsigned long alloc; - alloc = size * sizeof (struct bfd_hash_entry *); + alloc = size; + alloc *= sizeof (struct bfd_hash_entry *); + if (alloc / sizeof (struct bfd_hash_entry *) != size) + { + bfd_set_error (bfd_error_no_memory); + return FALSE; + } table->memory = (void *) objalloc_create (); if (table->memory == NULL) @@ -645,15 +651,15 @@ bfd_hash_traverse (struct bfd_hash_table *table, table->frozen = 0; } -void -bfd_hash_set_default_size (bfd_size_type hash_size) +unsigned long +bfd_hash_set_default_size (unsigned long hash_size) { /* Extend this prime list if you want more granularity of hash table size. */ - static const bfd_size_type hash_size_primes[] = + static const unsigned long hash_size_primes[] = { - 251, 509, 1021, 2039, 4051, 8599, 16699, 32749 + 251, 509, 1021, 2039, 4051, 8599, 16699, 32749, 65537 }; - size_t _index; + unsigned int _index; /* Work out best prime number near the hash_size. */ for (_index = 0; _index < ARRAY_SIZE (hash_size_primes) - 1; ++_index) @@ -661,6 +667,7 @@ bfd_hash_set_default_size (bfd_size_type hash_size) break; bfd_default_hash_table_size = hash_size_primes[_index]; + return bfd_default_hash_table_size; } /* A few different object file formats (a.out, COFF, ELF) use a string diff --git a/gas/ChangeLog b/gas/ChangeLog index 0cc109afc2f..6a21ff321ff 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2011-04-20 Alan Modra <amodra@gmail.com> + + * hash.c (set_gas_hash_table_size): Use bfd_hash_set_default_size. + (hash_new_sized): New function, split out from.. + (hash_new): ..here. + 2011-04-19 Nick Clifton <nickc@redhat.com> * config/tc-arm.c (v7m_psrs): Revert previous delta. diff --git a/gas/hash.c b/gas/hash.c index 6fc8543a90d..a58c9489b6a 100644 --- a/gas/hash.c +++ b/gas/hash.c @@ -1,6 +1,6 @@ /* hash.c -- gas hash table code Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, - 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009 + 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -78,41 +78,17 @@ static unsigned long gas_hash_table_size = 65537; void set_gas_hash_table_size (unsigned long size) { - gas_hash_table_size = size; -} - -/* FIXME: This function should be amalgmated with bfd/hash.c:bfd_hash_set_default_size(). */ -static unsigned long -get_gas_hash_table_size (void) -{ - /* Extend this prime list if you want more granularity of hash table size. */ - static const unsigned long hash_size_primes[] = - { - 1021, 4051, 8599, 16699, 65537 - }; - unsigned int hindex; - - /* Work out the best prime number near the hash_size. - FIXME: This could be a more sophisticated algorithm, - but is it really worth implementing it ? */ - for (hindex = 0; hindex < ARRAY_SIZE (hash_size_primes) - 1; ++ hindex) - if (gas_hash_table_size <= hash_size_primes[hindex]) - break; - - return hash_size_primes[hindex]; + gas_hash_table_size = bfd_hash_set_default_size (size); } /* Create a hash table. This return a control block. */ -struct hash_control * -hash_new (void) +static struct hash_control * +hash_new_sized (unsigned long size) { - unsigned long size; unsigned long alloc; struct hash_control *ret; - size = get_gas_hash_table_size (); - ret = (struct hash_control *) xmalloc (sizeof *ret); obstack_begin (&ret->memory, chunksize); alloc = size * sizeof (struct hash_entry *); @@ -132,6 +108,12 @@ hash_new (void) return ret; } +struct hash_control * +hash_new (void) +{ + return hash_new_sized (gas_hash_table_size); +} + /* Delete a hash table, freeing all allocated memory. */ void diff --git a/ld/ChangeLog b/ld/ChangeLog index 31acf598cb6..ce511ac2c2e 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,9 @@ 2011-04-20 Alan Modra <amodra@gmail.com> + * ld.h (ld_config_type <hash_table_size>): Make it an unsigned long. + +2011-04-20 Alan Modra <amodra@gmail.com> + PR ld/12365 * ldfile.c (ldfile_try_open_bfd): Move code creating and switching to plugin IR BFD.. @@ -308,7 +308,7 @@ typedef struct { bfd_size_type specified_data_size; /* The size of the hash table to use. */ - bfd_size_type hash_table_size; + unsigned long hash_table_size; /* The maximum page size for ELF. */ bfd_vma maxpagesize; |