don't share per-BFD data if relocations are needed
[deliverable/binutils-gdb.git] / gdb / objfiles.c
index 6585c3ff0ed0ac4d918024d272a8396d2c33fd9c..b9bcfd74830b916b337da9838ae21c328e35c9d6 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);
@@ -280,10 +284,6 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
 
   objfile_alloc_data (objfile);
 
-  /* Update the per-objfile information that comes from the bfd, ensuring
-     that any data that is reference is saved in the per-objfile data
-     region.  */
-
   if (name == NULL)
     {
       gdb_assert (abfd == NULL);
@@ -292,6 +292,10 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
   objfile->original_name = obstack_copy0 (&objfile->objfile_obstack, name,
                                          strlen (name));
 
+  /* Update the per-objfile information that comes from the bfd, ensuring
+     that any data that is reference is saved in the per-objfile data
+     region.  */
+
   objfile->obfd = abfd;
   gdb_bfd_ref (abfd);
   if (abfd != NULL)
@@ -645,8 +649,6 @@ free_objfile (struct objfile *objfile)
       clear_current_source_symtab_and_line ();
   }
 
-  /* The last thing we do is free the objfile struct itself.  */
-
   if (objfile->global_psymbols.list)
     xfree (objfile->global_psymbols.list);
   if (objfile->static_psymbols.list)
@@ -660,6 +662,7 @@ free_objfile (struct objfile *objfile)
   /* Rebuild section map next time we need it.  */
   get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1;
 
+  /* The last thing we do is free the objfile struct itself.  */
   xfree (objfile);
 }
 
This page took 0.025402 seconds and 4 git commands to generate.