diff options
author | Nick Clifton <nickc@redhat.com> | 2004-05-21 15:38:04 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2004-05-21 15:38:04 +0000 |
commit | 2d643429defea3c00819c1d9a288d424ad76a825 (patch) | |
tree | 8be2842d14c593c384ec38d66ae86902a6316e6e /bfd | |
parent | 8377c19cc4edbdbb66f30996bd0400ff9ec1562a (diff) | |
download | fsf-binutils-gdb-2d643429defea3c00819c1d9a288d424ad76a825.zip fsf-binutils-gdb-2d643429defea3c00819c1d9a288d424ad76a825.tar.gz fsf-binutils-gdb-2d643429defea3c00819c1d9a288d424ad76a825.tar.bz2 |
Add --hash-size switch to the linker
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 12 | ||||
-rw-r--r-- | bfd/Makefile.am | 2 | ||||
-rw-r--r-- | bfd/Makefile.in | 2 | ||||
-rw-r--r-- | bfd/bfd-in.h | 5 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 5 | ||||
-rw-r--r-- | bfd/hash.c | 55 |
6 files changed, 64 insertions, 17 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 56dbeeb..824a23c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2004-05-21 Andy Chittenden <achittenden@bluearc.com> + + * hash.c (bfd_default_hash_table_size): New variable. + (bfd_hash_table_init): Use new variable instead of DEFAULT_SIZE. + (bfd_hash_set_default_size): New function. Set the default size + to a selected prime number close to the argument. Document new + function. + * bfd-in.h: Add prototype for bfd_hash_set_default_size. + * bfd-in2.h: Regenerate. + * Makefile.am (hash.lo): Add dependency upon libiberty.h. + * Makefile.in: Regenerate. + 2004-05-21 Mark Kettenis <kettenis@gnu.org> * libaout.h (machine_type): Add M_88K_OPENBSD and M_HPPA_OPENBSD. diff --git a/bfd/Makefile.am b/bfd/Makefile.am index c395d32..29abed0 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -894,7 +894,7 @@ syms.lo: syms.c $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \ $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def targets.lo: targets.c $(INCDIR)/filenames.h $(INCDIR)/fnmatch.h \ targmatch.h -hash.lo: hash.c $(INCDIR)/filenames.h $(INCDIR)/objalloc.h +hash.lo: hash.c $(INCDIR)/filenames.h $(INCDIR)/objalloc.h $(INCDIR)/libiberty.h linker.lo: linker.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ genlink.h srec.lo: srec.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 4d4d784..8ee31d2 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -1431,7 +1431,7 @@ syms.lo: syms.c $(INCDIR)/filenames.h $(INCDIR)/safe-ctype.h \ $(INCDIR)/bfdlink.h $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def targets.lo: targets.c $(INCDIR)/filenames.h $(INCDIR)/fnmatch.h \ targmatch.h -hash.lo: hash.c $(INCDIR)/filenames.h $(INCDIR)/objalloc.h +hash.lo: hash.c $(INCDIR)/filenames.h $(INCDIR)/objalloc.h $(INCDIR)/libiberty.h linker.lo: linker.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ genlink.h srec.lo: srec.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index a3330e8..e7ed04a 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -433,6 +433,11 @@ extern void bfd_hash_traverse bfd_boolean (*) (struct bfd_hash_entry *, void *), void *info); +/* 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); + #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table /* User program access to BFD facilities. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 3f38b6a..1336f36 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -440,6 +440,11 @@ extern void bfd_hash_traverse bfd_boolean (*) (struct bfd_hash_entry *, void *), void *info); +/* 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); + #define COFF_SWAP_TABLE (void *) &bfd_coff_std_swap_table /* User program access to BFD facilities. */ @@ -1,28 +1,29 @@ /* hash.c -- hash table routines for BFD - Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003 + Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" #include "libbfd.h" #include "objalloc.h" +#include "libiberty.h" /* SECTION @@ -53,6 +54,7 @@ SECTION @* Looking Up or Entering a String:: @* Traversing a Hash Table:: @* Deriving a New Hash Table Type:: +@* Changing the default Hash Table Size:: @end menu INODE @@ -87,6 +89,10 @@ SUBSECTION been allocated for a hash table. This will not free up the <<struct bfd_hash_table>> itself, which you must provide. +@findex bfd_hash_set_default_size + Use <<bfd_hash_set_default_size>> to set the default size of + hash table to use. + INODE Looking Up or Entering a String, Traversing a Hash Table, Creating and Freeing a Hash Table, Hash Tables SUBSECTION @@ -295,7 +301,8 @@ SUBSUBSECTION */ /* The default number of entries to use when creating a hash table. */ -#define DEFAULT_SIZE (4051) +#define DEFAULT_SIZE 4051 +static size_t bfd_default_hash_table_size = DEFAULT_SIZE; /* Create a new hash table, given a number of entries. */ @@ -339,7 +346,7 @@ bfd_hash_table_init (table, newfunc) struct bfd_hash_table *, const char *)); { - return bfd_hash_table_init_n (table, newfunc, DEFAULT_SIZE); + return bfd_hash_table_init_n (table, newfunc, bfd_default_hash_table_size); } /* Free a hash table. */ @@ -495,6 +502,24 @@ bfd_hash_traverse (table, func, info) } } +void +bfd_hash_set_default_size (bfd_size_type hash_size) +{ + int index; + /* Extend this prime list if you want more granularity of hash table size. */ + static bfd_size_type hash_size_primes[] = + { + 1021, 4051, 8599, 16699 + }; + + /* Work out best prime number near the hash_size. */ + for (index = 0; index < ARRAY_SIZE (hash_size_primes) - 1; ++index) + if (hash_size <= hash_size_primes[index]) + break; + + bfd_default_hash_table_size = hash_size_primes[index]; +} + /* A few different object file formats (a.out, COFF, ELF) use a string table. These functions support adding strings to a string table, returning the byte offset, and writing out the table. |