From 1da77581c0559e62b80b27f06f81dad4c7a7a0be Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 7 Oct 2013 19:31:13 +0000 Subject: don't share per-BFD data if relocations are needed Right now we always share per-BFD data across objfiles, if there is a BFD. This works fine. However, we're going to start sharing more data, and sometimes this data will come directly from sections of the BFD. If such a section has SEC_RELOC set, then the data coming from that section will not be truly sharable -- the section will be program-space-dependent, and re-read by gdb for each objfile. This patch disallows per-BFD sharing in this case. This is a bit "heavy" in that we could in theory examine each bit of shared data for suitability. However, that is more complicated, and SEC_RELOC is rare enough that I think we needn't bother. Note that the "no sharing" case is equivalent to "gdb works as it historically did". That is, the sharing is a new(-ish) optimization. Built and regtested on x86-64 Fedora 18. * gdb_bfd.c (struct gdb_bfd_data) : 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. --- gdb/objfiles.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'gdb/objfiles.c') diff --git a/gdb/objfiles.c b/gdb/objfiles.c index b10f803..b9bcfd7 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -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); -- cgit v1.1