PR 2434
authorAlan Modra <amodra@gmail.com>
Thu, 16 Mar 2006 12:20:16 +0000 (12:20 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 16 Mar 2006 12:20:16 +0000 (12:20 +0000)
bfd/
* elflink.c (struct elf_smash_syms_data, elf_smash_syms): Delete.
(elf_link_add_object_symbols): Delete unnecessary locals.  Rename
hash_table -> htab.  Formatting.  Save entire symbol table
before loading as-needed syms, and restore afterwards if lib not
needed.  Use bfd_hash_allocate rather than bfd_alloc for sym
name.  Free some buffers earlier.
* bfd-in.h (struct bfd_hash_table): Add entsize.
(bfd_hash_table_init, bfd_hash_table_init_n): Adjust prototype.
* elf-bfd.h (_bfd_elf_link_hash_table_init): Likewise
* hash.c (bfd_hash_table_init_n): Add entsize param, save to
hash table.
(bfd_hash_table_init): Add param, adjust calls.
* aoutx.h: Adjust all hash_table_init functions and calls.
* bfd.c: Likewise.
* coff-arm.c: Likewise.
* coff-h8300.c: Likewise.
* coff-ppc.c: Likewise.
* cofflink.c: Likewise.
* ecoff.c: Likewise.
* ecofflink.c: Likewise.
* elf-m10300.c: Likewise.
* elf-strtab.c: Likewise.
* elf.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-cris.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-sh.c: Likewise.
* elf32-vax.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elf64-sh64.c: Likewise.
* elf64-x86-64.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* elfxx-sparc.c: Likewise.
* i386linux.c: Likewise.
* libaout.h: Likewise.
* libbfd-in.h: Likewise.
* libcoff-in.h: Likewise.
* linker.c: Likewise.
* m68klinux.c: Likewise.
* merge.c: Likewise.
* opncls.c: Likewise.
* pdp11.c: Likewise.
* sparclinux.c: Likewise.
* stabs.c: Likewise.
* sunos.c: Likewise.
* vms.c: Likewise.
* xcofflink.c: Likewise.
* section.c (struct section_hash_entry): Move to..
* libbfd-in.h: ..here.
* Makefile.am: Run "make dep-am"
* Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* libcoff.h: Regenerate.
binutils/
* ieee.c (write_ieee_debugging_info): Adjust bfd_hash_table_init calls.
* wrstabs.c (write_stabs_in_sections_debugging_info): Likewise.
ld/
* ldcref.c (add_cref): Adjust bfd_hash_table_init calls.
* ldlang.c (output_statement_table_init, lang_init): Likewise.
* ldmain.c (add_ysym, add_wrap, add_keepsyms_file): Likewise.
(undefined_symbol): Likewise.

65 files changed:
bfd/ChangeLog
bfd/Makefile.am
bfd/Makefile.in
bfd/aoutx.h
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c
bfd/coff-arm.c
bfd/coff-h8300.c
bfd/coff-ppc.c
bfd/cofflink.c
bfd/ecoff.c
bfd/ecofflink.c
bfd/elf-bfd.h
bfd/elf-m10300.c
bfd/elf-strtab.c
bfd/elf.c
bfd/elf32-arm.c
bfd/elf32-bfin.c
bfd/elf32-cris.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-i386.c
bfd/elf32-m32r.c
bfd/elf32-m68hc1x.c
bfd/elf32-m68k.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-vax.c
bfd/elf64-alpha.c
bfd/elf64-hppa.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfxx-ia64.c
bfd/elfxx-mips.c
bfd/elfxx-sparc.c
bfd/hash.c
bfd/i386linux.c
bfd/libaout.h
bfd/libbfd-in.h
bfd/libbfd.h
bfd/libcoff-in.h
bfd/libcoff.h
bfd/linker.c
bfd/m68klinux.c
bfd/merge.c
bfd/opncls.c
bfd/pdp11.c
bfd/section.c
bfd/sparclinux.c
bfd/stabs.c
bfd/sunos.c
bfd/vms.c
bfd/xcofflink.c
binutils/ChangeLog
binutils/ieee.c
binutils/wrstabs.c
ld/ChangeLog
ld/ldcref.c
ld/ldlang.c
ld/ldmain.c

index 5c8f5c01540a23c5e93cb56dcb68161b149738f4..9171cead2d0473477bd2eea5d2a07e39e19257ff 100644 (file)
@@ -1,3 +1,73 @@
+2006-03-16  Alan Modra  <amodra@bigpond.net.au>
+
+       PR 2434
+       * elflink.c (struct elf_smash_syms_data, elf_smash_syms): Delete.
+       (elf_link_add_object_symbols): Delete unnecessary locals.  Rename
+       hash_table -> htab.  Formatting.  Save entire symbol table
+       before loading as-needed syms, and restore afterwards if lib not
+       needed.  Use bfd_hash_allocate rather than bfd_alloc for sym
+       name.  Free some buffers earlier.
+       * bfd-in.h (struct bfd_hash_table): Add entsize.
+       (bfd_hash_table_init, bfd_hash_table_init_n): Adjust prototype.
+       * elf-bfd.h (_bfd_elf_link_hash_table_init): Likewise
+       * hash.c (bfd_hash_table_init_n): Add entsize param, save to
+       hash table.
+       (bfd_hash_table_init): Add param, adjust calls.
+       * aoutx.h: Adjust all hash_table_init functions and calls.
+       * bfd.c: Likewise.
+       * coff-arm.c: Likewise.
+       * coff-h8300.c: Likewise.
+       * coff-ppc.c: Likewise.
+       * cofflink.c: Likewise.
+       * ecoff.c: Likewise.
+       * ecofflink.c: Likewise.
+       * elf-m10300.c: Likewise.
+       * elf-strtab.c: Likewise.
+       * elf.c: Likewise.
+       * elf32-arm.c: Likewise.
+       * elf32-bfin.c: Likewise.
+       * elf32-cris.c: Likewise.
+       * elf32-frv.c: Likewise.
+       * elf32-hppa.c: Likewise.
+       * elf32-i386.c: Likewise.
+       * elf32-m32r.c: Likewise.
+       * elf32-m68hc1x.c: Likewise.
+       * elf32-m68k.c: Likewise.
+       * elf32-ppc.c: Likewise.
+       * elf32-s390.c: Likewise.
+       * elf32-sh.c: Likewise.
+       * elf32-vax.c: Likewise.
+       * elf64-alpha.c: Likewise.
+       * elf64-hppa.c: Likewise.
+       * elf64-ppc.c: Likewise.
+       * elf64-s390.c: Likewise.
+       * elf64-sh64.c: Likewise.
+       * elf64-x86-64.c: Likewise.
+       * elfxx-ia64.c: Likewise.
+       * elfxx-mips.c: Likewise.
+       * elfxx-sparc.c: Likewise.
+       * i386linux.c: Likewise.
+       * libaout.h: Likewise.
+       * libbfd-in.h: Likewise.
+       * libcoff-in.h: Likewise.
+       * linker.c: Likewise.
+       * m68klinux.c: Likewise.
+       * merge.c: Likewise.
+       * opncls.c: Likewise.
+       * pdp11.c: Likewise.
+       * sparclinux.c: Likewise.
+       * stabs.c: Likewise.
+       * sunos.c: Likewise.
+       * vms.c: Likewise.
+       * xcofflink.c: Likewise.
+       * section.c (struct section_hash_entry): Move to..
+       * libbfd-in.h: ..here.
+       * Makefile.am: Run "make dep-am"
+       * Makefile.in: Regenerate.
+       * bfd-in2.h: Regenerate.
+       * libbfd.h: Regenerate.
+       * libcoff.h: Regenerate.
+
 2006-03-16  Alan Modra  <amodra@bigpond.net.au>
 
        * elf32-ppc.c (ppc_elf_check_relocs): REL24 and REL14 relocs
index b592cd436cf8c8588f11664868e4ca28c21ebb65..4300ca9ed36ff40b433c459310d292a12e6ad8e3 100644 (file)
@@ -1000,7 +1000,8 @@ cpu-m68hc11.lo: cpu-m68hc11.c $(INCDIR)/filenames.h \
   $(INCDIR)/hashtab.h
 cpu-m68hc12.lo: cpu-m68hc12.c $(INCDIR)/filenames.h \
   $(INCDIR)/hashtab.h
-cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
+  $(INCDIR)/opcode/m68k.h
 cpu-m88k.lo: cpu-m88k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
 cpu-m10200.lo: cpu-m10200.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
 cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
@@ -1218,10 +1219,11 @@ elf32-arc.lo: elf32-arc.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h \
   $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \
   elf32-target.h
-elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
-  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
-  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h elf-vxworks.h \
-  $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \
+  $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+  elf-vxworks.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
+  elf32-target.h
 elf32-avr.lo: elf32-avr.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/avr.h \
@@ -1312,7 +1314,8 @@ elf32-m32r.lo: elf32-m32r.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
 elf32-m68k.lo: elf32-m68k.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/m68k.h \
-  $(INCDIR)/elf/reloc-macros.h elf32-target.h
+  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/opcode/m68k.h \
+  elf32-target.h
 elf32-m68hc11.lo: elf32-m68hc11.c $(INCDIR)/filenames.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elf32-m68hc1x.h \
@@ -1439,17 +1442,17 @@ elf32-xtensa.lo: elf32-xtensa.c $(INCDIR)/filenames.h \
   $(INCDIR)/elf/reloc-macros.h $(INCDIR)/xtensa-isa.h \
   $(INCDIR)/xtensa-config.h elf32-target.h
 elf32-xc16x.lo: elf32-xc16x.c $(INCDIR)/filenames.h \
-  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
-  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/xc16x.h \
-  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \
-  elf32-target.h
+  $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+  $(INCDIR)/elf/xc16x.h $(INCDIR)/elf/reloc-macros.h \
+  $(INCDIR)/elf/dwarf2.h $(INCDIR)/libiberty.h elf32-target.h
 elf32.lo: elf32.c elfcode.h $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfcore.h
 elflink.lo: elflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/safe-ctype.h \
-  $(INCDIR)/libiberty.h
+  $(INCDIR)/libiberty.h $(INCDIR)/objalloc.h
 elf-strtab.lo: elf-strtab.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h
index 445e8f4129d858adf82759a62ee488b191ad252d..ef96cc7a0ea1ed9d64f31f0f2cb7edb8c4821a3c 100644 (file)
@@ -2,7 +2,7 @@
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005  Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -1567,7 +1567,8 @@ cpu-m68hc11.lo: cpu-m68hc11.c $(INCDIR)/filenames.h \
   $(INCDIR)/hashtab.h
 cpu-m68hc12.lo: cpu-m68hc12.c $(INCDIR)/filenames.h \
   $(INCDIR)/hashtab.h
-cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
+cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
+  $(INCDIR)/opcode/m68k.h
 cpu-m88k.lo: cpu-m88k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
 cpu-m10200.lo: cpu-m10200.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
 cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h
@@ -1785,10 +1786,11 @@ elf32-arc.lo: elf32-arc.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h \
   $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \
   elf32-target.h
-elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
-  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
-  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h elf-vxworks.h \
-  $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h elf32-target.h
+elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \
+  $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+  elf-vxworks.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \
+  elf32-target.h
 elf32-avr.lo: elf32-avr.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/avr.h \
@@ -1879,7 +1881,8 @@ elf32-m32r.lo: elf32-m32r.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
 elf32-m68k.lo: elf32-m68k.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/m68k.h \
-  $(INCDIR)/elf/reloc-macros.h elf32-target.h
+  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/opcode/m68k.h \
+  elf32-target.h
 elf32-m68hc11.lo: elf32-m68hc11.c $(INCDIR)/filenames.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elf32-m68hc1x.h \
@@ -2006,17 +2009,17 @@ elf32-xtensa.lo: elf32-xtensa.c $(INCDIR)/filenames.h \
   $(INCDIR)/elf/reloc-macros.h $(INCDIR)/xtensa-isa.h \
   $(INCDIR)/xtensa-config.h elf32-target.h
 elf32-xc16x.lo: elf32-xc16x.c $(INCDIR)/filenames.h \
-  elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
-  $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/xc16x.h \
-  $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \
-  elf32-target.h
+  $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+  $(INCDIR)/elf/xc16x.h $(INCDIR)/elf/reloc-macros.h \
+  $(INCDIR)/elf/dwarf2.h $(INCDIR)/libiberty.h elf32-target.h
 elf32.lo: elf32.c elfcode.h $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfcore.h
 elflink.lo: elflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/safe-ctype.h \
-  $(INCDIR)/libiberty.h
+  $(INCDIR)/libiberty.h $(INCDIR)/objalloc.h
 elf-strtab.lo: elf-strtab.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
   $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h
index 9c44605621845c31a3c59d069f076906747b6be1..7dce07240ff6fbd600ee7aedd23ee4b5f86fdd5a 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD semi-generic back-end for a.out binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -2859,9 +2859,10 @@ NAME (aout, link_hash_table_init) (struct aout_link_hash_table *table,
                                   bfd *abfd,
                                   struct bfd_hash_entry *(*newfunc)
                                   (struct bfd_hash_entry *, struct bfd_hash_table *,
-                                   const char *))
+                                   const char *),
+                                  unsigned int entsize)
 {
-  return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize);
 }
 
 /* Create an a.out link hash table.  */
