* dwarf2read.c (try_open_dwo_file): Use gdb_bfd_ref and
[deliverable/binutils-gdb.git] / gdb / solib.c
index 90439ba584df76fab8ae9d4bfb53c9f32a1e4aba..7b9f473dbbbb880c9c7dba8d95b1c0230b7c3299 100644 (file)
@@ -46,6 +46,7 @@
 #include "solib.h"
 #include "interps.h"
 #include "filesystem.h"
+#include "gdb_bfd.h"
 
 /* Architecture-specific operations.  */
 
@@ -389,7 +390,7 @@ solib_bfd_fopen (char *pathname, int fd)
             pathname, bfd_errmsg (bfd_get_error ()));
     }
 
-  return abfd;
+  return gdb_bfd_ref (abfd);
 }
 
 /* Find shared library PATHNAME and open a BFD for it.  */
@@ -420,7 +421,7 @@ solib_bfd_open (char *pathname)
   /* Check bfd format.  */
   if (!bfd_check_format (abfd, bfd_object))
     {
-      bfd_close (abfd);
+      gdb_bfd_unref (abfd);
       make_cleanup (xfree, found_pathname);
       error (_("`%s': not in executable format: %s"),
             found_pathname, bfd_errmsg (bfd_get_error ()));
@@ -466,7 +467,7 @@ solib_map_sections (struct so_list *so)
     return 0;
 
   /* Leave bfd open, core_xfer_memory and "info files" need it.  */
-  so->abfd = gdb_bfd_ref (abfd);
+  so->abfd = abfd;
 
   /* copy full path name into so_name, so that later symbol_file_add
      can find it.  */
@@ -608,7 +609,7 @@ solib_read_symbols (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,
+         so->objfile = symbol_file_add_from_bfd (gdb_bfd_ref (so->abfd),
                                                  flags, sap, OBJF_SHARED,
                                                  NULL);
          so->objfile->addr_low = so->addr_low;
@@ -1233,7 +1234,7 @@ reload_shared_libraries_1 (int from_tty)
        {
          found_pathname = xstrdup (bfd_get_filename (abfd));
          make_cleanup (xfree, found_pathname);
-         gdb_bfd_close_or_warn (abfd);
+         gdb_bfd_unref (abfd);
        }
 
       /* If this shared library is no longer associated with its previous
This page took 0.027304 seconds and 4 git commands to generate.