This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[16/17] share minimal symbols


This patch makes us actually share minimal symbols.

It moves various things out of objfile and into a new
objfile_per_bfd_storage structure.  This structure is attached to the
BFD.

Minimal symbols are moved here, the goal of this series.

The filename bcache is moved here, as this is harmless and a decent
memory saver.

There is a second demangled_names_hash here.  We can't share these yet
as they can refer to a from debug sections.  (A patch series sharing
partial and full symbols would have to arrange for debug sections to
remain mapped as well... section data is a decent candidate for sharing
that I will probably look at for other reasons.)

There is a hack in here to disable reading minimal symbols if they have
already been read: we tell minsyms.c to suppress them (see inhibit_hash)
and continue on; after reading minsyms they are simply dropped.

I took this approach because, to my surprise, many of the symbol readers
mix minsym reading in with psymbol reading.  ELF does this separately,
though, so I also added a SYMFILE_MINSYMS_READ flag so that some symbol
readers could bypass the work when possible.  I didn't fix up elfread.c
to do this yet, though.

A few hunks in this patch (elfread.c, hppa-hpux-tdep.c, jit.c) could
probably just go in immediately.

Tom

>From 9e4bbdbbf90d99ebe902d965f0078c6d3b005c8b Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Thu, 8 Dec 2011 10:14:08 -0700
Subject: [PATCH 16/18] make minsym sharing work

	* elfread.c (elf_symtab_read): Put the filename in the filename
	bcache.
	* hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence): Use
	ALL_OBJFILE_MSYMBOLS.
	(hppa_hpux_find_dummy_bpaddr): Likewise.
	* jit.c (jit_object_close_impl): Use
	terminate_minimal_symbol_table.
	* minsyms.c (inhibit_hash): New global.
	(msymbol_objfile): Update.
	(lookup_minimal_symbol_full): Update.
	(iterate_over_minimal_symbols): Update.
	(lookup_minimal_symbol_text): Update.
	(lookup_minimal_symbol_by_pc_name): Update.
	(lookup_minimal_symbol_solib_trampoline): Update.
	(lookup_minimal_symbol_by_pc_section_1): Update.
	(lookup_minimal_symbol_and_objfile): Update.
	(prim_record_minimal_symbol_full): Check inhibit_hash.
	(make_cleanup_discard_minimal_symbols): Update comment.
	(build_minimal_symbol_hash_tables): Update.
	(install_minimal_symbols): Check inhibit_hash.  Allocate on
	per-BFD obstack.  Update.
	(remove_objfile_from_hash, inhibit_minimal_symbol_registration):
	New functions.
	* minsyms.h (inhibit_minimal_symbol_registration): Declare.
	* objfiles.c (objfiles_bfd_data): New global.
	(get_objfile_bfd_data, free_objfile_per_bfd_storage)
	(objfile_bfd_data_free, set_objfile_per_bfd): New functions.
	(allocate_objfile): Don't initialize filename_cache.  Call
	terminate_minimal_symbol_table later.  Set per_bfd field.
	(free_objfile): Call free_objfile_per_bfd_storage.  Update.
	(have_minimal_symbols): Update.
	(_initialize_objfiles): Initialize objfiles_bfd_data.
	* objfiles.h (struct objfile_per_bfd_storage): New.
	(struct objfile) <per_bfd>: New field.
	<filename_cache, msymbols, minimal_symbol_count, msymbol_hash,
	msymbol_demangled_hash>: Remove.
	(ALL_OBJFILE_MSYMBOLS): Update.
	(set_objfile_per_bfd): Declare.
	* symfile.c (syms_from_objfile): Set SYMFILE_MINSYMS_READ and call
	inhibit_minimal_symbol_registration when needed.
	(reread_symbols): Likewise.  Update.
	(allocate_symtab): Update.
	* symfile.h (enum symfile_add_flags) <SYMFILE_MINSYMS_READ>: New
	constant.
	* symmisc.c (print_symbol_bcache_statistics): Update.
	(print_objfile_statistics): Update.
	(dump_objfile): Update.
	(dump_msymbols): Update.
	* symtab.c (symbol_init_cplus_specific): Remove objfile argument,
	add obstack argument.
	(symbol_set_demangled_name): Likewise.
	(create_demangled_names_hash): Change argument type.
	(symbol_set_names): Remove objfile argument, add storage and
	demangled_names_hash arguments.
	* symtab.h (symbol_set_demangled_name): Update.
	(SYMBOL_SET_NAMES): Update.
	(symbol_set_names): Update.
	(MSYMBOL_SET_NAMES): Update.
---
 gdb/elfread.c        |   10 ++--
 gdb/hppa-hpux-tdep.c |    8 +---
 gdb/jit.c            |    4 +-
 gdb/minsyms.c        |  121 ++++++++++++++++++++++++++++++++++----------------
 gdb/minsyms.h        |   10 ++++
 gdb/objfiles.c       |   73 ++++++++++++++++++++++++++++--
 gdb/objfiles.h       |   87 +++++++++++++++++++++++++----------
 gdb/symfile.c        |   44 +++++++++++++-----
 gdb/symfile.h        |    9 +++-
 gdb/symmisc.c        |   16 ++++---
 gdb/symtab.c         |   33 +++++++-------
 gdb/symtab.h         |   13 ++++--
 12 files changed, 305 insertions(+), 123 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index 8f0bde0..bfea8b6 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -44,6 +44,7 @@
 #include "gdbthread.h"
 #include "regcache.h"
 #include "gdb_bfd.h"
+#include "bcache.h"
 
 extern void _initialize_elfread (void);
 