@@ -2876,8 +2877,9 @@ NAME (aout, link_hash_table_create) (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! NAME (aout, link_hash_table_init) (ret, abfd,
-                                          NAME (aout, link_hash_newfunc)))
+  if (!NAME (aout, link_hash_table_init) (ret, abfd,
+                                         NAME (aout, link_hash_newfunc),
+                                         sizeof (struct aout_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -5252,9 +5254,10 @@ NAME (aout, final_link) (bfd *abfd,
   aout_info.symbol_map = NULL;
   aout_info.output_syms = NULL;
 
-  if (! bfd_hash_table_init_n (&aout_info.includes.root,
-                              aout_link_includes_newfunc,
-                              251))
+  if (!bfd_hash_table_init_n (&aout_info.includes.root,
+                             aout_link_includes_newfunc,
+                             sizeof (struct aout_link_includes_entry),
+                             251))
     goto error_return;
   includes_hash_initialized = TRUE;
 
index 25ae6a4495e18d4a8a2223e54295f6707f423926..9daa578c03efc11d389f31ef5f5ed9bbb401f577 100644 (file)
@@ -376,6 +376,8 @@ struct bfd_hash_table
   struct bfd_hash_entry **table;
   /* The number of slots in the hash table.  */
   unsigned int size;
+  /* The size of elements.  */
+  unsigned int entsize;
   /* A function used to create new elements in the hash table.  The
      first entry is itself a pointer to an element.  When this
      function is first invoked, this pointer will be NULL.  However,
@@ -395,7 +397,8 @@ extern bfd_boolean bfd_hash_table_init
   (struct bfd_hash_table *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 
 /* Initialize a hash table specifying a size.  */
 extern bfd_boolean bfd_hash_table_init_n
@@ -403,7 +406,7 @@ extern bfd_boolean bfd_hash_table_init_n
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
                               const char *),
-   unsigned int size);
+   unsigned int, unsigned int);
 
 /* Free up a hash table.  */
 extern void bfd_hash_table_free
index 8782bf914cb303a10bee34347cf917a3f4ab9dcd..4a777ed825cc4105f5e0e7c5d20c0345f2bf75ae 100644 (file)
@@ -383,6 +383,8 @@ struct bfd_hash_table
   struct bfd_hash_entry **table;
   /* The number of slots in the hash table.  */
   unsigned int size;
+  /* The size of elements.  */
+  unsigned int entsize;
   /* A function used to create new elements in the hash table.  The
      first entry is itself a pointer to an element.  When this
      function is first invoked, this pointer will be NULL.  However,
@@ -402,7 +404,8 @@ extern bfd_boolean bfd_hash_table_init
   (struct bfd_hash_table *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 
 /* Initialize a hash table specifying a size.  */
 extern bfd_boolean bfd_hash_table_init_n
@@ -410,7 +413,7 @@ extern bfd_boolean bfd_hash_table_init_n
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
                               const char *),
-   unsigned int size);
+   unsigned int, unsigned int);
 
 /* Free up a hash table.  */
 extern void bfd_hash_table_free
index c4b18e98bac23178017255d1be976f67b7c015f4..733f6ee0272db1beb8b385505719f27f45929391 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1440,7 +1440,8 @@ bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve)
   preserve->section_count = abfd->section_count;
   preserve->section_htab = abfd->section_htab;
 
-  if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc))
+  if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc,
+                            sizeof (struct section_hash_entry)))
     return FALSE;
 
   abfd->tdata.any = NULL;
index 4ae195c2bcac5982eb6765edd67dd04937e3f7ae..6b83dc7af7fd6c7c1efee572be0114e8be3a49ee 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for ARM COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -879,8 +879,10 @@ coff_arm_link_hash_table_create (bfd * abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_coff_link_hash_table_init
-      (& ret->root, abfd, _bfd_coff_link_hash_newfunc))
+  if (!_bfd_coff_link_hash_table_init (&ret->root,
+                                      abfd,
+                                      _bfd_coff_link_hash_newfunc,
+                                      sizeof (struct coff_link_hash_entry)))
     {
       free (ret);
       return NULL;
index ef29664e782150d43ff81acee1ffbfc37377f2bf..9c858e1ef1ede5c374f95d40b98e31ab24742426 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for Renesas H8/300 COFF binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Steve Chamberlain, <sac@cygnus.com>.
 
@@ -63,13 +63,6 @@ static struct bfd_hash_entry *
 funcvec_hash_newfunc
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
 
-static bfd_boolean
-funcvec_hash_table_init
-  (struct funcvec_hash_table *, bfd *,
-   struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
-                              struct bfd_hash_table *,
-                              const char *));
-
 static bfd_reloc_status_type special
   (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **);
 static int select_reloc
@@ -181,13 +174,14 @@ funcvec_hash_table_init (struct funcvec_hash_table *table,
                         struct bfd_hash_entry *(*newfunc)
                           (struct bfd_hash_entry *,
                            struct bfd_hash_table *,
-                           const char *))
+                           const char *),
+                        unsigned int entsize)
 {
   /* Initialize our local fields, then call the generic initialization
      routine.  */
   table->offset = 0;
   table->abfd = abfd;
-  return (bfd_hash_table_init (&table->root, newfunc));
+  return (bfd_hash_table_init (&table->root, newfunc, entsize));
 }
 
 /* Create the derived linker hash table.  We use a derived hash table
@@ -204,7 +198,8 @@ h8300_coff_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
   if (!_bfd_link_hash_table_init (&ret->root.root, abfd,
-                                 _bfd_generic_link_hash_newfunc))
+                                 _bfd_generic_link_hash_newfunc,
+                                 sizeof (struct generic_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -1298,7 +1293,8 @@ h8300_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
 
       /* And initialize the funcvec hash table.  */
       if (!funcvec_hash_table_init (funcvec_hash_table, abfd,
-                                   funcvec_hash_newfunc))
+                                   funcvec_hash_newfunc,
+                                   sizeof (struct funcvec_hash_entry)))
        {
          bfd_release (abfd, funcvec_hash_table);
          return FALSE;
index 55f5f621b7a06281d575f3e7432987d9e28e5834..b4427936933a649abc02dd6810eba904ac73482e 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila (krk@cygnus.com)
@@ -127,11 +127,6 @@ struct ppc_coff_link_hash_table
 static struct bfd_hash_entry *ppc_coff_link_hash_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
           const char *));
-static bfd_boolean ppc_coff_link_hash_table_init
-  PARAMS ((struct ppc_coff_link_hash_table *, bfd *,
-          struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
-                                      struct bfd_hash_table *,
-                                      const char *)));
 static struct bfd_link_hash_table *ppc_coff_link_hash_table_create
   PARAMS ((bfd *));
 static bfd_boolean coff_ppc_relocate_section
@@ -184,14 +179,14 @@ ppc_coff_link_hash_newfunc (entry, table, string)
 /* Initialize a PE linker hash table.  */
 
 static bfd_boolean
-ppc_coff_link_hash_table_init (table, abfd, newfunc)
-     struct ppc_coff_link_hash_table *table;
-     bfd *abfd;
-     struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
-                                               struct bfd_hash_table *,
-                                               const char *));
+ppc_coff_link_hash_table_init (struct ppc_coff_link_hash_table *table,
+                              bfd *abfd,
+                              struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
+                                                                 struct bfd_hash_table *,
+                                                                 const char *),
+                              unsigned int entsize)
 {
-  return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc);
+  return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc, entsize);
 }
 
 /* Create a PE linker hash table.  */
@@ -206,8 +201,9 @@ ppc_coff_link_hash_table_create (abfd)
   ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
