diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2009-08-04 18:46:05 +0000 |
---|---|---|
committer | Paul Pluzhnikov <ppluzhnikov@google.com> | 2009-08-04 18:46:05 +0000 |
commit | e3c69974ac166b09a48d5b0a971cf4833d293b90 (patch) | |
tree | 78801fae838b5f4b950e8d1632178b030f4f0b62 /gdb/solib.c | |
parent | afd0cd3fc15852600db10b246ff5ed1dbb48fc66 (diff) | |
download | gdb-e3c69974ac166b09a48d5b0a971cf4833d293b90.zip gdb-e3c69974ac166b09a48d5b0a971cf4833d293b90.tar.gz gdb-e3c69974ac166b09a48d5b0a971cf4833d293b90.tar.bz2 |
2009-08-04 Paul Pluzhnikov <ppluzhnikov@google.com>
* objfiles.h (OBJF_KEEPBFD): Delete.
(gdb_bfd_unref): New prototype.
* objfiles.c (gdb_bfd_unref): New function.
(free_objfile): Call gdb_bfd_unref.
* solib.c (free_so): Likewise.
(symbol_add_stub): Set refcount.
Diffstat (limited to 'gdb/solib.c')
-rw-r--r-- | gdb/solib.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/gdb/solib.c b/gdb/solib.c index 157aaba..564a55c 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -421,21 +421,11 @@ void free_so (struct so_list *so) { struct target_so_ops *ops = solib_ops (target_gdbarch); - char *bfd_filename = 0; if (so->sections) xfree (so->sections); - - if (so->abfd) - { - bfd_filename = bfd_get_filename (so->abfd); - if (! bfd_close (so->abfd)) - warning (_("cannot close \"%s\": %s"), - bfd_filename, bfd_errmsg (bfd_get_error ())); - } - if (bfd_filename) - xfree (bfd_filename); + gdb_bfd_unref (so->abfd); ops->free_so (so); @@ -454,6 +444,7 @@ static void symbol_add_stub (struct so_list *so, int flags) { struct section_addr_info *sap; + int *p_refcount; /* Have we already loaded this shared object? */ ALL_OBJFILES (so->objfile) @@ -465,8 +456,11 @@ symbol_add_stub (struct so_list *so, int flags) sap = build_section_addr_info_from_section_table (so->sections, so->sections_end); - so->objfile = symbol_file_add_from_bfd (so->abfd, flags, - sap, OBJF_SHARED | OBJF_KEEPBFD); + so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED); + p_refcount = xmalloc (sizeof (*p_refcount)); + *p_refcount = 2; /* Both solib and objfile refer to this abfd. */ + so->abfd->usrdata = p_refcount; + free_section_addr_info (sap); return; |