@@ -241,8 +242,8 @@ elf_symtab_read (struct objfile *objfile, int type,
      seen any section info for it yet.  */
   asymbol *filesym = 0;
   /* Name of filesym.  This is either a constant string or is saved on
-     the objfile's obstack.  */
-  char *filesymname = "";
+     the BFD's filename cache.  */
+  const char *filesymname = "";
   struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info;
   int stripped = (bfd_get_symcount (objfile->obfd) == 0);
 
@@ -330,9 +331,8 @@ elf_symtab_read (struct objfile *objfile, int type,
 	      sectinfo = NULL;
 	    }
 	  filesym = sym;
-	  filesymname =
-	    obsavestring ((char *) filesym->name, strlen (filesym->name),
-			  &objfile->objfile_obstack);
+	  filesymname = bcache (filesym->name, strlen (filesym->name) + 1,
+				objfile->per_bfd->filename_cache);
 	}
       else if (sym->flags & BSF_SECTION_SYM)
 	continue;
diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c
index e750874..55cf6e0 100644
--- a/gdb/hppa-hpux-tdep.c
+++ b/gdb/hppa-hpux-tdep.c
@@ -958,7 +958,6 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
   struct hppa_objfile_private *priv;
   CORE_ADDR addr;
   struct minimal_symbol *msym;
-  int i;
 
   sec = find_pc_section (pc);
   obj = sec->objfile;
@@ -981,7 +980,7 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
      scheme; try to read in blocks of code, and look for a "bve,n (rp)" 
      instruction.  These are likely to occur at the end of functions, so
      we only look at the last two instructions of each function.  */