-  if (! ppc_coff_link_hash_table_init (ret, abfd,
-                                       ppc_coff_link_hash_newfunc))
+  if (!ppc_coff_link_hash_table_init (ret, abfd,
+                                     ppc_coff_link_hash_newfunc,
+                                     sizeof (struct ppc_coff_link_hash_entry)))
     {
       free (ret);
       return (struct bfd_link_hash_table *) NULL;
index 151b1fff0e532640144341a570ba817063e1e923..a1f6684bb61cc1fab98c71c0e5529198fdf71428 100644 (file)
@@ -1,6 +1,6 @@
 /* COFF specific linker code.
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005 Free Software Foundation, Inc.
+   2004, 2005, 2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -94,10 +94,11 @@ _bfd_coff_link_hash_table_init (struct coff_link_hash_table *table,
                                bfd *abfd,
                                struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                                                   struct bfd_hash_table *,
-                                                                  const char *))
+                                                                  const char *),
+                               unsigned int entsize)
 {
   memset (&table->stab_info, 0, sizeof (table->stab_info));
-  return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize);
 }
 
 /* Create a COFF linker hash table.  */
@@ -113,7 +114,8 @@ _bfd_coff_link_hash_table_create (bfd *abfd)
     return NULL;
 
   if (! _bfd_coff_link_hash_table_init (ret, abfd,
-                                       _bfd_coff_link_hash_newfunc))
+                                       _bfd_coff_link_hash_newfunc,
+                                       sizeof (struct coff_link_hash_entry)))
     {
       free (ret);
       return (struct bfd_link_hash_table *) NULL;
index 8c855b32b66720962af0e5ec068aa325a49bd961..75e1cc2a398d6b092b827bfa106407c41f2e633c 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic ECOFF (Extended-COFF) routines.
    Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
 
@@ -3285,8 +3285,9 @@ _bfd_ecoff_bfd_link_hash_table_create (bfd *abfd)
   ret = bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
-  if (! _bfd_link_hash_table_init (&ret->root, abfd,
-                                  ecoff_link_hash_newfunc))
+  if (!_bfd_link_hash_table_init (&ret->root, abfd,
+                                 ecoff_link_hash_newfunc,
+                                 sizeof (struct ecoff_link_hash_entry)))
     {
       free (ret);
       return NULL;
index d7bb817f6760f11e0f4149b05aa5675d4fcc6e0b..4246e94f3937e05949c191879aebc9cc21466bcc 100644 (file)
@@ -1,6 +1,6 @@
 /* Routines to link ECOFF debugging information.
    Copyright 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005 Free Software Foundation, Inc.
+   2004, 2005, 2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -501,8 +501,8 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
   ainfo = (struct accumulate *) bfd_malloc (amt);
   if (!ainfo)
     return NULL;
-  if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
-                              1021))
+  if (!bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
+                             sizeof (struct string_hash_entry), 1021))
     return NULL;
 
   ainfo->line = NULL;
@@ -528,7 +528,8 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
 
   if (! info->relocatable)
     {
-      if (! bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc))
+      if (!bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc,
+                               sizeof (struct string_hash_entry)))
        return NULL;
 
       /* The first entry in the string table is the empty string.  */
index 76be811ec291bf359731d511a9855dadcb1cbc8a..3fba1c228f0a9d57e3cf98727b969b167503b396 100644 (file)
@@ -1489,7 +1489,8 @@ extern bfd_boolean _bfd_elf_link_hash_fixup_symbol
 extern bfd_boolean _bfd_elf_link_hash_table_init
   (struct elf_link_hash_table *, bfd *,
    struct bfd_hash_entry *(*)
-     (struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
+     (struct bfd_hash_entry *, struct bfd_hash_table *, const char *),
+   unsigned int);
 extern bfd_boolean _bfd_elf_slurp_version_tables
   (bfd *, bfd_boolean);
 extern bfd_boolean _bfd_elf_merge_sections
index 81c5db026ee98cba1011bae3bc9156840217ca94..509f2a102e3838cf43f366b3d2fa76848e76aa2d 100644 (file)
@@ -1,6 +1,6 @@
 /* Matsushita 10300 specific support for 32-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -3695,8 +3695,9 @@ elf32_mn10300_link_hash_table_create (abfd)
   if (ret == (struct elf32_mn10300_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      elf32_mn10300_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf32_mn10300_link_hash_newfunc,
+                                     sizeof (struct elf32_mn10300_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -3712,8 +3713,9 @@ elf32_mn10300_link_hash_table_create (abfd)
       return NULL;
     }
 
-  if (! _bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd,
-                                      elf32_mn10300_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd,
+                                     elf32_mn10300_link_hash_newfunc,
+                                     sizeof (struct elf32_mn10300_link_hash_entry)))
     {
       free (ret->static_hash_table);
       free (ret);
index ac17b15af60067326324bad1c6ec424446620e6c..a0ce1d79ea8e7f3e99ad679af4e9688f7eaf71c6 100644 (file)
@@ -1,5 +1,5 @@
 /* ELF strtab with GC and suffix merging support.
-   Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -99,7 +99,8 @@ _bfd_elf_strtab_init (void)
   if (table == NULL)
     return NULL;
 
-  if (! bfd_hash_table_init (&table->table, elf_strtab_hash_newfunc))
+  if (!bfd_hash_table_init (&table->table, elf_strtab_hash_newfunc,
+                           sizeof (struct elf_strtab_hash_entry)))
     {
       free (table);
       return NULL;
index 365c3a0d7b4bfd35eac6f88be7ed0a5baff2f2eb..9e48f66e90fa22596bcd660e1a025832ed2233e7 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1561,7 +1561,8 @@ _bfd_elf_link_hash_table_init
    bfd *abfd,
    struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                      struct bfd_hash_table *,
-                                     const char *))
+                                     const char *),
+   unsigned int entsize)
 {
   bfd_boolean ret;
   int can_refcount = get_elf_backend_data (abfd)->can_refcount;
@@ -1588,7 +1589,7 @@ _bfd_elf_link_hash_table_init
   table->loaded = NULL;
   table->is_relocatable_executable = FALSE;
 
-  ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize);
   table->root.type = bfd_link_elf_hash_table;
 
   return ret;
@@ -1606,7 +1607,8 @@ _bfd_elf_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc))
+  if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc,
+                                      sizeof (struct elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 3f560dfec1395b9d6e1614b94c03d8523a50b627..ca33121708da810026e27cbdb60b41a975c2023f 100644 (file)
@@ -1967,7 +1967,8 @@ elf32_arm_link_hash_table_create (bfd *abfd)
     return NULL;
 
   if (!_bfd_elf_link_hash_table_init (& ret->root, abfd,
-                                     elf32_arm_link_hash_newfunc))
+                                     elf32_arm_link_hash_newfunc,
+                                     sizeof (struct elf32_arm_link_hash_entry)))
     {
       free (ret);
       return NULL;
index c97cbb2044e80d3fae419ee3441ee87bf4e4bbf0..13c320152025cdfe467caee146daa2e6798694fd 100644 (file)
@@ -1,5 +1,5 @@
 /* ADI Blackfin BFD support for 32-bit ELF. 
-   Copyright 2005 Free Software Foundation, Inc.
+   Copyright 2005, 2006 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -2224,7 +2224,8 @@ bfin_link_hash_table_create (bfd * abfd)
     return NULL;
 
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                     bfin_link_hash_newfunc))
+                                     bfin_link_hash_newfunc,
+                                     sizeof (struct bfin_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 3edabc757945436b4137cd69c54f29e6d36b790f..4019e34e26b4b21a2e3080772b8cd9250c6ccf74 100644 (file)
@@ -1,5 +1,5 @@
 /* CRIS-specific support for 32-bit ELF.
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Contributed by Axis Communications AB.
    Written by Hans-Peter Nilsson, based on elf32-fr30.c
@@ -849,8 +849,9 @@ elf_cris_link_hash_table_create (abfd)
   if (ret == (struct elf_cris_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      elf_cris_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf_cris_link_hash_newfunc,
+                                     sizeof (struct elf_cris_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 7126ed46c38f3ca4f4695c5837f6abbd81e70b85..1758e27591fa1a27d64aabfed624a2c24dca388b 100644 (file)
@@ -1,5 +1,5 @@
 /* FRV-specific support for 32-bit ELF.
-   Copyright 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright 2002, 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -1008,8 +1008,9 @@ frvfdpic_elf_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd,
-                                      _bfd_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
+                                     _bfd_elf_link_hash_newfunc,
+                                     sizeof (struct elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
index b5d67140ecb268f9642ae8b1eb6c9ace45701023..51c210e5b1c358dc9ce369291741b2781be2e99d 100644 (file)
@@ -394,14 +394,16 @@ elf32_hppa_link_hash_table_create (bfd *abfd)
   if (htab == NULL)
     return NULL;
 
-  if (!_bfd_elf_link_hash_table_init (&htab->etab, abfd, hppa_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&htab->etab, abfd, hppa_link_hash_newfunc,
+                                     sizeof (struct elf32_hppa_link_hash_entry)))
     {
       free (htab);
       return NULL;
     }
 
   /* Init the stub hash table too.  */
-  if (!bfd_hash_table_init (&htab->bstab, stub_hash_newfunc))
+  if (!bfd_hash_table_init (&htab->bstab, stub_hash_newfunc,
+                           sizeof (struct elf32_hppa_stub_hash_entry)))
     return NULL;
 
   htab->stub_bfd = NULL;
index c14fc3ba312e279ae3db64c1cd53c52f1e5ed0e6..bc44cba972ccc163aff6fa48cd1905af4f2d09a7 100644 (file)
@@ -721,7 +721,8 @@ elf_i386_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+                                     sizeof (struct elf_i386_link_hash_entry)))
     {
       free (ret);
       return NULL;
index aecf0fea2985ca1f6269d7e23e5dd94440a52cb1..6c42c2f5b60de6a544bab31431f51a5071729c7d 100644 (file)
@@ -1572,8 +1572,9 @@ m32r_elf_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                       m32r_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     m32r_elf_link_hash_newfunc,
+                                     sizeof (struct elf_m32r_link_hash_entry)))
     {
       free (ret);
       return NULL;
index bf34694f24b4bfe271d64499b7a77d78c7498919..e7fb944b26b3be7b2bd844913a2a6a429dfcffdb 100644 (file)
@@ -1,5 +1,5 @@
 /* Motorola 68HC11/HC12-specific support for 32-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Contributed by Stephane Carrez (stcarrez@nerim.fr)
 
@@ -70,8 +70,9 @@ m68hc11_elf_hash_table_create (bfd *abfd)
     return NULL;
 
   memset (ret, 0, amt);
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      _bfd_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     _bfd_elf_link_hash_newfunc,
+                                     sizeof (struct elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -85,7 +86,8 @@ m68hc11_elf_hash_table_create (bfd *abfd)
       free (ret);
       return NULL;
     }
-  if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc))
+  if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc,
+                           sizeof (struct elf32_m68hc11_stub_hash_entry)))
     return NULL;
 
   ret->stub_bfd = NULL;
index 978dbd22d94703f2ea36f1b18148b3a0b076ab12..5e69df5c9b0f42011ef410e6720608af012b2cc2 100644 (file)
@@ -361,8 +361,9 @@ elf_m68k_link_hash_table_create (abfd)
   if (ret == (struct elf_m68k_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      elf_m68k_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf_m68k_link_hash_newfunc,
+                                     sizeof (struct elf_m68k_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 3d9402e804c75b917cabfce812ec036bd87bc6ce..2fd30a0560b716eb274ef0838176b4dd186ff59f 100644 (file)
@@ -1,6 +1,6 @@
 /* PowerPC-specific support for 32-bit ELF
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005 Free Software Foundation, Inc.
+   2004, 2005, 2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -2430,8 +2430,9 @@ ppc_elf_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd,
-                                      ppc_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd,
+                                     ppc_elf_link_hash_newfunc,
+                                     sizeof (struct ppc_elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 1c527552bef882d59607f231344c8a406c6f6d5d..eb8e1724fc195d10f9dd6481ffe8baa2f6e9575a 100644 (file)
@@ -771,7 +771,8 @@ elf_s390_link_hash_table_create (abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+                                     sizeof (struct elf_s390_link_hash_entry)))
     {
       free (ret);
       return NULL;
index d03f60b2b5f3df63046ca2bcaf52607f1a7a9243..118690d9a58fd31deeadaad41d52495898e43ea9 100644 (file)
@@ -3612,8 +3612,9 @@ sh_elf_link_hash_table_create (bfd *abfd)
   if (ret == (struct elf_sh_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      sh_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     sh_elf_link_hash_newfunc,
+                                     sizeof (struct elf_sh_link_hash_entry)))
     {
       free (ret);
       return NULL;
index e0d059c0cb0b95eb7be936d189cc62378907c6e9..bf481e459e75d496cb1902f2e607ec991bffbe64 100644 (file)
@@ -1,6 +1,6 @@
 /* VAX series support for 32-bit ELF
    Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005 Free Software Foundation, Inc.
+   2004, 2005, 2006 Free Software Foundation, Inc.
    Contributed by Matt Thomas <matt@3am-software.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -468,8 +468,9 @@ elf_vax_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      elf_vax_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf_vax_link_hash_newfunc,
+                                     sizeof (struct elf_vax_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 60deadb8dd5d4805446fff042fa93d6c7bc568c8..76d0661a11657055261af2a583636279f8eede74 100644 (file)
@@ -1,6 +1,6 @@
 /* Alpha specific support for 64-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@tamu.edu>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -273,8 +273,9 @@ elf64_alpha_bfd_link_hash_table_create (bfd *abfd)
   if (ret == (struct alpha_elf_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      elf64_alpha_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     elf64_alpha_link_hash_newfunc,
+                                     sizeof (struct alpha_elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
index fbd64584d1db6b2cc532919ddab0531f96b1503a..3c2ca995abe90567e341e48442267c6775297501 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for HPPA 64-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -157,9 +157,6 @@ struct elf64_hppa_link_hash_table
 typedef struct bfd_hash_entry *(*new_hash_entry_func)
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 
-static bfd_boolean elf64_hppa_dyn_hash_table_init
-  PARAMS ((struct elf64_hppa_dyn_hash_table *ht, bfd *abfd,
-          new_hash_entry_func new));
 static struct bfd_hash_entry *elf64_hppa_new_dyn_hash_entry
   PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
           const char *string));
@@ -276,13 +273,13 @@ static int elf64_hppa_elf_get_symbol_type
   PARAMS ((Elf_Internal_Sym *, int));
 
 static bfd_boolean
-elf64_hppa_dyn_hash_table_init (ht, abfd, new)
-     struct elf64_hppa_dyn_hash_table *ht;
-     bfd *abfd ATTRIBUTE_UNUSED;
-     new_hash_entry_func new;
+elf64_hppa_dyn_hash_table_init (struct elf64_hppa_dyn_hash_table *ht,
+                               bfd *abfd ATTRIBUTE_UNUSED,
+                               new_hash_entry_func new,
+                               unsigned int entsize)
 {
   memset (ht, 0, sizeof (*ht));
-  return bfd_hash_table_init (&ht->root, new);
+  return bfd_hash_table_init (&ht->root, new, entsize);
 }
 
 static struct bfd_hash_entry*
@@ -328,14 +325,16 @@ elf64_hppa_hash_table_create (abfd)
   if (!ret)
     return 0;
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                     _bfd_elf_link_hash_newfunc))
+                                     _bfd_elf_link_hash_newfunc,
+                                     sizeof (struct elf_link_hash_entry)))
     {
       bfd_release (abfd, ret);
       return 0;
     }
 
   if (!elf64_hppa_dyn_hash_table_init (&ret->dyn_hash_table, abfd,
-                                      elf64_hppa_new_dyn_hash_entry))
+                                      elf64_hppa_new_dyn_hash_entry,
+                                      sizeof (struct elf64_hppa_dyn_hash_entry)))
     return 0;
   return &ret->root.root;
 }
index 1cfac82c741898de4f2ccb7ef4378595d0b1951a..fc8c182e83da94b31000c62349cd3a9e7d322a2e 100644 (file)
@@ -3464,18 +3464,21 @@ ppc64_elf_link_hash_table_create (bfd *abfd)
   if (htab == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc,
+                                     sizeof (struct ppc_link_hash_entry)))
     {
       free (htab);
       return NULL;
     }
 
   /* Init the stub hash table too.  */
-  if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc))
+  if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc,
+                           sizeof (struct ppc_stub_hash_entry)))
     return NULL;
 
   /* And the branch hash table.  */
