ld --as-needed assertion fail, BFD internal error and crash

Alan Modra amodra@bigpond.net.au
Thu Mar 16 12:37:00 GMT 2006


PR 2434 is a problem caused by incomplete restore of symbol table state
after deciding that an as-needed shared lib is not in fact needed.  This
patch addresses that by taking a snapshot of the sym hash table before
loading an as-needed lib, then restoring afterwards if the lib isn't
needed.  Unfortunately, to do this we need to know the size of hash
table entries, so I had to touch lots of files.  It also can use quite
a bit of memory.  On the plus side, we do get a complete restore.

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.

Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.204
diff -u -p -d -r1.204 elflink.c
--- bfd/elflink.c	25 Feb 2006 09:23:30 -0000	1.204
+++ bfd/elflink.c	16 Mar 2006 11:51:12 -0000
@@ -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, st
 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, 
   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, 
 	 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 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, 
 
 	      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, 
 	 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, 
 		  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, 
       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, 
 	}
     }
 
-  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, 
 
       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, 
 		 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, 
 	    }
 	  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, 
 	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, 
 		  && 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, 
 	}
 
       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, 
 	  && 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, 
 	    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, 
 	      && (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, 
 		{
 		  /* 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, 
 		  && ! 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, 
 	}
     }
 
+  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, 
 	  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, 
       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, 
       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, 
 
      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, 
 	  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, 
      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_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, 
 	}
     }
 
-  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, 
       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: bfd/bfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in.h,v
retrieving revision 1.112
diff -u -p -r1.112 bfd-in.h
--- bfd/bfd-in.h	7 Feb 2006 19:01:09 -0000	1.112
+++ bfd/bfd-in.h	16 Mar 2006 09:20:43 -0000
@@ -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: bfd/hash.c
===================================================================
RCS file: /cvs/src/src/bfd/hash.c,v
retrieving revision 1.19
diff -u -p -r1.19 hash.c
--- bfd/hash.c	29 Dec 2005 10:33:40 -0000	1.19
+++ bfd/hash.c	16 Mar 2006 09:22:09 -0000
@@ -308,6 +308,7 @@ bfd_hash_table_init_n (struct bfd_hash_t
 		       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_t
     }
   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: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.204
diff -u -p -r1.204 elf-bfd.h
--- bfd/elf-bfd.h	25 Feb 2006 09:23:30 -0000	1.204
+++ bfd/elf-bfd.h	16 Mar 2006 09:21:00 -0000
@@ -1489,7 +1489,8 @@ extern bfd_boolean _bfd_elf_link_hash_fi
 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: bfd/aoutx.h
===================================================================
RCS file: /cvs/src/src/bfd/aoutx.h,v
retrieving revision 1.59
diff -u -p -r1.59 aoutx.h
--- bfd/aoutx.h	28 Oct 2005 13:50:57 -0000	1.59
+++ bfd/aoutx.h	16 Mar 2006 09:20:42 -0000
@@ -2859,9 +2859,10 @@ NAME (aout, link_hash_table_init) (struc
 				   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
   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: bfd/bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.80
diff -u -p -r1.80 bfd.c
--- bfd/bfd.c	21 Feb 2006 00:14:49 -0000	1.80
+++ bfd/bfd.c	16 Mar 2006 09:20:46 -0000
@@ -1440,7 +1440,8 @@ bfd_preserve_save (bfd *abfd, struct bfd
   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: bfd/coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.62
diff -u -p -r1.62 coff-arm.c
--- bfd/coff-arm.c	4 May 2005 15:53:02 -0000	1.62
+++ bfd/coff-arm.c	16 Mar 2006 09:20:47 -0000
@@ -879,8 +879,10 @@ coff_arm_link_hash_table_create (bfd * a
   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: bfd/coff-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-h8300.c,v
retrieving revision 1.37
diff -u -p -r1.37 coff-h8300.c
--- bfd/coff-h8300.c	27 Dec 2005 03:06:27 -0000	1.37
+++ bfd/coff-h8300.c	16 Mar 2006 09:20:48 -0000
@@ -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_
 			 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 *
   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, s
 
       /* 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: bfd/coff-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-ppc.c,v
retrieving revision 1.28
diff -u -p -r1.28 coff-ppc.c
--- bfd/coff-ppc.c	4 May 2005 15:53:03 -0000	1.28
+++ bfd/coff-ppc.c	16 Mar 2006 09:20:49 -0000
@@ -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
 /* 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: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.57
diff -u -p -r1.57 cofflink.c
--- bfd/cofflink.c	17 Aug 2005 08:58:01 -0000	1.57
+++ bfd/cofflink.c	16 Mar 2006 09:20:54 -0000
@@ -94,10 +94,11 @@ _bfd_coff_link_hash_table_init (struct c
 				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 *a
     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: bfd/ecoff.c
===================================================================
RCS file: /cvs/src/src/bfd/ecoff.c,v
retrieving revision 1.49
diff -u -p -r1.49 ecoff.c
--- bfd/ecoff.c	27 Dec 2005 03:06:27 -0000	1.49
+++ bfd/ecoff.c	16 Mar 2006 09:20:57 -0000
@@ -3285,8 +3285,9 @@ _bfd_ecoff_bfd_link_hash_table_create (b
   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: bfd/ecofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/ecofflink.c,v
retrieving revision 1.19
diff -u -p -r1.19 ecofflink.c
--- bfd/ecofflink.c	6 Oct 2005 19:21:13 -0000	1.19
+++ bfd/ecofflink.c	16 Mar 2006 09:20:58 -0000
@@ -501,8 +501,8 @@ bfd_ecoff_debug_init (output_bfd, output
   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
 
   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: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.72
diff -u -p -r1.72 elf-m10300.c
--- bfd/elf-m10300.c	27 Feb 2006 08:48:28 -0000	1.72
+++ bfd/elf-m10300.c	16 Mar 2006 09:21:03 -0000
@@ -3695,8 +3695,9 @@ elf32_mn10300_link_hash_table_create (ab
   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 (ab
       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: bfd/elf-strtab.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-strtab.c,v
retrieving revision 1.11
diff -u -p -r1.11 elf-strtab.c
--- bfd/elf-strtab.c	4 May 2005 15:53:11 -0000	1.11
+++ bfd/elf-strtab.c	16 Mar 2006 09:21:04 -0000
@@ -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: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.328
diff -u -p -r1.328 elf.c
--- bfd/elf.c	16 Feb 2006 18:07:54 -0000	1.328
+++ bfd/elf.c	16 Mar 2006 09:21:08 -0000
@@ -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 *ab
   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: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.69
diff -u -p -r1.69 elf32-arm.c
--- bfd/elf32-arm.c	14 Mar 2006 23:58:07 -0000	1.69
+++ bfd/elf32-arm.c	16 Mar 2006 09:21:12 -0000
@@ -1967,7 +1967,8 @@ elf32_arm_link_hash_table_create (bfd *a
     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: bfd/elf32-bfin.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-bfin.c,v
retrieving revision 1.4
diff -u -p -r1.4 elf32-bfin.c
--- bfd/elf32-bfin.c	27 Feb 2006 08:48:28 -0000	1.4
+++ bfd/elf32-bfin.c	16 Mar 2006 09:21:13 -0000
@@ -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: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.72
diff -u -p -r1.72 elf32-cris.c
--- bfd/elf32-cris.c	27 Feb 2006 08:48:28 -0000	1.72
+++ bfd/elf32-cris.c	16 Mar 2006 09:21:16 -0000
@@ -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: bfd/elf32-frv.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-frv.c,v
retrieving revision 1.45
diff -u -p -r1.45 elf32-frv.c
--- bfd/elf32-frv.c	25 Feb 2006 09:23:30 -0000	1.45
+++ bfd/elf32-frv.c	16 Mar 2006 09:21:19 -0000
@@ -1008,8 +1008,9 @@ frvfdpic_elf_link_hash_table_create (bfd
   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: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.143
diff -u -p -r1.143 elf32-hppa.c
--- bfd/elf32-hppa.c	27 Feb 2006 08:48:28 -0000	1.143
+++ bfd/elf32-hppa.c	16 Mar 2006 09:21:21 -0000
@@ -394,14 +394,16 @@ elf32_hppa_link_hash_table_create (bfd *
   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: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.157
diff -u -p -r1.157 elf32-i386.c
--- bfd/elf32-i386.c	2 Mar 2006 08:56:59 -0000	1.157
+++ bfd/elf32-i386.c	16 Mar 2006 09:21:23 -0000
@@ -721,7 +721,8 @@ elf_i386_link_hash_table_create (bfd *ab
   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: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.79
diff -u -p -r1.79 elf32-m32r.c
--- bfd/elf32-m32r.c	27 Feb 2006 08:48:28 -0000	1.79
+++ bfd/elf32-m32r.c	16 Mar 2006 09:21:26 -0000
@@ -1572,8 +1572,9 @@ m32r_elf_link_hash_table_create (bfd *ab
   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: bfd/elf32-m68hc1x.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68hc1x.c,v
retrieving revision 1.24
diff -u -p -r1.24 elf32-m68hc1x.c
--- bfd/elf32-m68hc1x.c	20 Jun 2005 18:12:07 -0000	1.24
+++ bfd/elf32-m68hc1x.c	16 Mar 2006 09:21:26 -0000
@@ -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: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.87
diff -u -p -r1.87 elf32-m68k.c
--- bfd/elf32-m68k.c	6 Mar 2006 13:42:03 -0000	1.87
+++ bfd/elf32-m68k.c	16 Mar 2006 09:21:27 -0000
@@ -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: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.194
diff -u -p -r1.194 elf32-ppc.c
--- bfd/elf32-ppc.c	15 Mar 2006 14:30:18 -0000	1.194
+++ bfd/elf32-ppc.c	16 Mar 2006 09:21:31 -0000
@@ -2430,8 +2430,9 @@ ppc_elf_link_hash_table_create (bfd *abf
   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: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.81
diff -u -p -r1.81 elf32-s390.c
--- bfd/elf32-s390.c	27 Feb 2006 08:48:28 -0000	1.81
+++ bfd/elf32-s390.c	16 Mar 2006 09:21:33 -0000
@@ -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: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.135
diff -u -p -r1.135 elf32-sh.c
--- bfd/elf32-sh.c	27 Feb 2006 08:48:28 -0000	1.135
+++ bfd/elf32-sh.c	16 Mar 2006 09:21:37 -0000
@@ -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: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.35
diff -u -p -r1.35 elf32-vax.c
--- bfd/elf32-vax.c	27 Feb 2006 08:48:28 -0000	1.35
+++ bfd/elf32-vax.c	16 Mar 2006 09:21:37 -0000
@@ -468,8 +468,9 @@ elf_vax_link_hash_table_create (bfd *abf
   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: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.149
diff -u -p -r1.149 elf64-alpha.c
--- bfd/elf64-alpha.c	27 Feb 2006 08:48:28 -0000	1.149
+++ bfd/elf64-alpha.c	16 Mar 2006 09:21:40 -0000
@@ -273,8 +273,9 @@ elf64_alpha_bfd_link_hash_table_create (
   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: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.67
diff -u -p -r1.67 elf64-hppa.c
--- bfd/elf64-hppa.c	4 Dec 2005 14:58:11 -0000	1.67
+++ bfd/elf64-hppa.c	16 Mar 2006 09:21:42 -0000
@@ -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_typ
   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: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.234
diff -u -p -r1.234 elf64-ppc.c
--- bfd/elf64-ppc.c	17 Feb 2006 12:52:58 -0000	1.234
+++ bfd/elf64-ppc.c	16 Mar 2006 09:21:47 -0000
@@ -3464,18 +3464,21 @@ ppc64_elf_link_hash_table_create (bfd *a
   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: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.81
diff -u -p -r1.81 elf64-s390.c
--- bfd/elf64-s390.c	27 Feb 2006 08:48:28 -0000	1.81
+++ bfd/elf64-s390.c	16 Mar 2006 09:21:48 -0000
@@ -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: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.66
diff -u -p -r1.66 elf64-sh64.c
--- bfd/elf64-sh64.c	27 Feb 2006 08:48:28 -0000	1.66
+++ bfd/elf64-sh64.c	16 Mar 2006 09:21:51 -0000
@@ -3138,8 +3138,9 @@ sh64_elf64_link_hash_table_create (bfd *
   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: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.111
diff -u -p -r1.111 elf64-x86-64.c
--- bfd/elf64-x86-64.c	27 Feb 2006 08:48:28 -0000	1.111
+++ bfd/elf64-x86-64.c	16 Mar 2006 09:21:52 -0000
@@ -510,7 +510,8 @@ elf64_x86_64_link_hash_table_create (bfd
   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: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.179
diff -u -p -r1.179 elfxx-ia64.c
--- bfd/elfxx-ia64.c	8 Mar 2006 21:24:22 -0000	1.179
+++ bfd/elfxx-ia64.c	16 Mar 2006 09:22:01 -0000
@@ -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: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.161
diff -u -p -r1.161 elfxx-mips.c
--- bfd/elfxx-mips.c	14 Mar 2006 07:47:49 -0000	1.161
+++ bfd/elfxx-mips.c	16 Mar 2006 09:22:08 -0000
@@ -8944,8 +8944,9 @@ _bfd_mips_elf_link_hash_table_create (bf
   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: bfd/elfxx-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-sparc.c,v
retrieving revision 1.19
diff -u -p -r1.19 elfxx-sparc.c
--- bfd/elfxx-sparc.c	27 Feb 2006 08:48:28 -0000	1.19
+++ bfd/elfxx-sparc.c	16 Mar 2006 09:22:09 -0000
@@ -810,7 +810,8 @@ _bfd_sparc_elf_link_hash_table_create (b
       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: bfd/i386linux.c
===================================================================
RCS file: /cvs/src/src/bfd/i386linux.c,v
retrieving revision 1.15
diff -u -p -r1.15 i386linux.c
--- bfd/i386linux.c	4 May 2005 15:53:32 -0000	1.15
+++ bfd/i386linux.c	16 Mar 2006 09:22:10 -0000
@@ -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: bfd/libaout.h
===================================================================
RCS file: /cvs/src/src/bfd/libaout.h,v
retrieving revision 1.22
diff -u -p -r1.22 libaout.h
--- bfd/libaout.h	23 May 2005 17:44:54 -0000	1.22
+++ bfd/libaout.h	16 Mar 2006 09:22:10 -0000
@@ -575,7 +575,8 @@ extern bfd_boolean NAME (aout, link_hash
   (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: bfd/section.c
===================================================================
RCS file: /cvs/src/src/bfd/section.c,v
retrieving revision 1.90
diff -u -p -r1.90 section.c
--- bfd/section.c	25 Jul 2005 15:35:37 -0000	1.90
+++ bfd/section.c	16 Mar 2006 09:22:19 -0000
@@ -713,12 +713,6 @@ STD_SECTION (bfd_abs_section, 0, bfd_abs
 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: bfd/libbfd-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd-in.h,v
retrieving revision 1.62
diff -u -p -r1.62 libbfd-in.h
--- bfd/libbfd-in.h	24 Dec 2005 08:37:38 -0000	1.62
+++ bfd/libbfd-in.h	16 Mar 2006 09:22:11 -0000
@@ -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_
   (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: bfd/libcoff-in.h
===================================================================
RCS file: /cvs/src/src/bfd/libcoff-in.h,v
retrieving revision 1.28
diff -u -p -r1.28 libcoff-in.h
--- bfd/libcoff-in.h	23 May 2005 17:44:54 -0000	1.28
+++ bfd/libcoff-in.h	16 Mar 2006 09:22:12 -0000
@@ -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_t
   (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: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.52
diff -u -p -r1.52 linker.c
--- bfd/linker.c	27 Dec 2005 03:06:27 -0000	1.52
+++ bfd/linker.c	16 Mar 2006 09:22:14 -0000
@@ -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
   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: bfd/m68klinux.c
===================================================================
RCS file: /cvs/src/src/bfd/m68klinux.c,v
retrieving revision 1.17
diff -u -p -r1.17 m68klinux.c
--- bfd/m68klinux.c	4 May 2005 15:53:35 -0000	1.17
+++ bfd/m68klinux.c	16 Mar 2006 09:22:14 -0000
@@ -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: bfd/merge.c
===================================================================
RCS file: /cvs/src/src/bfd/merge.c,v
retrieving revision 1.28
diff -u -p -r1.28 merge.c
--- bfd/merge.c	4 May 2005 15:53:35 -0000	1.28
+++ bfd/merge.c	16 Mar 2006 09:22:15 -0000
@@ -242,7 +242,7 @@ sec_merge_init (unsigned int entsize, bf
     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: bfd/opncls.c
===================================================================
RCS file: /cvs/src/src/bfd/opncls.c,v
retrieving revision 1.41
diff -u -p -r1.41 opncls.c
--- bfd/opncls.c	3 Nov 2005 16:06:11 -0000	1.41
+++ bfd/opncls.c	16 Mar 2006 09:22:15 -0000
@@ -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: bfd/pdp11.c
===================================================================
RCS file: /cvs/src/src/bfd/pdp11.c,v
retrieving revision 1.33
diff -u -p -r1.33 pdp11.c
--- bfd/pdp11.c	18 Aug 2005 03:48:26 -0000	1.33
+++ bfd/pdp11.c	16 Mar 2006 09:22:18 -0000
@@ -2446,9 +2446,10 @@ NAME (aout, link_hash_table_init) (struc
 				   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 +2464,8 @@ NAME (aout, link_hash_table_create) (bfd
   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 +3659,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: bfd/sparclinux.c
===================================================================
RCS file: /cvs/src/src/bfd/sparclinux.c,v
retrieving revision 1.17
diff -u -p -r1.17 sparclinux.c
--- bfd/sparclinux.c	4 May 2005 15:53:39 -0000	1.17
+++ bfd/sparclinux.c	16 Mar 2006 09:22:19 -0000
@@ -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: bfd/stabs.c
===================================================================
RCS file: /cvs/src/src/bfd/stabs.c,v
retrieving revision 1.25
diff -u -p -r1.25 stabs.c
--- bfd/stabs.c	29 Dec 2005 10:29:23 -0000	1.25
+++ bfd/stabs.c	16 Mar 2006 09:22:20 -0000
@@ -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: bfd/sunos.c
===================================================================
RCS file: /cvs/src/src/bfd/sunos.c,v
retrieving revision 1.21
diff -u -p -r1.21 sunos.c
--- bfd/sunos.c	4 May 2005 15:53:39 -0000	1.21
+++ bfd/sunos.c	16 Mar 2006 09:22:21 -0000
@@ -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: bfd/vms.c
===================================================================
RCS file: /cvs/src/src/bfd/vms.c,v
retrieving revision 1.37
diff -u -p -r1.37 vms.c
--- bfd/vms.c	23 May 2005 17:44:55 -0000	1.37
+++ bfd/vms.c	16 Mar 2006 09:22:22 -0000
@@ -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: bfd/xcofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/xcofflink.c,v
retrieving revision 1.43
diff -u -p -r1.43 xcofflink.c
--- bfd/xcofflink.c	4 May 2005 15:53:41 -0000	1.43
+++ bfd/xcofflink.c	16 Mar 2006 09:22:25 -0000
@@ -444,7 +444,8 @@ _bfd_xcoff_bfd_link_hash_table_create (b
   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: binutils/ieee.c
===================================================================
RCS file: /cvs/src/src/binutils/ieee.c,v
retrieving revision 1.17
diff -u -p -r1.17 ieee.c
--- binutils/ieee.c	8 May 2005 14:17:38 -0000	1.17
+++ binutils/ieee.c	16 Mar 2006 09:22:30 -0000
@@ -4594,8 +4594,10 @@ write_ieee_debugging_info (bfd *abfd, vo
   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: binutils/wrstabs.c
===================================================================
RCS file: /cvs/src/src/binutils/wrstabs.c,v
retrieving revision 1.12
diff -u -p -r1.12 wrstabs.c
--- binutils/wrstabs.c	8 May 2005 14:17:39 -0000	1.12
+++ binutils/wrstabs.c	16 Mar 2006 09:22:30 -0000
@@ -480,8 +480,10 @@ write_stabs_in_sections_debugging_info (
   /* 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: ld/ldcref.c
===================================================================
RCS file: /cvs/src/src/ld/ldcref.c,v
retrieving revision 1.13
diff -u -p -r1.13 ldcref.c
--- ld/ldcref.c	5 Oct 2005 16:12:17 -0000	1.13
+++ ld/ldcref.c	16 Mar 2006 09:22:47 -0000
@@ -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: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.212
diff -u -p -r1.212 ldlang.c
--- ld/ldlang.c	24 Dec 2005 07:48:30 -0000	1.212
+++ ld/ldlang.c	16 Mar 2006 09:22:50 -0000
@@ -933,8 +933,10 @@ output_statement_newfunc (struct bfd_has
 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: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.104
diff -u -p -r1.104 ldmain.c
--- ld/ldmain.c	6 Nov 2005 23:12:36 -0000	1.104
+++ ld/ldmain.c	16 Mar 2006 09:22:51 -0000
@@ -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 *
       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"));
 	}
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list