-  for (i = 0, msym = obj->msymbols; i < obj->minimal_symbol_count; i++, msym++)
+  ALL_OBJFILE_MSYMBOLS (obj, msym)
     {
       CORE_ADDR begin, end;
       char *name;
@@ -1089,7 +1088,6 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
   struct unwind_table_entry *u;
   struct minimal_symbol *msym;
   CORE_ADDR func;
-  int i;
 
   sec = find_pc_section (addr);
   if (sec)
@@ -1109,9 +1107,7 @@ hppa_hpux_find_dummy_bpaddr (CORE_ADDR addr)
 	 work.  */
 
       find_pc_partial_function (addr, NULL, &func, NULL);
-      for (i = 0, msym = sec->objfile->msymbols;
-      	   i < sec->objfile->minimal_symbol_count;
-	   i++, msym++)
+      ALL_OBJFILE_MSYMBOLS (sec->objfile, msym)
 	{
 	  u = find_unwind_entry (MSYMBOL_VALUE_ADDRESS (msym));
 	  if (func != MSYMBOL_VALUE_ADDRESS (msym) 
diff --git a/gdb/jit.c b/gdb/jit.c
index 29e559a..e35d239 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -694,9 +694,7 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
   objfile = allocate_objfile (NULL, 0);
   objfile->gdbarch = target_gdbarch;
 
-  objfile->msymbols = obstack_alloc (&objfile->objfile_obstack,
-                                     sizeof (struct minimal_symbol));
-  memset (objfile->msymbols, 0, sizeof (struct minimal_symbol));
+  terminate_minimal_symbol_table (objfile);
 
   xfree (objfile->name);
   objfile->name = xstrdup ("<< JIT compiled code >>");
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 4352cd2..877d5a3 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -78,6 +78,10 @@ static int msym_bunch_index;
 
 static int msym_count;
 
+/* If an objfile is in this hash, then minsyms are inhibited for it.  */
+
+static htab_t inhibit_hash;
+
 /* Compute a hash code based using the same criteria as `strcmp_iw'.  */
 
 unsigned int
@@ -153,7 +157,7 @@ msymbol_objfile (const struct minimal_symbol *sym)
     = msymbol_hash (MSYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
 
   for (objf = object_files; objf; objf = objf->next)
-    for (tsym = objf->msymbol_hash[hash]; tsym; tsym = tsym->hash_next)
+    for (tsym = objf->per_bfd->msymbol_hash[hash]; tsym; tsym = tsym->hash_next)
       if (tsym == sym)
 	return objf;
 
@@ -233,9 +237,9 @@ lookup_minimal_symbol_full (const char *name, const char *sfile,
 	    {
             /* Select hash list according to pass.  */
             if (pass == 1)
-              msymbol = objfile->msymbol_hash[hash];
+              msymbol = objfile->per_bfd->msymbol_hash[hash];
             else
-              msymbol = objfile->msymbol_demangled_hash[dem_hash];
+              msymbol = objfile->per_bfd->msymbol_demangled_hash[dem_hash];
 
             while (msymbol != NULL && found_symbol == NULL)
 		{
@@ -360,7 +364,7 @@ iterate_over_minimal_symbols (struct objfile *objf, const char *name,
 
   /* The first pass is over the ordinary hash table.  */
   hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
-  iter = objf->msymbol_hash[hash];
+  iter = objf->per_bfd->msymbol_hash[hash];
   cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp);
   while (iter)
     {
@@ -371,7 +375,7 @@ iterate_over_minimal_symbols (struct objfile *objf, const char *name,
 
   /* The second pass is over the demangled table.  */
   hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
-  iter = objf->msymbol_demangled_hash[hash];
+  iter = objf->per_bfd->msymbol_demangled_hash[hash];
   while (iter)
     {
       if (MSYMBOL_MATCHES_SEARCH_NAME (iter, name))
@@ -404,7 +408,7 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf)
       if (objf == NULL || objf == objfile
 	  || objf == objfile->separate_debug_objfile_backlink)
 	{
-	  for (msymbol = objfile->msymbol_hash[hash];
+	  for (msymbol = objfile->per_bfd->msymbol_hash[hash];
 	       msymbol != NULL && found_symbol == NULL;
 	       msymbol = msymbol->hash_next)
 	    {
@@ -458,7 +462,7 @@ lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
       if (objf == NULL || objf == objfile
 	  || objf == objfile->separate_debug_objfile_backlink)
 	{
-	  for (msymbol = objfile->msymbol_hash[hash];
+	  for (msymbol = objfile->per_bfd->msymbol_hash[hash];
 	       msymbol != NULL;
 	       msymbol = msymbol->hash_next)
 	    {
@@ -497,7 +501,7 @@ lookup_minimal_symbol_solib_trampoline (const char *name,
       if (objf == NULL || objf == objfile
 	  || objf == objfile->separate_debug_objfile_backlink)
 	{
-	  for (msymbol = objfile->msymbol_hash[hash];
+	  for (msymbol = objfile->per_bfd->msymbol_hash[hash];
 	       msymbol != NULL && found_symbol == NULL;
 	       msymbol = msymbol->hash_next)
 	    {
@@ -587,13 +591,13 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in,
          "null symbol".  If there are no real symbols, then there is no
          minimal symbol table at all.  */
 
-      if (objfile->minimal_symbol_count > 0)
+      if (objfile->per_bfd->minimal_symbol_count > 0)
 	{
 	  int best_zero_sized = -1;
 
-          msymbol = objfile->msymbols;
+          msymbol = objfile->per_bfd->msymbols;
 	  lo = 0;
-	  hi = objfile->minimal_symbol_count - 1;
+	  hi = objfile->per_bfd->minimal_symbol_count - 1;
 
 	  /* FIXME
 	     fix up the comment here
@@ -639,7 +643,7 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc_in,
 	      /* If we have multiple symbols at the same address, we want
 	         hi to point to the last one.  That way we can find the
 	         right symbol if it has an index greater than hi.  */
-	      while (hi < objfile->minimal_symbol_count - 1
+	      while (hi < objfile->per_bfd->minimal_symbol_count - 1
 		     && (MSYMBOL_RAW_VALUE_ADDRESS (&msymbol[hi])
 			 == MSYMBOL_RAW_VALUE_ADDRESS (&msymbol[hi + 1])))
 		hi++;
@@ -893,7 +897,7 @@ lookup_minimal_symbol_and_objfile (const char *name,
     {
       struct minimal_symbol *msym;
 
-      for (msym = objfile->msymbol_hash[hash];
+      for (msym = objfile->per_bfd->msymbol_hash[hash];
 	   msym != NULL;
 	   msym = msym->hash_next)
 	{
@@ -1044,7 +1048,10 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
   msymbol->hash_next = NULL;
   msymbol->demangled_hash_next = NULL;
 
-  msym_bunch_index++;
+  /* If we are inhibiting minimal symbols for this objfile, then don't
+     ever allocate a new one.  */
+  if (!inhibit_hash || !htab_find (inhibit_hash, objfile))
+    msym_bunch_index++;
   msym_count++;
   OBJSTAT (objfile, n_minsyms++);
   return msymbol;
@@ -1155,7 +1162,7 @@ make_cleanup_discard_minimal_symbols (void)
 
    Note that we are not concerned here about recovering the space that
    is potentially freed up, because the strings themselves are allocated
-   on the objfile_obstack, and will get automatically freed when the symbol
+   on the storage_obstack, and will get automatically freed when the symbol
    table is freed.  The caller can free up the unused minimal symbols at
    the end of the compacted region if their allocation strategy allows it.
 
@@ -1213,22 +1220,23 @@ build_minimal_symbol_hash_tables (struct objfile *objfile)
   /* Clear the hash tables.  */
   for (i = 0; i < MINIMAL_SYMBOL_HASH_SIZE; i++)
     {
-      objfile->msymbol_hash[i] = 0;
-      objfile->msymbol_demangled_hash[i] = 0;
+      objfile->per_bfd->msymbol_hash[i] = 0;
+      objfile->per_bfd->msymbol_demangled_hash[i] = 0;
     }
 
   /* Now, (re)insert the actual entries.  */
-  for (i = objfile->minimal_symbol_count, msym = objfile->msymbols;
+  for ((i = objfile->per_bfd->minimal_symbol_count,
+	msym = objfile->per_bfd->msymbols);
        i > 0;
        i--, msym++)
     {
       msym->hash_next = 0;
-      add_minsym_to_hash_table (msym, objfile->msymbol_hash);
+      add_minsym_to_hash_table (msym, objfile->per_bfd->msymbol_hash);
 
       msym->demangled_hash_next = 0;
       if (MSYMBOL_SEARCH_NAME (msym) != MSYMBOL_LINKAGE_NAME (msym))
 	add_minsym_to_demangled_hash_table (msym,
-                                            objfile->msymbol_demangled_hash);
+                                            objfile->per_bfd->msymbol_demangled_hash);
     }
 }
 
@@ -1264,6 +1272,9 @@ install_minimal_symbols (struct objfile *objfile)
   struct minimal_symbol *msymbols;
   int alloc_count;
 
+  if (inhibit_hash && htab_find (inhibit_hash, objfile))
+    return;
+
   if (msym_count > 0)
     {
       /* Allocate enough space in the obstack, into which we will gather the
@@ -1271,17 +1282,17 @@ install_minimal_symbols (struct objfile *objfile)
          compact out the duplicate entries.  Once we have a final table,
          we will give back the excess space.  */
 
-      alloc_count = msym_count + objfile->minimal_symbol_count + 1;
-      obstack_blank (&objfile->objfile_obstack,
+      alloc_count = msym_count + objfile->per_bfd->minimal_symbol_count + 1;
+      obstack_blank (&objfile->per_bfd->storage_obstack,
 		     alloc_count * sizeof (struct minimal_symbol));
       msymbols = (struct minimal_symbol *)
-	obstack_base (&objfile->objfile_obstack);
+	obstack_base (&objfile->per_bfd->storage_obstack);
 
       /* Copy in the existing minimal symbols, if there are any.  */
 
-      if (objfile->minimal_symbol_count)
-	memcpy ((char *) msymbols, (char *) objfile->msymbols,
-	    objfile->minimal_symbol_count * sizeof (struct minimal_symbol));
+      if (objfile->per_bfd->minimal_symbol_count)
+	memcpy ((char *) msymbols, (char *) objfile->per_bfd->msymbols,
+	    objfile->per_bfd->minimal_symbol_count * sizeof (struct minimal_symbol));
 
       /* Walk through the list of minimal symbol bunches, adding each symbol
          to the new contiguous array of symbols.  Note that we start with the
@@ -1289,7 +1300,7 @@ install_minimal_symbols (struct objfile *objfile)
          msym_bunch_index for the first bunch we copy over), and thereafter
          each bunch is full.  */
 
-      mcount = objfile->minimal_symbol_count;
+      mcount = objfile->per_bfd->minimal_symbol_count;
 
       for (bunch = msym_bunch; bunch != NULL; bunch = bunch->next)
 	{
@@ -1308,10 +1319,10 @@ install_minimal_symbols (struct objfile *objfile)
 
       mcount = compact_minimal_symbols (msymbols, mcount, objfile);
 
-      obstack_blank (&objfile->objfile_obstack,
+      obstack_blank (&objfile->per_bfd->storage_obstack,
 	       (mcount + 1 - alloc_count) * sizeof (struct minimal_symbol));
       msymbols = (struct minimal_symbol *)
-	obstack_finish (&objfile->objfile_obstack);
+	obstack_finish (&objfile->per_bfd->storage_obstack);
 
       /* We also terminate the minimal symbol table with a "null symbol",
          which is *not* included in the size of the table.  This makes it
@@ -1326,11 +1337,11 @@ install_minimal_symbols (struct objfile *objfile)
       MSYMBOL_SET_LANGUAGE (&msymbols[mcount], language_unknown);
 
       /* Attach the minimal symbol table to the specified objfile.
-         The strings themselves are also located in the objfile_obstack
+         The strings themselves are also located in the storage_obstack
          of this objfile.  */
 
-      objfile->minimal_symbol_count = mcount;
-      objfile->msymbols = msymbols;
+      objfile->per_bfd->minimal_symbol_count = mcount;
+      objfile->per_bfd->msymbols = msymbols;
 
       /* Try to guess the appropriate C++ ABI by looking at the names 
 	 of the minimal symbols in the table.  */
@@ -1344,10 +1355,12 @@ install_minimal_symbols (struct objfile *objfile)
 	       For now we set the C++ ABI globally; if the user is
 	       mixing ABIs then the user will need to "set cp-abi"
 	       manually.  */
-	    const char *name = MSYMBOL_LINKAGE_NAME (&objfile->msymbols[i]);
+	    const char *name
+	      = MSYMBOL_LINKAGE_NAME (&objfile->per_bfd->msymbols[i]);
 
 	    if (name[0] == '_' && name[1] == 'Z'
-		&& MSYMBOL_DEMANGLED_NAME (&objfile->msymbols[i]) != NULL)
+		&& (MSYMBOL_DEMANGLED_NAME (&objfile->per_bfd->msymbols[i])
+		    != NULL))
 	      {
 		set_cp_abi_as_auto_default ("gnu-v3");
 		break;
@@ -1368,14 +1381,17 @@ install_minimal_symbols (struct objfile *objfile)
 void
 terminate_minimal_symbol_table (struct objfile *objfile)
 {
-  if (! objfile->msymbols)
-    objfile->msymbols = ((struct minimal_symbol *)
-                         obstack_alloc (&objfile->objfile_obstack,
-                                        sizeof (objfile->msymbols[0])));
+  gdb_assert (!inhibit_hash || !htab_find (inhibit_hash, objfile));
+
+  if (! objfile->per_bfd->msymbols)
+    objfile->per_bfd->msymbols
+      = ((struct minimal_symbol *)
+	 obstack_alloc (&objfile->per_bfd->storage_obstack,
+			sizeof (struct minimal_symbol)));
 
   {
     struct minimal_symbol *m
-      = &objfile->msymbols[objfile->minimal_symbol_count];
+      = &objfile->per_bfd->msymbols[objfile->per_bfd->minimal_symbol_count];
 
     memset (m, 0, sizeof (*m));
     /* Don't rely on these enumeration values being 0's.  */
@@ -1384,6 +1400,33 @@ terminate_minimal_symbol_table (struct objfile *objfile)
   }
 }
 
+/* A cleanup function to remove an objfile from inhibit_hash.  */
+
+static void
+remove_objfile_from_hash (void *objfile)
+{
+  htab_remove_elt (inhibit_hash, objfile);
+}
+
+/* See minsyms.h.  */
+
+struct cleanup *
+inhibit_minimal_symbol_registration (struct objfile *objfile)
+{
+  struct cleanup *result;
+  void **slot;
+
+  if (inhibit_hash == NULL)
+    inhibit_hash = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
+				      NULL, xcalloc, xfree);
+
+  slot = htab_find_slot (inhibit_hash, objfile, INSERT);
+  gdb_assert (slot && !*slot);
+  *slot = objfile;
+
+  return make_cleanup (remove_objfile_from_hash, objfile);
+}
+
 /* Check if PC is in a shared library trampoline code stub.
    Return minimal symbol for the trampoline entry or NULL if PC is not
    in a trampoline code stub.  */
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 0b58c53..1604c81 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -116,4 +116,14 @@ void iterate_over_minimal_symbols (struct objfile *objf,
 
 CORE_ADDR msymbol_address (const struct minimal_symbol *msym);
 
+/* Inhibit minimal symbol registration for OBJFILE.  This is used when
+   reading minimal symbols from a BFD that has already been read.  It
+   is a hack to let us avoid updating all the symbol readers, which
+   tend to mix minimal- and partial-symbol reading.
+
+   This returns a cleanup which should be run to restore the previous
+   state.  */
+
+struct cleanup *inhibit_minimal_symbol_registration (struct objfile *);
+
 #endif /* MINSYMS_H */
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index e879873..185d249 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -108,6 +108,55 @@ get_objfile_pspace_data (struct program_space *pspace)
   return info;
 }
 
+
+
+/* Per-BFD data key.  */
+
+static const struct bfd_data *objfiles_bfd_data;
+
+static struct objfile_per_bfd_storage *
+get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
+{
+  struct objfile_per_bfd_storage *storage = NULL;
+
+  if (abfd != NULL)
+    storage = bfd_data (abfd, objfiles_bfd_data);
+
+  if (storage == NULL)
+    {
+      if (abfd != NULL)
+	{
+	  storage = bfd_zalloc (abfd, sizeof (struct objfile_per_bfd_storage));
+	  set_bfd_data (abfd, objfiles_bfd_data, storage);
+	}
+      else
+	storage = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+				  struct objfile_per_bfd_storage);
+
+      obstack_init (&storage->storage_obstack);
+      storage->filename_cache = bcache_xmalloc (NULL, NULL);
+    }
+
+  return storage;
+}
+
+void
+free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage)
+{
+  bcache_xfree (storage->filename_cache);
+  if (storage->demangled_names_hash != NULL)
+    htab_delete (storage->demangled_names_hash);
+  obstack_free (&storage->storage_obstack, 0);
+}
+
+static void
+objfile_bfd_data_free (struct bfd *unused, void *d)
+{
+  free_objfile_per_bfd_storage (d);
+}
+
+
+
 /* Records whether any objfiles appeared or disappeared since we last updated
    address to obj section map.  */
 
@@ -177,6 +226,14 @@ build_objfile_section_table (struct objfile *objfile)
   return (0);
 }
 
+/* This is a hack until we make reread_symbols create a new objfile.  */
+
+void
+set_objfile_per_bfd (struct objfile *objfile)
+{
+  objfile->per_bfd = get_objfile_bfd_data (objfile, objfile->obfd);
+}
+
 /* Given a pointer to an initialized bfd (ABFD) and some flag bits
    allocate a new objfile struct, fill it in as best we can, link it
    into the list of all known objfiles, and return a pointer to the
@@ -203,11 +260,9 @@ allocate_objfile (bfd *abfd, int flags)
   objfile = (struct objfile *) xzalloc (sizeof (struct objfile));
   objfile->psymbol_cache = psymbol_bcache_init ();
   objfile->macro_cache = bcache_xmalloc (NULL, NULL);
-  objfile->filename_cache = bcache_xmalloc (NULL, NULL);
   /* We could use obstack_specify_allocation here instead, but
      gdb_obstack.h specifies the alloc/dealloc functions.  */
   obstack_init (&objfile->objfile_obstack);
-  terminate_minimal_symbol_table (objfile);
 
   objfile_alloc_data (objfile);
 
@@ -237,8 +292,11 @@ allocate_objfile (bfd *abfd, int flags)
       objfile->name = xstrdup ("<<anonymous objfile>>");
     }
 
+  objfile->per_bfd = get_objfile_bfd_data (objfile, abfd);
   objfile->pspace = current_program_space;
 
+  terminate_minimal_symbol_table (objfile);
+
   /* Initialize the section indexes for this objfile, so that we can
      later detect if they are used w/o being properly assigned to.  */
 
@@ -580,7 +638,10 @@ free_objfile (struct objfile *objfile)
      still may reference objfile->obfd.  */
   objfile_free_data (objfile);
 
-  gdb_bfd_unref (objfile->obfd);
+  if (objfile->obfd)
+    gdb_bfd_unref (objfile->obfd);
+  else
+    free_objfile_per_bfd_storage (objfile->per_bfd);
 
   /* Remove it from the chain of all objfiles.  */
 
@@ -629,7 +690,6 @@ free_objfile (struct objfile *objfile)
   /* Free the obstacks for non-reusable objfiles.  */
   psymbol_bcache_free (objfile->psymbol_cache);
   bcache_xfree (objfile->macro_cache);
-  bcache_xfree (objfile->filename_cache);
   if (objfile->demangled_names_hash)
     htab_delete (objfile->demangled_names_hash);
   obstack_free (&objfile->objfile_obstack, 0);
@@ -974,7 +1034,7 @@ have_minimal_symbols (void)
 
   ALL_OBJFILES (ofp)
   {
-    if (ofp->minimal_symbol_count > 0)
+    if (ofp->per_bfd->minimal_symbol_count > 0)
       {
 	return 1;
       }
@@ -1363,4 +1423,7 @@ _initialize_objfiles (void)
   objfiles_pspace_data
     = register_program_space_data_with_cleanup (NULL,
 						objfiles_pspace_data_cleanup);
+
+  objfiles_bfd_data = register_bfd_data_with_cleanup (NULL,
+						      objfile_bfd_data_free);
 }
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index ec6d616..a49c5e2 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -162,6 +162,56 @@ extern void print_symbol_bcache_statistics (void);
 /* Number of entries in the minimal symbol hash table.  */
 #define MINIMAL_SYMBOL_HASH_SIZE 2039
 
+/* Some objfile data is hung off the BFD.  This enables sharing of the
+   data across all objfiles using the BFD.  The data is stored in an
+   instance of this structure, and associated with the BFD using the
+   registry system.  */
+
+struct objfile_per_bfd_storage
+{
+  /* The storage has an obstack of its own.  */
+
+  struct obstack storage_obstack;
+  
+  /* Byte cache for file names.  */
+
+  struct bcache *filename_cache;
+
+  /* Hash table for mapping symbol names to demangled names.  Each
+     entry in the hash table is actually two consecutive strings,
+     both null-terminated; the first one is a mangled or linkage
+     name, and the second is the demangled name or just a zero byte
+     if the name doesn't demangle.  */
+
+  struct htab *demangled_names_hash;
+
+  /* This is true if the minimal symbols have been read.  */
+
+  unsigned int minsyms_read : 1;
+
+  /* Each file contains a pointer to an array of minimal symbols for all
+     global symbols that are defined within the file.  The array is
+     terminated by a "null symbol", one that has a NULL pointer for the
+     name and a zero value for the address.  This makes it easy to walk
+     through the array when passed a pointer to somewhere in the middle
+     of it.  There is also a count of the number of symbols, which does
+     not include the terminating null symbol.  The array itself, as well
+     as all the data that it points to, should be allocated on the
+     objfile_obstack for this file.  */
+
+  struct minimal_symbol *msymbols;
+  int minimal_symbol_count;
+
+  /* This is a hash table used to index the minimal symbols by name.  */
+
+  struct minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE];
+
+  /* This hash table is used to index the minimal symbols by their
+     demangled names.  */
+
+  struct minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE];
+};
+
 /* Master structure for keeping track of each file from which
    gdb reads symbols.  There are several ways these get allocated: 1.
    The main symbol file, symfile_objfile, set by the symbol-file command,
@@ -234,6 +284,11 @@ struct objfile
 
     bfd *obfd;
 
+    /* The per-BFD data.  Note that this is treated specially if OBFD
+       is NULL.  */
+
+    struct objfile_per_bfd_storage *per_bfd;
+
     /* The gdbarch associated with the BFD.  Note that this gdbarch is
        determined solely from BFD information, without looking at target
        information.  The gdbarch determined from a running target may
@@ -261,13 +316,13 @@ struct objfile
 
     struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms.  */
     struct bcache *macro_cache;           /* Byte cache for macros.  */
-    struct bcache *filename_cache;	  /* Byte cache for file names.  */
 
     /* Hash table for mapping symbol names to demangled names.  Each
        entry in the hash table is actually two consecutive strings,
        both null-terminated; the first one is a mangled or linkage
        name, and the second is the demangled name or just a zero byte
        if the name doesn't demangle.  */
+
     struct htab *demangled_names_hash;
 
     /* Vectors of all partial symbols read in from file.  The actual data
@@ -276,28 +331,6 @@ struct objfile
     struct psymbol_allocation_list global_psymbols;
     struct psymbol_allocation_list static_psymbols;
 
-    /* Each file contains a pointer to an array of minimal symbols for all
-       global symbols that are defined within the file.  The array is
-       terminated by a "null symbol", one that has a NULL pointer for the
-       name and a zero value for the address.  This makes it easy to walk
-       through the array when passed a pointer to somewhere in the middle
-       of it.  There is also a count of the number of symbols, which does
-       not include the terminating null symbol.  The array itself, as well
-       as all the data that it points to, should be allocated on the
-       objfile_obstack for this file.  */
-
-    struct minimal_symbol *msymbols;
-    int minimal_symbol_count;
-
-    /* This is a hash table used to index the minimal symbols by name.  */
-
-    struct minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE];
-
-    /* This hash table is used to index the minimal symbols by their
-       demangled names.  */
-
-    struct minimal_symbol *msymbol_demangled_hash[MINIMAL_SYMBOL_HASH_SIZE];
-
     /* Structure which keeps track of functions that manipulate objfile's
        of the same type as this objfile.  I.e. the function to read partial
        symbols for example.  Note that this structure is in statically
@@ -551,8 +584,10 @@ DECLARE_REGISTRY(objfile);
 
 /* Traverse all minimal symbols in one objfile.  */
 
-#define	ALL_OBJFILE_MSYMBOLS(objfile, m) \
-    for ((m) = (objfile) -> msymbols; MSYMBOL_LINKAGE_NAME(m) != NULL; (m)++)
+#define	ALL_OBJFILE_MSYMBOLS(objfile, m)	\
+    for ((m) = (objfile)->per_bfd->msymbols;	\
+	 MSYMBOL_LINKAGE_NAME (m) != NULL;	\
+	 (m)++)
 
 /* Traverse all symtabs in all objfiles in the current symbol
    space.  */
@@ -654,4 +689,6 @@ DECLARE_REGISTRY(objfile);
 
 #define MULTI_OBJFILE_P() (object_files && object_files->next)
 
+void set_objfile_per_bfd (struct objfile *obj);
+
 #endif /* !defined (OBJFILES_H) */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b4d790e..a7aa70b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -933,7 +933,7 @@ syms_from_objfile (struct objfile *objfile,
 		   int add_flags)
 {
   struct section_addr_info *local_addr = NULL;
-  struct cleanup *old_chain;
+  struct cleanup *old_chain, *inner_cleanup;
   const int mainline = add_flags & SYMFILE_MAINLINE;
 
   gdb_assert (! (addrs && offsets));
@@ -1015,7 +1015,16 @@ syms_from_objfile (struct objfile *objfile,
       init_objfile_sect_indices (objfile);
     }
 
+  if (objfile->per_bfd->minsyms_read)
+    {
+      add_flags |= SYMFILE_MINSYMS_READ;
+      inner_cleanup = inhibit_minimal_symbol_registration (objfile);
+    }
+  else
+    inner_cleanup = make_cleanup (null_cleanup, NULL);
   (*objfile->sf->sym_read) (objfile, add_flags);
+  do_cleanups (inner_cleanup);
+  objfile->per_bfd->minsyms_read = 1;
 
   if ((add_flags & SYMFILE_NO_READ) == 0)
     require_partial_symbols (objfile, 0);
@@ -2402,9 +2411,9 @@ reread_symbols (void)
       new_modtime = new_statbuf.st_mtime;
       if (new_modtime != objfile->mtime)
 	{
-	  struct cleanup *old_cleanups;
+	  struct cleanup *old_cleanups, *inner_cleanup;
 	  struct section_offsets *offsets;
-	  int num_offsets;
+	  int num_offsets, add_flags;
 	  char *obfd_filename;
 
 	  printf_unfiltered (_("`%s' has changed; re-reading symbols.\n"),
@@ -2498,8 +2507,6 @@ reread_symbols (void)
 	  objfile->psymbol_cache = psymbol_bcache_init ();
 	  bcache_xfree (objfile->macro_cache);
 	  objfile->macro_cache = bcache_xmalloc (NULL, NULL);
-	  bcache_xfree (objfile->filename_cache);
-	  objfile->filename_cache = bcache_xmalloc (NULL,NULL);
 	  if (objfile->demangled_names_hash != NULL)
 	    {
 	      htab_delete (objfile->demangled_names_hash);
@@ -2512,13 +2519,10 @@ reread_symbols (void)
 	  objfile->psymtabs_addrmap = NULL;
 	  objfile->free_psymtabs = NULL;
 	  objfile->template_symbols = NULL;
-	  objfile->msymbols = NULL;
 	  objfile->deprecated_sym_private = NULL;
-	  objfile->minimal_symbol_count = 0;
-	  memset (&objfile->msymbol_hash, 0,
-		  sizeof (objfile->msymbol_hash));
-	  memset (&objfile->msymbol_demangled_hash, 0,
-		  sizeof (objfile->msymbol_demangled_hash));
+	  objfile->demangled_names_hash = NULL;
+
+	  set_objfile_per_bfd (objfile);
 
 	  /* obstack_init also initializes the obstack so it is
 	     empty.  We could use obstack_specify_allocation but
@@ -2551,9 +2555,23 @@ reread_symbols (void)
 
 	  (*objfile->sf->sym_init) (objfile);
 	  clear_complaints (&symfile_complaints, 1, 1);
+
+	  if (objfile->per_bfd->minsyms_read)
+	    {
+	      add_flags = SYMFILE_MINSYMS_READ;
+	      inner_cleanup = inhibit_minimal_symbol_registration (objfile);
+	    }
+	  else
+	    {
+	      add_flags = 0;
+	      inner_cleanup = make_cleanup (null_cleanup, NULL);
+	    }
 	  /* Do not set flags as this is safe and we don't want to be
              verbose.  */
-	  (*objfile->sf->sym_read) (objfile, 0);
+	  (*objfile->sf->sym_read) (objfile, add_flags);
+	  do_cleanups (inner_cleanup);
+	  objfile->per_bfd->minsyms_read = 1;
+
 	  if ((objfile->flags & OBJF_PSYMTABS_READ) != 0)
 	    {
 	      objfile->flags &= ~OBJF_PSYMTABS_READ;
@@ -2797,7 +2815,7 @@ allocate_symtab (const char *filename, struct objfile *objfile)
     obstack_alloc (&objfile->objfile_obstack, sizeof (struct symtab));
   memset (symtab, 0, sizeof (*symtab));
   symtab->filename = (char *) bcache (filename, strlen (filename) + 1,
-				      objfile->filename_cache);
+				      objfile->per_bfd->filename_cache);
   symtab->fullname = NULL;
   symtab->language = deduce_language_from_filename (filename);
   symtab->debugformat = "unknown";
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 44f0c01..7539f84 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -425,7 +425,14 @@ enum symfile_add_flags
 
     /* Do not immediately read symbols for this file.  By default,
        symbols are read when the objfile is created.  */
-    SYMFILE_NO_READ = 1 << 4
+    SYMFILE_NO_READ = 1 << 4,
+
+    /* This can be passed to sym_read to indicate that the minimal
+       symbols for this objfile's BFD have already been read.  If set,
+       any minimal symbols created by sym_read will be ignored; see
+       inhibit_minimal_symbol_registration.  In this case, the reader
+       may opt to skip the work of reading minimal symbols.  */
+    SYMFILE_MINSYMS_READ = 1 << 5
   };
 
 extern void syms_from_objfile (struct objfile *,
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index dbe6d11..3cf2761 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -94,7 +94,9 @@ print_symbol_bcache_statistics (void)
     print_bcache_statistics (psymbol_bcache_get_bcache (objfile->psymbol_cache),
                              "partial symbol cache");
     print_bcache_statistics (objfile->macro_cache, "preprocessor macro cache");
-    print_bcache_statistics (objfile->filename_cache, "file name cache");
+    /* FIXME */
+    print_bcache_statistics (objfile->per_bfd->filename_cache,
+			     "file name cache");
   }
   immediate_quit--;
 }
@@ -154,8 +156,9 @@ print_objfile_statistics (void)
 		                          (objfile->psymbol_cache)));
     printf_filtered (_("  Total memory used for macro cache: %d\n"),
 		     bcache_memory_used (objfile->macro_cache));
+    /* FIXME */
     printf_filtered (_("  Total memory used for file name cache: %d\n"),
-		     bcache_memory_used (objfile->filename_cache));
+		     bcache_memory_used (objfile->per_bfd->filename_cache));
   }
   immediate_quit--;
 }
@@ -170,8 +173,9 @@ dump_objfile (struct objfile *objfile)
   gdb_print_host_address (objfile, gdb_stdout);
   printf_filtered (", bfd at ");
   gdb_print_host_address (objfile->obfd, gdb_stdout);
+  /* FIXME */
   printf_filtered (", %d minsyms\n\n",
-		   objfile->minimal_symbol_count);
+		   objfile->per_bfd->minimal_symbol_count);
 
   if (objfile->sf)
     objfile->sf->qf->dump (objfile);
@@ -207,7 +211,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
   char ms_type;
 
   fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile->name);
-  if (objfile->minimal_symbol_count == 0)
+  if (objfile->per_bfd->minimal_symbol_count == 0)
     {
       fprintf_filtered (outfile, "No minimal symbols found.\n");
       return;
@@ -270,10 +274,10 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
       fputs_filtered ("\n", outfile);
       index++;
     }
-  if (objfile->minimal_symbol_count != index)
+  if (objfile->per_bfd->minimal_symbol_count != index)
     {
       warning (_("internal error:  minimal symbol count %d != %d"),
-	       objfile->minimal_symbol_count, index);
+	       objfile->per_bfd->minimal_symbol_count, index);
     }
   fprintf_filtered (outfile, "\n");
 }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 23bc561..2679d3e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -409,15 +409,15 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
 
 static void
 symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
-                           struct objfile *objfile)
+			    struct obstack *obstack)
 {
   /* A language_specific structure should not have been previously
      initialized.  */
   gdb_assert (gsymbol->language_specific.cplus_specific == NULL);
-  gdb_assert (objfile != NULL);
+  gdb_assert (obstack != NULL);
 
   gsymbol->language_specific.cplus_specific =
-      OBSTACK_ZALLOC (&objfile->objfile_obstack, struct cplus_specific);
+      OBSTACK_ZALLOC (obstack, struct cplus_specific);
 }
 
 /* Set the demangled name of GSYMBOL to NAME.  NAME must be already
@@ -427,12 +427,12 @@ symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
 void
 symbol_set_demangled_name (struct general_symbol_info *gsymbol,
                            char *name,
-                           struct objfile *objfile)
+                           struct obstack *obstack)
 {
   if (gsymbol->language == language_cplus)
     {
       if (gsymbol->language_specific.cplus_specific == NULL)
-	symbol_init_cplus_specific (gsymbol, objfile);
+	symbol_init_cplus_specific (gsymbol, obstack);
 
       gsymbol->language_specific.cplus_specific->demangled_name = name;
     }
@@ -512,14 +512,14 @@ eq_demangled_name_entry (const void *a, const void *b)
    name.  The entry is hashed via just the mangled name.  */
 
 static void
-create_demangled_names_hash (struct objfile *objfile)
+create_demangled_names_hash (htab_t *demangled_names_hash)
 {
   /* Choose 256 as the starting size of the hash table, somewhat arbitrarily.
      The hash table code will round this up to the next prime number.
      Choosing a much larger table size wastes memory, and saves only about
      1% in symbol reading.  */
 
-  objfile->demangled_names_hash = htab_create_alloc
+  *demangled_names_hash = htab_create_alloc
     (256, hash_demangled_name_entry, eq_demangled_name_entry,
      NULL, xcalloc, xfree);
 }
@@ -623,7 +623,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
 void
 symbol_set_names (struct general_symbol_info *gsymbol,
 		  const char *linkage_name, int len, int copy_name,
-		  struct objfile *objfile)
+		  struct obstack *storage,
+		  htab_t *demangled_names_hash)
 {
   struct demangled_name_entry **slot;
   /* A 0-terminated copy of the linkage name.  */
@@ -649,7 +650,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 	gsymbol->name = (char *) linkage_name;
       else
 	{
-	  gsymbol->name = obstack_alloc (&objfile->objfile_obstack, len + 1);
+	  gsymbol->name = obstack_alloc (storage, len + 1);
 	  memcpy (gsymbol->name, linkage_name, len);
 	  gsymbol->name[len] = '\0';
 	}
@@ -658,8 +659,8 @@ symbol_set_names (struct general_symbol_info *gsymbol,
       return;
     }
 
-  if (objfile->demangled_names_hash == NULL)
-    create_demangled_names_hash (objfile);
+  if (*demangled_names_hash == NULL)
+    create_demangled_names_hash (demangled_names_hash);
 
   /* The stabs reader generally provides names that are not
      NUL-terminated; most of the other readers don't do this, so we
@@ -698,7 +699,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 
   entry.mangled = (char *) lookup_name;
   slot = ((struct demangled_name_entry **)
-	  htab_find_slot (objfile->demangled_names_hash,
+	  htab_find_slot (*demangled_names_hash,
 			  &entry, INSERT));
 
   /* If this name is not in the hash table, add it.  */
@@ -719,7 +720,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 	 us better bcache hit rates for partial symbols.  */
       if (!copy_name && lookup_name == linkage_name)
 	{
-	  *slot = obstack_alloc (&objfile->objfile_obstack,
+	  *slot = obstack_alloc (storage,
 				 offsetof (struct demangled_name_entry,
 					   demangled)
 				 + demangled_len + 1);
@@ -730,7 +731,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 	  /* If we must copy the mangled name, put it directly after
 	     the demangled name so we can have a single
 	     allocation.  */
-	  *slot = obstack_alloc (&objfile->objfile_obstack,
+	  *slot = obstack_alloc (storage,
 				 offsetof (struct demangled_name_entry,
 					   demangled)
 				 + lookup_len + demangled_len + 2);
@@ -749,9 +750,9 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 
   gsymbol->name = (*slot)->mangled + lookup_len - len;
   if ((*slot)->demangled[0] != '\0')
-    symbol_set_demangled_name (gsymbol, (*slot)->demangled, objfile);
+    symbol_set_demangled_name (gsymbol, (*slot)->demangled, storage);
   else
-    symbol_set_demangled_name (gsymbol, NULL, objfile);
+    symbol_set_demangled_name (gsymbol, NULL, storage);
 }
 
 /* Return the source code name of a symbol.  In languages where
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 75a926c..08f234a 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -172,7 +172,7 @@ struct general_symbol_info
 };
 
 extern void symbol_set_demangled_name (struct general_symbol_info *, char *,
-                                       struct objfile *);
+                                       struct obstack *);
 
 extern char *symbol_get_demangled_name (const struct general_symbol_info *);
 
@@ -213,10 +213,13 @@ extern void symbol_set_language (struct general_symbol_info *symbol,
 /* Set the linkage and natural names of a symbol, by demangling
    the linkage name.  */
 #define SYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)	\
-  symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name, objfile)
+  symbol_set_names (&(symbol)->ginfo, linkage_name, len, copy_name,	\
+		    &objfile->objfile_obstack, &objfile->demangled_names_hash)
+
 extern void symbol_set_names (struct general_symbol_info *symbol,
 			      const char *linkage_name, int len, int copy_name,
-			      struct objfile *objfile);
+			      struct obstack *symbol_obstack,
+			      htab_t *demangled_names_hash);
 
 /* Now come lots of name accessor macros.  Short version as to when to
    use which: Use SYMBOL_NATURAL_NAME to refer to the name of the
@@ -411,7 +414,9 @@ struct minimal_symbol
 #define MSYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
   (strcmp_iw (MSYMBOL_SEARCH_NAME (symbol), (name)) == 0)
 #define MSYMBOL_SET_NAMES(symbol,linkage_name,len,copy_name,objfile)	\
-  symbol_set_names (&(symbol)->mginfo, linkage_name, len, copy_name, objfile)
+  symbol_set_names (&(symbol)->mginfo, linkage_name, len, copy_name,	\
+		    &objfile->per_bfd->storage_obstack,			\
+		    &objfile->per_bfd->demangled_names_hash)
 
 #include "minsyms.h"
 
-- 
1.7.6.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]