-  if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc))
+  if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc,
+                           sizeof (struct ppc_branch_hash_entry)))
     return NULL;
 
   /* Initializing two fields of the union is just cosmetic.  We really
index 7beda9dcd00bf7cc5767735c01a86cb99dce86ec..1fe0c6ca915c05efcfb82867d07eb99e31877c36 100644 (file)
@@ -724,7 +724,8 @@ elf_s390_link_hash_table_create (abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+                                     sizeof (struct elf_s390_link_hash_entry)))
     {
       free (ret);
       return NULL;
index f76e91676e815370f91ae7c162873032ba2932ed..4d6d8d5645fac50019b4cadd12aa5fa03899c663 100644 (file)
@@ -1,5 +1,5 @@
 /* SuperH SH64-specific support for 64-bit ELF
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -3138,8 +3138,9 @@ sh64_elf64_link_hash_table_create (bfd *abfd)
   if (ret == (struct elf_sh64_link_hash_table *) NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      sh64_elf64_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     sh64_elf64_link_hash_newfunc,
+                                     sizeof (struct elf_sh64_link_hash_entry)))
     {
       free (ret);
       return NULL;
index 8c1a712c1e081febeb9811dabcbe5f49c6c407ce..504a19b7b9833f1ee059760c2eba068b4fde1c0c 100644 (file)
@@ -510,7 +510,8 @@ elf64_x86_64_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+                                     sizeof (struct elf64_x86_64_link_hash_entry)))
     {
       free (ret);
       return NULL;
index a95ac44c0e9fb404aca658c618fedad5f81d97dc..12dd273f909a6302b7d9391f5917ac3219404551 100644 (file)
@@ -26,6 +26,7 @@
 #include "elf-bfd.h"
 #include "safe-ctype.h"
 #include "libiberty.h"
+#include "objalloc.h"
 
 /* Define a symbol in a dynamic linkage section.  */
 
@@ -2875,98 +2876,6 @@ elf_add_dt_needed_tag (bfd *abfd,
   return 0;
 }
 
-/* Called via elf_link_hash_traverse, elf_smash_syms sets all symbols
-   belonging to NOT_NEEDED to bfd_link_hash_new.  We know there are no
-   references from regular objects to these symbols.
-
-   ??? Should we do something about references from other dynamic
-   obects?  If not, we potentially lose some warnings about undefined
-   symbols.  But how can we recover the initial undefined / undefweak
-   state?  */
-
-struct elf_smash_syms_data
-{
-  bfd *not_needed;
-  struct elf_link_hash_table *htab;
-  bfd_boolean twiddled;
-};
-
-static bfd_boolean
-elf_smash_syms (struct elf_link_hash_entry *h, void *data)
-{
-  struct elf_smash_syms_data *inf = (struct elf_smash_syms_data *) data;
-  struct bfd_link_hash_entry *bh;
-
-  switch (h->root.type)
-    {
-    default:
-    case bfd_link_hash_new:
-      return TRUE;
-
-    case bfd_link_hash_undefined:
-      if (h->root.u.undef.abfd != inf->not_needed)
-       return TRUE;
-      if (h->root.u.undef.weak != NULL
-         && h->root.u.undef.weak != inf->not_needed)
-       {
-         /* Symbol was undefweak in u.undef.weak bfd, and has become
-            undefined in as-needed lib.  Restore weak.  */
-         h->root.type = bfd_link_hash_undefweak;
-         h->root.u.undef.abfd = h->root.u.undef.weak;
-         if (h->root.u.undef.next != NULL
-             || inf->htab->root.undefs_tail == &h->root)
-           inf->twiddled = TRUE;
-         return TRUE;
-       }
-      break;
-
-    case bfd_link_hash_undefweak:
-      if (h->root.u.undef.abfd != inf->not_needed)
-       return TRUE;
-      break;
-
-    case bfd_link_hash_defined:
-    case bfd_link_hash_defweak:
-      if (h->root.u.def.section->owner != inf->not_needed)
-       return TRUE;
-      break;
-
-    case bfd_link_hash_common:
-      if (h->root.u.c.p->section->owner != inf->not_needed)
-       return TRUE;
-      break;
-
-    case bfd_link_hash_warning:
-    case bfd_link_hash_indirect:
-      elf_smash_syms ((struct elf_link_hash_entry *) h->root.u.i.link, data);
-      if (h->root.u.i.link->type != bfd_link_hash_new)
-       return TRUE;
-      if (h->root.u.i.link->u.undef.abfd != inf->not_needed)
-       return TRUE;
-      break;
-    }
-
-  /* There is no way we can undo symbol table state from defined or
-     defweak back to undefined.  */
-  if (h->ref_regular)
-    abort ();
-
-  /* Set sym back to newly created state, but keep undef.next if it is
-     being used as a list pointer.  */
-  bh = h->root.u.undef.next;
-  if (bh == &h->root)
-    bh = NULL;
-  if (bh != NULL || inf->htab->root.undefs_tail == &h->root)
-    inf->twiddled = TRUE;
-  (*inf->htab->root.table.newfunc) (&h->root.root,
-                                   &inf->htab->root.table,
-                                   h->root.root.string);
-  h->root.u.undef.next = bh;
-  h->root.u.undef.abfd = inf->not_needed;
-  h->non_elf = 0;
-  return TRUE;
-}
-
 /* Sort symbol by value and section.  */
 static int
 elf_sort_symbol (const void *arg1, const void *arg2)
