gdb/
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index b10f803540fa3767c276e5ac7a834e26cf0f3dd1..d1f312141dad20c81be79ebcbc9099ab0327c68f 100644 (file)
@@ -137,18 +137,22 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
 
   if (storage == NULL)
     {
-      if (abfd != NULL)
+      /* If the object requires gdb to do relocations, we simply fall
+        back to not sharing data across users.  These cases are rare
+        enough that this seems reasonable.  */
+      if (abfd != NULL && !gdb_bfd_requires_relocations (abfd))
        {
          storage = bfd_zalloc (abfd, sizeof (struct objfile_per_bfd_storage));
          set_bfd_data (abfd, objfiles_bfd_data, storage);
-
-         /* Look up the gdbarch associated with the BFD.  */
-         storage->gdbarch = gdbarch_from_bfd (abfd);
        }
       else
        storage = OBSTACK_ZALLOC (&objfile->objfile_obstack,
                                  struct objfile_per_bfd_storage);
 
+      /* Look up the gdbarch associated with the BFD.  */
+      if (abfd != NULL)
+       storage->gdbarch = gdbarch_from_bfd (abfd);
+
       obstack_init (&storage->storage_obstack);
       storage->filename_cache = bcache_xmalloc (NULL, NULL);
       storage->macro_cache = bcache_xmalloc (NULL, NULL);
@@ -164,6 +168,8 @@ free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage)
 {
   bcache_xfree (storage->filename_cache);
   bcache_xfree (storage->macro_cache);
+  if (storage->demangled_names_hash)
+    htab_delete (storage->demangled_names_hash);
   obstack_free (&storage->storage_obstack, 0);
 }
 
@@ -283,6 +289,7 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
   if (name == NULL)
     {
       gdb_assert (abfd == NULL);
+      gdb_assert ((flags & OBJF_NOT_FILENAME) != 0);
       name = "<<anonymous objfile>>";
     }
   objfile->original_name = obstack_copy0 (&objfile->objfile_obstack, name,
@@ -651,8 +658,6 @@ free_objfile (struct objfile *objfile)
     xfree (objfile->static_psymbols.list);
   /* Free the obstacks for non-reusable objfiles.  */
   psymbol_bcache_free (objfile->psymbol_cache);
-  if (objfile->demangled_names_hash)
-    htab_delete (objfile->demangled_names_hash);
   obstack_free (&objfile->objfile_obstack, 0);
 
   /* Rebuild section map next time we need it.  */
This page took 0.024114 seconds and 4 git commands to generate.