+2013-10-07 Tom Tromey <tromey@redhat.com>
+
+ * gdb_bfd.c (struct gdb_bfd_data) <relocation_computed,
+ needs_relocations>: New fields.
+ (gdb_bfd_requires_relocations): New function.
+ * gdb_bfd.h (gdb_bfd_requires_relocations): Declare.
+ * objfiles.c (get_objfile_bfd_data): Disallow sharing if
+ the BFD needs relocations applied.
+
2013-10-07 Pedro Alves <palves@redhat.com>
PR breakpoints/11568
/* The mtime of the BFD at the point the cache entry was made. */
time_t mtime;
+ /* This is true if we have determined whether this BFD has any
+ sections requiring relocation. */
+ unsigned int relocation_computed : 1;
+
+ /* This is true if any section needs relocation. */
+ unsigned int needs_relocations : 1;
+
/* This is true if we have successfully computed the file's CRC. */
unsigned int crc_computed : 1;
return bfd_count_sections (abfd) + 4;
}
+/* See gdb_bfd.h. */
+
+int
+gdb_bfd_requires_relocations (bfd *abfd)
+{
+ struct gdb_bfd_data *gdata = bfd_usrdata (abfd);
+
+ if (gdata->relocation_computed == 0)
+ {
+ asection *sect;
+
+ for (sect = abfd->sections; sect != NULL; sect = sect->next)
+ if ((sect->flags & SEC_RELOC) != 0)
+ {
+ gdata->needs_relocations = 1;
+ break;
+ }
+
+ gdata->relocation_computed = 1;
+ }
+
+ return gdata->needs_relocations;
+}
+
\f
/* A callback for htab_traverse that prints a single BFD. */
int gdb_bfd_count_sections (bfd *abfd);
+/* Return true if any section requires relocations, false
+ otherwise. */
+
+int gdb_bfd_requires_relocations (bfd *abfd);
+
#endif /* GDB_BFD_H */
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);