@@ -3136,14 +3045,6 @@ elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info)
 static bfd_boolean
 elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 {
-  bfd_boolean (*add_symbol_hook)
-    (bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
-     const char **, flagword *, asection **, bfd_vma *);
-  bfd_boolean (*check_relocs)
-    (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
-  bfd_boolean (*check_directives)
-    (bfd *, struct bfd_link_info *);
-  bfd_boolean collect;
   Elf_Internal_Shdr *hdr;
   bfd_size_type symcount;
   bfd_size_type extsymcount;
@@ -3160,14 +3061,20 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
   Elf_Internal_Sym *isymend;
   const struct elf_backend_data *bed;
   bfd_boolean add_needed;
-  struct elf_link_hash_table * hash_table;
+  struct elf_link_hash_table *htab;
   bfd_size_type amt;
+  void *alloc_mark = NULL;
+  void *old_tab = NULL;
+  void *old_hash;
+  void *old_ent;
+  struct bfd_link_hash_entry *old_undefs = NULL;
+  struct bfd_link_hash_entry *old_undefs_tail = NULL;
+  long old_dynsymcount = 0;
+  size_t tabsize = 0;
+  size_t hashsize = 0;
 
-  hash_table = elf_hash_table (info);
-
+  htab = elf_hash_table (info);
   bed = get_elf_backend_data (abfd);
-  add_symbol_hook = bed->elf_add_symbol_hook;
-  collect = bed->collect;
 
   if ((abfd->flags & DYNAMIC) == 0)
     dynamic = FALSE;
@@ -3179,8 +3086,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
         hope of using a dynamic object which does not exactly match
         the format of the output file.  */
       if (info->relocatable
-         || !is_elf_hash_table (hash_table)
-         || hash_table->root.creator != abfd->xvec)
+         || !is_elf_hash_table (htab)
+         || htab->root.creator != abfd->xvec)
        {
          if (info->relocatable)
            bfd_set_error (bfd_error_invalid_operation);
@@ -3223,8 +3130,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                {
                  struct elf_link_hash_entry *h;
 
-                 h = elf_link_hash_lookup (hash_table, name,
-                                           FALSE, FALSE, TRUE);
+                 h = elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE);
 
                  /* FIXME: What about bfd_link_hash_common?  */
                  if (h != NULL
@@ -3251,7 +3157,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 
              if (! (_bfd_generic_link_add_one_symbol
                     (info, abfd, name, BSF_WARNING, s, 0, msg,
-                     FALSE, collect, NULL)))
+                     FALSE, bed->collect, NULL)))
                goto error_return;
 
              if (! info->relocatable)
@@ -3277,15 +3183,15 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
         format.  FIXME: If there are no input BFD's of the same
         format as the output, we can't make a shared library.  */
       if (info->shared
-         && is_elf_hash_table (hash_table)
-         && hash_table->root.creator == abfd->xvec
-         && ! hash_table->dynamic_sections_created)
+         && is_elf_hash_table (htab)
+         && htab->root.creator == abfd->xvec
+         && !htab->dynamic_sections_created)
        {
          if (! _bfd_elf_link_create_dynamic_sections (abfd, info))
            goto error_return;
        }
     }
-  else if (!is_elf_hash_table (hash_table))
+  else if (!is_elf_hash_table (htab))
     goto error_return;
   else
     {
@@ -3360,9 +3266,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                  n->name = anm;
                  n->by = abfd;
                  n->next = NULL;
-                 for (pn = & hash_table->needed;
-                      *pn != NULL;
-                      pn = &(*pn)->next)
+                 for (pn = &htab->needed; *pn != NULL; pn = &(*pn)->next)
                    ;
                  *pn = n;
                }
@@ -3434,9 +3338,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       if (rpath)
        {
          struct bfd_link_needed_list **pn;
-         for (pn = & hash_table->runpath;
-              *pn != NULL;
-              pn = &(*pn)->next)
+         for (pn = &htab->runpath; *pn != NULL; pn = &(*pn)->next)
            ;
          *pn = rpath;
        }
@@ -3544,8 +3446,57 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
        }
     }
 
-  weaks = NULL;
+  /* If we are loading an as-needed shared lib, save the symbol table
+     state before we start adding symbols.  If the lib turns out
+     to be unneeded, restore the state.  */
+  if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0)
+    {
+      unsigned int i;
+      size_t entsize;
 
+      for (entsize = 0, i = 0; i < htab->root.table.size; i++)
+       {
+         struct bfd_hash_entry *p;
+
+         for (p = htab->root.table.table[i]; p != NULL; p = p->next)
+           entsize += htab->root.table.entsize;
+       }
+
+      tabsize = htab->root.table.size * sizeof (struct bfd_hash_entry *);
+      hashsize = extsymcount * sizeof (struct elf_link_hash_entry *);
+      old_tab = bfd_malloc (tabsize + entsize + hashsize);
+      if (old_tab == NULL)
+       goto error_free_vers;
+
+      /* Remember the current objalloc pointer, so that all mem for
+        symbols added can later be reclaimed.  */
+      alloc_mark = bfd_hash_allocate (&htab->root.table, 1);
+      if (alloc_mark == NULL)
+       goto error_free_vers;
+
+      /* Clone the symbol table and sym hashes.  Remember some
+        pointers into the symbol table, and dynamic symbol count.  */
+      old_hash = (char *) old_tab + tabsize;
+      old_ent = (char *) old_hash + hashsize;
+      memcpy (old_tab, htab->root.table.table, tabsize);
+      memcpy (old_hash, sym_hash, hashsize);
+      old_undefs = htab->root.undefs;
+      old_undefs_tail = htab->root.undefs_tail;
+      old_dynsymcount = htab->dynsymcount;
+
+      for (i = 0; i < htab->root.table.size; i++)
+       {
+         struct bfd_hash_entry *p;
+
+         for (p = htab->root.table.table[i]; p != NULL; p = p->next)
+           {
+             memcpy (old_ent, p, htab->root.table.entsize);
+             old_ent = (char *) old_ent + htab->root.table.entsize;
+           }
+       }
+    }
+
+  weaks = NULL;
   ever = extversym != NULL ? extversym + extsymoff : NULL;
   for (isym = isymbuf, isymend = isymbuf + extsymcount;
        isym < isymend;
@@ -3597,7 +3548,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 
       if (isym->st_shndx == SHN_UNDEF)
        sec = bfd_und_section_ptr;
-      else if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE)
+      else if (isym->st_shndx < SHN_LORESERVE
+              || isym->st_shndx > SHN_HIRESERVE)
        {
          sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
          if (sec == NULL)
@@ -3608,8 +3560,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                 default visibility.  */
              sec = bfd_und_section_ptr;
              isym->st_shndx = SHN_UNDEF;
-             isym->st_other = STV_DEFAULT
-                              | (isym->st_other & ~ ELF_ST_VISIBILITY(-1));
+             isym->st_other = (STV_DEFAULT
+                               | (isym->st_other & ~ ELF_ST_VISIBILITY (-1)));
            }
          else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
            value -= sec->vma;
@@ -3650,10 +3602,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
            }
          sec = tcomm;
        }
-      else if (add_symbol_hook)
+      else if (bed->elf_add_symbol_hook)
        {
-         if (! (*add_symbol_hook) (abfd, info, isym, &name, &flags, &sec,
-                                   &value))
+         if (! (*bed->elf_add_symbol_hook) (abfd, info, isym, &name, &flags,
+                                            &sec, &value))
            goto error_free_vers;
 
          /* The hook function sets the name to NULL if this symbol
@@ -3676,12 +3628,12 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
        definition = TRUE;
 
       size_change_ok = FALSE;
-      type_change_ok = get_elf_backend_data (abfd)->type_change_ok;
+      type_change_ok = bed->type_change_ok;
       old_alignment = 0;
       old_bfd = NULL;
       new_sec = sec;
 
-      if (is_elf_hash_table (hash_table))
+      if (is_elf_hash_table (htab))
        {
          Elf_Internal_Versym iver;
          unsigned int vernum = 0;
@@ -3776,7 +3728,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                  && isym->st_shndx != SHN_UNDEF)
                ++newlen;
 
-             newname = bfd_alloc (abfd, newlen);
+             newname = bfd_hash_allocate (&htab->root.table, newlen);
              if (newname == NULL)
                goto error_free_vers;
              memcpy (newname, name, namelen);
@@ -3840,7 +3792,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
        }
 
       if (! (_bfd_generic_link_add_one_symbol
-            (info, abfd, name, flags, sec, value, NULL, FALSE, collect,
+            (info, abfd, name, flags, sec, value, NULL, FALSE, bed->collect,
              (struct bfd_link_hash_entry **) sym_hash)))
        goto error_free_vers;
 
@@ -3855,7 +3807,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
          && definition
          && (flags & BSF_WEAK) != 0
          && ELF_ST_TYPE (isym->st_info) != STT_FUNC
-         && is_elf_hash_table (hash_table)
+         && is_elf_hash_table (htab)
          && h->u.weakdef == NULL)
        {
          /* Keep a list of all weak defined non function symbols from
@@ -3898,7 +3850,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
            h->root.u.c.p->alignment_power = old_alignment;
        }
 
-      if (is_elf_hash_table (hash_table))
+      if (is_elf_hash_table (htab))
        {
          bfd_boolean dynsym;
 
@@ -3998,7 +3950,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
              && (abfd->no_export
                  || (abfd->my_archive && abfd->my_archive->no_export))
              && ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL)
-           isym->st_other = STV_HIDDEN | (isym->st_other & ~ ELF_ST_VISIBILITY (-1));
+           isym->st_other = (STV_HIDDEN
+                             | (isym->st_other & ~ELF_ST_VISIBILITY (-1)));
 
          if (isym->st_other != 0 && !dynamic)
            {
@@ -4071,13 +4024,13 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                {
                  /* Queue non-default versions so that .symver x, x@FOO
                     aliases can be checked.  */
-                 if (! nondeflt_vers)
+                 if (!nondeflt_vers)
                    {
-                     amt = (isymend - isym + 1)
-                           * sizeof (struct elf_link_hash_entry *);
+                     amt = ((isymend - isym + 1)
+                            * sizeof (struct elf_link_hash_entry *));
                      nondeflt_vers = bfd_malloc (amt);
                    }
-                 nondeflt_vers [nondeflt_vers_cnt++] = h;
+                 nondeflt_vers[nondeflt_vers_cnt++] = h;
                }
            }
 
@@ -4089,7 +4042,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                  && ! new_weakdef
                  && h->u.weakdef->dynindx == -1)
                {
-                 if (! bfd_elf_link_record_dynamic_symbol (info, h->u.weakdef))
+                 if (!bfd_elf_link_record_dynamic_symbol (info, h->u.weakdef))
                    goto error_free_vers;
                }
            }
@@ -4139,6 +4092,59 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
        }
     }
 
+  if (extversym != NULL)
+    {
+      free (extversym);
+      extversym = NULL;
+    }
+
+  if (isymbuf != NULL)
+    {
+      free (isymbuf);
+      isymbuf = NULL;
+    }
+
+  if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0)
+    {
+      unsigned int i;
+
+      /* Restore the symbol table.  */
+      old_hash = (char *) old_tab + tabsize;
+      old_ent = (char *) old_hash + hashsize;
+      sym_hash = elf_sym_hashes (abfd);
+      memcpy (htab->root.table.table, old_tab, tabsize);
+      memcpy (sym_hash, old_hash, hashsize);
+      htab->root.undefs = old_undefs;
+      htab->root.undefs_tail = old_undefs_tail;
+      for (i = 0; i < htab->root.table.size; i++)
+       {
+         struct bfd_hash_entry *p;
+         struct elf_link_hash_entry *h;
+
+         for (p = htab->root.table.table[i]; p != NULL; p = p->next)
+           {
+             h = (struct elf_link_hash_entry *) p;
+             if (h->dynindx >= old_dynsymcount)
+               _bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index);
+             memcpy (p, old_ent, htab->root.table.entsize);
+             old_ent = (char *) old_ent + htab->root.table.entsize;
+           }
+       }
+
+      free (old_tab);
+      objalloc_free_block ((struct objalloc *) htab->root.table.memory,
+                          alloc_mark);
+      if (nondeflt_vers != NULL)
+       free (nondeflt_vers);
+      return TRUE;
+    }
+  if (old_tab != NULL)
+    {
+      free (old_tab);
+      old_tab = NULL;
+    }
+
   /* Now that all the symbols from this input file are created, handle
      .symver foo, foo@BAR such that any relocs against foo become foo@BAR.  */
   if (nondeflt_vers != NULL)
@@ -4162,7 +4168,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
          shortname[amt] = '\0';
 
          hi = (struct elf_link_hash_entry *)
-              bfd_link_hash_lookup (&hash_table->root, shortname,
+              bfd_link_hash_lookup (&htab->root, shortname,
                                     FALSE, FALSE, FALSE);
          if (hi != NULL
              && hi->root.type == h->root.type
@@ -4188,31 +4194,6 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       nondeflt_vers = NULL;
     }
 
-  if (extversym != NULL)
-    {
-      free (extversym);
-      extversym = NULL;
-    }
-
-  if (isymbuf != NULL)
-    free (isymbuf);
-  isymbuf = NULL;
-
-  if (!add_needed
-      && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0)
-    {
-      /* Remove symbols defined in an as-needed shared lib that wasn't
-        needed.  */
-      struct elf_smash_syms_data inf;
-      inf.not_needed = abfd;
-      inf.htab = hash_table;
-      inf.twiddled = FALSE;
-      elf_link_hash_traverse (hash_table, elf_smash_syms, &inf);
-      if (inf.twiddled)
-       bfd_link_repair_undef_list (&hash_table->root);
-      weaks = NULL;
-    }
-
   /* Now set the weakdefs field correctly for all the weak defined
      symbols we found.  The only way to do this is to search all the
      symbols.  Since we only need the information for non functions in
@@ -4352,9 +4333,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       free (sorted_sym_hash);
     }
 
-  check_directives = get_elf_backend_data (abfd)->check_directives;
-  if (check_directives)
-    check_directives (abfd, info);
+  if (bed->check_directives)
+    (*bed->check_directives) (abfd, info);
 
   /* If this object is the same format as the output object, and it is
      not a shared library, then let the backend look through the
@@ -4373,11 +4353,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 
      I have no idea how to handle linking PIC code into a file of a
      different format.  It probably can't be done.  */
-  check_relocs = get_elf_backend_data (abfd)->check_relocs;
   if (! dynamic
-      && is_elf_hash_table (hash_table)
-      && hash_table->root.creator == abfd->xvec
-      && check_relocs != NULL)
+      && is_elf_hash_table (htab)
+      && htab->root.creator == abfd->xvec
+      && bed->check_relocs != NULL)
     {
       asection *o;
 
@@ -4398,7 +4377,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
          if (internal_relocs == NULL)
            goto error_return;
 
-         ok = (*check_relocs) (abfd, info, o, internal_relocs);
+         ok = (*bed->check_relocs) (abfd, info, o, internal_relocs);
 
          if (elf_section_data (o)->relocs != internal_relocs)
            free (internal_relocs);
@@ -4412,7 +4391,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
      of the .stab/.stabstr sections.  */
   if (! dynamic
       && ! info->traditional_format
-      && is_elf_hash_table (hash_table)
+      && is_elf_hash_table (htab)
       && (info->strip != strip_all && info->strip != strip_debugger))
     {
       asection *stabstr;
@@ -4433,10 +4412,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
                struct bfd_elf_section_data *secdata;
 
                secdata = elf_section_data (stab);
-               if (! _bfd_link_section_stabs (abfd,
-                                              &hash_table->stab_info,
-                                              stab, stabstr,
-                                              &secdata->sec_info,
+               if (! _bfd_link_section_stabs (abfd, &htab->stab_info, stab,
+                                              stabstr, &secdata->sec_info,
                                               &string_offset))
                  goto error_return;
                if (secdata->sec_info)
@@ -4445,7 +4422,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
        }
     }
 
-  if (is_elf_hash_table (hash_table) && add_needed)
+  if (is_elf_hash_table (htab) && add_needed)
     {
       /* Add this bfd to the loaded list.  */
       struct elf_link_loaded_list *n;
@@ -4454,13 +4431,15 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
       if (n == NULL)
        goto error_return;
       n->abfd = abfd;
-      n->next = hash_table->loaded;
-      hash_table->loaded = n;
+      n->next = htab->loaded;
+      htab->loaded = n;
     }
 
   return TRUE;
 
  error_free_vers:
+  if (old_tab != NULL)
+    free (old_tab);
   if (nondeflt_vers != NULL)
     free (nondeflt_vers);
   if (extversym != NULL)
index 63c131649b62201df93de302807e1720192b5c0b..f0bb0fa60ad67e5bb16d311b4398d501ad027005 100644 (file)
@@ -1,5 +1,5 @@
 /* IA-64 support for 64-bit ELF
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
 
@@ -1918,7 +1918,8 @@ elfNN_ia64_hash_table_create (abfd)
     return 0;
 
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                     elfNN_ia64_new_elf_hash_entry))
+                                     elfNN_ia64_new_elf_hash_entry,
+                                     sizeof (struct elfNN_ia64_link_hash_entry)))
     {
       free (ret);
       return 0;
index ea8820b61132acbcfe98a6274c4a20a1efc76f2a..6f6b4a2e6c7bc3417b049de0424540b49a606554 100644 (file)
@@ -1,6 +1,6 @@
 /* MIPS-specific support for ELF
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
    Most of the information added by Ian Lance Taylor, Cygnus Support,
    <ian@cygnus.com>.
@@ -8944,8 +8944,9 @@ _bfd_mips_elf_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
 
-  if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
-                                      mips_elf_link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+                                     mips_elf_link_hash_newfunc,
+                                     sizeof (struct mips_elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
index cdf8c83cd87607f28706af1c719c5e915b5d69ba..cb5f7cbba9bf64a82144dd0b2f40482618b8fdca 100644 (file)
@@ -810,7 +810,8 @@ _bfd_sparc_elf_link_hash_table_create (bfd *abfd)
       ret->dynamic_interpreter_size = sizeof ELF32_DYNAMIC_INTERPRETER;
     }
 
-  if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc))
+  if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc,
+                                     sizeof (struct _bfd_sparc_elf_link_hash_entry)))
     {
       free (ret);
       return NULL;
index e53eda1b901cb929ff6613d5cf6548a75ba496a6..ce9ba5c6297fb436274b828939bde37f27dbc7c2 100644 (file)
@@ -1,6 +1,6 @@
 /* hash.c -- hash table routines for BFD
-   Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -308,6 +308,7 @@ bfd_hash_table_init_n (struct bfd_hash_table *table,
                       struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                                          struct bfd_hash_table *,
                                                          const char *),
+                      unsigned int entsize,
                       unsigned int size)
 {
   unsigned int alloc;
@@ -328,6 +329,7 @@ bfd_hash_table_init_n (struct bfd_hash_table *table,
     }
   memset ((void *) table->table, 0, alloc);
   table->size = size;
+  table->entsize = entsize;
   table->newfunc = newfunc;
   return TRUE;
 }
@@ -338,9 +340,11 @@ bfd_boolean
 bfd_hash_table_init (struct bfd_hash_table *table,
                     struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                                        struct bfd_hash_table *,
-                                                       const char *))
+                                                       const char *),
+                    unsigned int entsize)
 {
-  return bfd_hash_table_init_n (table, newfunc, bfd_default_hash_table_size);
+  return bfd_hash_table_init_n (table, newfunc, entsize,
+                               bfd_default_hash_table_size);
 }
 
 /* Free a hash table.  */
@@ -591,7 +595,8 @@ _bfd_stringtab_init (void)
   if (table == NULL)
     return NULL;
 
-  if (! bfd_hash_table_init (& table->table, strtab_hash_newfunc))
+  if (!bfd_hash_table_init (&table->table, strtab_hash_newfunc,
+                           sizeof (struct strtab_hash_entry)))
     {
       free (table);
       return NULL;
index 8b55b350075ad1d04c72933ff0680b1d895b4dd7..17c618006ff3207d1f1096f8f493adf5d8500266 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for linux flavored i386 a.out binaries.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2001, 2002, 2003,
-   2004 Free Software Foundation, Inc.
+   2004, 2006 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -231,8 +231,9 @@ linux_link_hash_table_create (abfd)
   ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
   if (ret == (struct linux_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
-  if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
-                                        linux_link_hash_newfunc))
+  if (!NAME(aout,link_hash_table_init) (&ret->root, abfd,
+                                       linux_link_hash_newfunc,
+                                       sizeof (struct linux_link_hash_entry)))
     {
       free (ret);
       return (struct bfd_link_hash_table *) NULL;
index 79f540221ef4f73a439791ad53c8a8703374e788..bb3ee80826740661c8b0eb80cbd012123355f74a 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end data structures for a.out (and similar) files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -575,7 +575,8 @@ extern bfd_boolean NAME (aout, link_hash_table_init)
   (struct aout_link_hash_table *, bfd *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 
 extern struct bfd_link_hash_table * NAME (aout, link_hash_table_create)
   (bfd *);
index e3468c1a9950cf391a13f0b32bef59cda76177f7..ee2484f25c12dc581a97e93cde1ffd726e690aad 100644 (file)
@@ -2,7 +2,7 @@
    (This include file is not for users of the library.)
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -53,6 +53,12 @@ struct bfd_in_memory
   bfd_byte *buffer;
 };
 
+struct section_hash_entry
+{
+  struct bfd_hash_entry root;
+  asection section;
+};
+
 /* tdata for an archive.  For an input archive, cache
    needs to be free()'d.  For an output archive, symdefs do.  */
 
@@ -468,7 +474,8 @@ extern bfd_boolean _bfd_link_hash_table_init
   (struct bfd_link_hash_table *, bfd *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 
 /* Generic link hash table creation routine.  */
 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
index 03e2fa527c1e954891497208f1797ebd098de06d..6d48036f8235d952856eef6dbd9bcf9be192c3dd 100644 (file)
@@ -58,6 +58,12 @@ struct bfd_in_memory
   bfd_byte *buffer;
 };
 
+struct section_hash_entry
+{
+  struct bfd_hash_entry root;
+  asection section;
+};
+
 /* tdata for an archive.  For an input archive, cache
    needs to be free()'d.  For an output archive, symdefs do.  */
 
@@ -473,7 +479,8 @@ extern bfd_boolean _bfd_link_hash_table_init
   (struct bfd_link_hash_table *, bfd *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 
 /* Generic link hash table creation routine.  */
 extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create
index 490f2a8046240e2f4b775c657cfca3b14d2920c1..f2bc264b3b9f703c43343c8a5de71b631d2da637 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD COFF object file private structure.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -421,7 +421,8 @@ struct coff_debug_merge_hash_table
 /* Initialize a COFF debug merge hash table.  */
 
 #define coff_debug_merge_hash_table_init(table) \
-  (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
+  (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
+                       sizeof (struct coff_debug_merge_hash_entry)))
 
 /* Free a COFF debug merge hash table.  */
 
@@ -537,7 +538,8 @@ extern bfd_boolean _bfd_coff_link_hash_table_init
   (struct coff_link_hash_table *, bfd *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
   (bfd *);
 extern const char *_bfd_coff_internal_syment_name
index 67ff404895a5130af3f557439333339f108e4aeb..b0b271c09a3a0a34de2184fabc2e7ad16de93277 100644 (file)
@@ -425,7 +425,8 @@ struct coff_debug_merge_hash_table
 /* Initialize a COFF debug merge hash table.  */
 
 #define coff_debug_merge_hash_table_init(table) \
-  (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc))
+  (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \
+                       sizeof (struct coff_debug_merge_hash_entry)))
 
 /* Free a COFF debug merge hash table.  */
 
@@ -541,7 +542,8 @@ extern bfd_boolean _bfd_coff_link_hash_table_init
   (struct coff_link_hash_table *, bfd *,
    struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
                               struct bfd_hash_table *,
-                              const char *));
+                              const char *),
+   unsigned int);
 extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create
   (bfd *);
 extern const char *_bfd_coff_internal_syment_name
index 67fe80451c2e4c97742327ae860fc7cdcf68a8ca..14eeae4df0c858d63dcdd4f299951fb39ad2775b 100644 (file)
@@ -1,6 +1,6 @@
 /* linker.c -- BFD linker routines
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -472,14 +472,15 @@ _bfd_link_hash_table_init
    bfd *abfd,
    struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                      struct bfd_hash_table *,
-                                     const char *))
+                                     const char *),
+   unsigned int entsize)
 {
   table->creator = abfd->xvec;
   table->undefs = NULL;
   table->undefs_tail = NULL;
   table->type = bfd_link_generic_hash_table;
 
-  return bfd_hash_table_init (&table->table, newfunc);
+  return bfd_hash_table_init (&table->table, newfunc, entsize);
 }
 
 /* Look up a symbol in a link hash table.  If follow is TRUE, we
@@ -709,7 +710,8 @@ _bfd_generic_link_hash_table_create (bfd *abfd)
   if (ret == NULL)
     return NULL;
   if (! _bfd_link_hash_table_init (&ret->root, abfd,
-                                  _bfd_generic_link_hash_newfunc))
+                                  _bfd_generic_link_hash_newfunc,
+                                  sizeof (struct generic_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -901,9 +903,10 @@ archive_hash_table_init
   (struct archive_hash_table *table,
    struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                      struct bfd_hash_table *,
-                                     const char *))
+                                     const char *),
+   unsigned int entsize)
 {
-  return bfd_hash_table_init (&table->table, newfunc);
+  return bfd_hash_table_init (&table->table, newfunc, entsize);
 }
 
 /* Look up an entry in an archive hash table.  */
@@ -981,7 +984,8 @@ _bfd_generic_link_add_archive_symbols
 
   /* In order to quickly determine whether an symbol is defined in
      this archive, we build a hash table of the symbols.  */
-  if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc))
+  if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc,
+                                sizeof (struct archive_hash_entry)))
     return FALSE;
   for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++)
     {
@@ -2952,7 +2956,9 @@ bfd_boolean
 bfd_section_already_linked_table_init (void)
 {
   return bfd_hash_table_init_n (&_bfd_section_already_linked_table,
-                               already_linked_newfunc, 42);
+                               already_linked_newfunc,
+                               sizeof (struct bfd_section_already_linked_hash_entry),
+                               42);
 }
 
 void
index e55fd546ab878fbd87b4e826d694c9b5ca3bd5ae..2c12a7c776e7cf329011f6fc87c81261770f8329 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for linux flavored m68k a.out binaries.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
-   2003, 2004 Free Software Foundation, Inc.
+   2003, 2004, 2006 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -235,8 +235,9 @@ linux_link_hash_table_create (abfd)
       bfd_set_error (bfd_error_no_memory);
       return (struct bfd_link_hash_table *) NULL;
     }
-  if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
-                                        linux_link_hash_newfunc))
+  if (!NAME(aout,link_hash_table_init) (&ret->root, abfd,
+                                       linux_link_hash_newfunc,
+                                       sizeof (struct linux_link_hash_entry)))
     {
       free (ret);
       return (struct bfd_link_hash_table *) NULL;
index 0c34821ebe11e881905995cf2e12c4e011bc45e8..c1795d29112f71c5c8748636919cd71cc9ea33c0 100644 (file)
@@ -1,5 +1,6 @@
 /* SEC_MERGE support.
-   Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
    Written by Jakub Jelinek <jakub@redhat.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -242,7 +243,7 @@ sec_merge_init (unsigned int entsize, bfd_boolean strings)
     return NULL;
 
   if (! bfd_hash_table_init_n (&table->table, sec_merge_hash_newfunc,
-                              16699))
+                              sizeof (struct sec_merge_hash_entry), 16699))
     {
       free (table);
       return NULL;
index 63f7b74d63e95ac8b326c996e533d15ecd3b1dab..b02b137889a1226df67357512cc056de39d451d0 100644 (file)
@@ -1,6 +1,6 @@
 /* opncls.c -- open and close a BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001, 2002, 2003, 2004, 2005
+   2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -71,7 +71,7 @@ _bfd_new_bfd (void)
   nbfd->iostream = NULL;
   nbfd->where = 0;
   if (!bfd_hash_table_init_n (& nbfd->section_htab, bfd_section_hash_newfunc,
-                             251))
+                             sizeof (struct section_hash_entry), 251))
     {
       free (nbfd);
       return NULL;
index 83029c46d04721d594d7efec7d033b09e39bd351..37f960f1992a809630ac85f7002db3760bb415ea 100644 (file)
@@ -1,5 +1,6 @@
 /* BFD back-end for PDP-11 a.out binaries.
-   Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -2446,9 +2447,10 @@ NAME (aout, link_hash_table_init) (struct aout_link_hash_table *table,
                                   bfd *abfd,
                                   struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
                                                                     struct bfd_hash_table *,
-                                                                    const char *))
+                                                                    const char *),
+                                  unsigned int entsize)
 {
-  return _bfd_link_hash_table_init (&table->root, abfd, newfunc);
+  return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize);
 }
 
 /* Create an a.out link hash table.  */
@@ -2463,7 +2465,8 @@ NAME (aout, link_hash_table_create) (bfd *abfd)
   if (ret == NULL)
     return NULL;
   if (! NAME (aout, link_hash_table_init) (ret, abfd,
-                                          NAME (aout, link_hash_newfunc)))
+                                          NAME (aout, link_hash_newfunc),
+                                          sizeof (struct aout_link_hash_entry)))
     {
       free (ret);
       return NULL;
@@ -3657,9 +3660,10 @@ NAME (aout, final_link) (bfd *abfd,
   aout_info.symbol_map = NULL;
   aout_info.output_syms = NULL;
 
-  if (! bfd_hash_table_init_n (&aout_info.includes.root,
-                              aout_link_includes_newfunc,
-                              251))
+  if (!bfd_hash_table_init_n (&aout_info.includes.root,
+                             aout_link_includes_newfunc,
+                             sizeof (struct aout_link_includes_entry),
+                             251))
     goto error_return;
   includes_hash_initialized = TRUE;
 
index 42554b9a63e788a44f3225660cee435303a937c2..f870e6bfc08a83331f883a02c5aeff7eefe68f8c 100644 (file)
@@ -1,6 +1,6 @@
 /* Object file "section" support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005
+   2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -713,12 +713,6 @@ STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);
 STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);
 #undef STD_SECTION
 
-struct section_hash_entry
-{
-  struct bfd_hash_entry root;
-  asection section;
-};
-
 /* Initialize an entry in the section hash table.  */
 
 struct bfd_hash_entry *
index 27e5f2f7752e0b9450186caf625fb7d604228111..d8659eec16ba67a82aa2b7dab46da2138b8459b8 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD back-end for linux flavored sparc a.out binaries.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
-   2003, 2004 Free Software Foundation, Inc.
+   2003, 2004, 2006 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -232,8 +232,9 @@ linux_link_hash_table_create (abfd)
   ret = (struct linux_link_hash_table *) bfd_malloc (amt);
   if (ret == (struct linux_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
-  if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
-                                        linux_link_hash_newfunc))
+  if (!NAME(aout,link_hash_table_init) (&ret->root, abfd,
+                                       linux_link_hash_newfunc,
+                                       sizeof (struct linux_link_hash_entry)))
     {
       free (ret);
       return (struct bfd_link_hash_table *) NULL;
index 25fae29ccc76331ae1272461729e423207157765..ba3f934461936d9ed9a498e762290665f855956b 100644 (file)
@@ -1,6 +1,6 @@
 /* Stabs in sections linking support.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -195,7 +195,8 @@ _bfd_link_section_stabs (bfd *abfd,
       /* Make sure the first byte is zero.  */
       (void) _bfd_stringtab_add (sinfo->strings, "", TRUE, TRUE);
       if (! bfd_hash_table_init (&sinfo->includes,
-                                stab_link_includes_newfunc))
+                                stab_link_includes_newfunc,
+                                sizeof (struct stab_link_includes_entry)))
        goto error_return;
       sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr");
       if (sinfo->stabstr == NULL)
index 03d386a2f8f20b6acd4e261758e6e64e38d2331b..024320fbfa18ceb98ccaa4ed8f5c12adae08db62 100644 (file)
@@ -1,6 +1,6 @@
 /* BFD backend for SunOS binaries.
    Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -679,8 +679,9 @@ sunos_link_hash_table_create (bfd *abfd)
   ret = bfd_malloc (amt);
   if (ret ==  NULL)
     return NULL;
-  if (! NAME (aout, link_hash_table_init) (&ret->root, abfd,
-                                          sunos_link_hash_newfunc))
+  if (!NAME (aout, link_hash_table_init) (&ret->root, abfd,
+                                         sunos_link_hash_newfunc,
+                                         sizeof (struct sunos_link_hash_entry)))
     {
       free (ret);
       return NULL;
index cdac38130127c1b6039b9c1d7118f13a0a45b093..e6ee98a53eec332ba7f4fd1ecf2cf14d71e819d8 100644 (file)
--- a/bfd/vms.c
+++ b/bfd/vms.c
@@ -1,7 +1,7 @@
 /* vms.c -- BFD back-end for VAX (openVMS/VAX) and
    EVAX (openVMS/Alpha) files.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2006 Free Software Foundation, Inc.
 
    Written by Klaus K"ampf (kkaempf@rmi.de)
 
@@ -77,7 +77,8 @@ vms_initialize (bfd * abfd)
   if (PRIV (vms_symbol_table) == NULL)
     goto error_ret1;
 
-  if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc))
+  if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc,
+                           sizeof (vms_symbol_entry)))
     goto error_ret1;
 
   amt = sizeof (struct location_struct) * LOCATION_SAVE_SIZE;
index b1cac27b2dc53357c386e00acc1563a919c9a5a1..47c330b6c15f1fd21f378d76fddb3698879a5049 100644 (file)
@@ -1,6 +1,6 @@
 /* POWER/PowerPC XCOFF linker support.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -444,7 +444,8 @@ _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd)
   ret = bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
-  if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
+  if (!_bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc,
+                                 sizeof (struct xcoff_link_hash_entry)))
     {
       free (ret);
       return NULL;
index a168029d71c2559455c854b4edb3290265eeab5b..3fc0dbe422d2377237820479b4551675a4caa4db 100644 (file)
@@ -1,3 +1,9 @@
+2006-03-16  Alan Modra  <amodra@bigpond.net.au>
+
+       PR 2434
+       * ieee.c (write_ieee_debugging_info): Adjust bfd_hash_table_init calls.
+       * wrstabs.c (write_stabs_in_sections_debugging_info): Likewise.
+
 2006-03-13  Ben Elliston  <bje@au.ibm.com>
 
        * bucomm.c (display_target_list): Make local variable `a' to be of
index 4ffd8f59eef21b56d50543c3a2356d5c9e465c7f..98ec30de9efdf106f5649dec228a97a094718a44 100644 (file)
@@ -1,5 +1,5 @@
 /* ieee.c -- Read and write IEEE-695 debugging information.
-   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
@@ -4594,8 +4594,10 @@ write_ieee_debugging_info (bfd *abfd, void *dhandle)
   info.type_indx = 256;
   info.name_indx = 32;
 
-  if (! bfd_hash_table_init (&info.typedefs.root, ieee_name_type_newfunc)
-      || ! bfd_hash_table_init (&info.tags.root, ieee_name_type_newfunc))
+  if (!bfd_hash_table_init (&info.typedefs.root, ieee_name_type_newfunc,
+                           sizeof (struct ieee_name_type_hash_entry))
+      || !bfd_hash_table_init (&info.tags.root, ieee_name_type_newfunc,
+                              sizeof (struct ieee_name_type_hash_entry)))
     return FALSE;
 
   if (! ieee_init_buffer (&info, &info.global_types)
index 0feb4e25a86e919471c09cb68b8ae88efc6f7407..b75d6df58450c51a63bdcf75b99e4d53b3d666b9 100644 (file)
@@ -1,5 +1,5 @@
 /* wrstabs.c -- Output stabs debugging information
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
@@ -480,8 +480,10 @@ write_stabs_in_sections_debugging_info (bfd *abfd, void *dhandle,
   /* Reserve 1 byte for a null byte.  */
   info.strings_size = 1;
 
-  if (! bfd_hash_table_init (&info.strhash.table, string_hash_newfunc)
-      || ! bfd_hash_table_init (&info.typedef_hash.table, string_hash_newfunc))
+  if (!bfd_hash_table_init (&info.strhash.table, string_hash_newfunc,
+                           sizeof (struct string_hash_entry))
+      || !bfd_hash_table_init (&info.typedef_hash.table, string_hash_newfunc,
+                              sizeof (struct string_hash_entry)))
     {
       non_fatal ("bfd_hash_table_init_failed: %s",
                 bfd_errmsg (bfd_get_error ()));
index 6f091b0bb95c585a34ddd1ff95eba619fdefdc6c..9005e8f2d705ae090582d73c4d626864a1ac67d5 100644 (file)
@@ -1,3 +1,11 @@
+2006-03-16  Alan Modra  <amodra@bigpond.net.au>
+
+       PR 2434
+       * ldcref.c (add_cref): Adjust bfd_hash_table_init calls.
+       * ldlang.c (output_statement_table_init, lang_init): Likewise.
+       * ldmain.c (add_ysym, add_wrap, add_keepsyms_file): Likewise.
+       (undefined_symbol): Likewise.
+
 2006-03-07  Richard Sandiford  <richard@codesourcery.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
            Zack Weinberg  <zack@codesourcery.com>
index bcb787bec5658ec2926ff2c44a5d3876fa52f8fa..7445aa8cf208612c72bb6835c4236ed70566f2cc 100644 (file)
@@ -1,5 +1,5 @@
 /* ldcref.c -- output a cross reference table
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>
 
@@ -149,7 +149,8 @@ add_cref (const char *name,
 
   if (! cref_initialized)
     {
-      if (! bfd_hash_table_init (&cref_table.root, cref_hash_newfunc))
+      if (!bfd_hash_table_init (&cref_table.root, cref_hash_newfunc,
+                               sizeof (struct cref_hash_entry)))
        einfo (_("%X%P: bfd_hash_table_init of cref table failed: %E\n"));
       cref_initialized = TRUE;
     }
index f51f68ef4b09054443d600bb8018f596dd2efb97..f6d849e19c9719fd3376841492d47da8fa5eb489 100644 (file)
@@ -1,6 +1,6 @@
 /* Linker command language support.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005
+   2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
@@ -933,8 +933,10 @@ output_statement_newfunc (struct bfd_hash_entry *entry,
 static void
 output_statement_table_init (void)
 {
-  if (! bfd_hash_table_init_n (&output_statement_table,
-                              output_statement_newfunc, 61))
+  if (!bfd_hash_table_init_n (&output_statement_table,
+                             output_statement_newfunc,
+                             sizeof (struct output_statement_hash_entry),
+                             61))
     einfo (_("%P%F: can not create hash table: %E\n"));
 }
 
@@ -974,7 +976,9 @@ lang_init (void)
      of code-complexity here in ld, besides the initialization which just
      looks like other code here.  */
   if (!bfd_hash_table_init_n (&lang_definedness_table,
-                             lang_definedness_newfunc, 3))
+                             lang_definedness_newfunc,
+                             sizeof (struct lang_definedness_hash_entry),
+                             3))
     einfo (_("%P%F: can not create hash table: %E\n"));
 }
 
index c8a75d6f9e18aee21ea323db056a8696f80e8b8d..3093bdb00c5ae50d6dff339f3aea7acc9039c2c3 100644 (file)
@@ -1,6 +1,6 @@
 /* Main program of GNU linker.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005
+   2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
@@ -777,9 +777,10 @@ add_ysym (const char *name)
   if (link_info.notice_hash == NULL)
     {
       link_info.notice_hash = xmalloc (sizeof (struct bfd_hash_table));
-      if (! bfd_hash_table_init_n (link_info.notice_hash,
-                                  bfd_hash_newfunc,
-                                  61))
+      if (!bfd_hash_table_init_n (link_info.notice_hash,
+                                 bfd_hash_newfunc,
+                                 sizeof (struct bfd_hash_entry),
+                                 61))
        einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
     }
 
@@ -795,9 +796,10 @@ add_wrap (const char *name)
   if (link_info.wrap_hash == NULL)
     {
       link_info.wrap_hash = xmalloc (sizeof (struct bfd_hash_table));
-      if (! bfd_hash_table_init_n (link_info.wrap_hash,
-                                  bfd_hash_newfunc,
-                                  61))
+      if (!bfd_hash_table_init_n (link_info.wrap_hash,
+                                 bfd_hash_newfunc,
+                                 sizeof (struct bfd_hash_entry),
+                                 61))
        einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
     }
 
@@ -827,7 +829,8 @@ add_keepsyms_file (const char *filename)
     }
 
   link_info.keep_hash = xmalloc (sizeof (struct bfd_hash_table));
-  if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc))
+  if (!bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc,
+                           sizeof (struct bfd_hash_entry)))
     einfo (_("%P%F: bfd_hash_table_init failed: %E\n"));
 
   bufsize = 100;
@@ -1326,7 +1329,8 @@ undefined_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
       if (hash == NULL)
        {
          hash = xmalloc (sizeof (struct bfd_hash_table));
-         if (! bfd_hash_table_init (hash, bfd_hash_newfunc))
+         if (!bfd_hash_table_init (hash, bfd_hash_newfunc,
+                                   sizeof (struct bfd_hash_entry)))
            einfo (_("%F%P: bfd_hash_table_init failed: %E\n"));
        }
 
This page took 0.102463 seconds and 4 git commands to generate.