libiberty/md5: fix strict alias warnings
[deliverable/binutils-gdb.git] / gdb / solib.c
index f5917856d1509a11d28c8d308822033e1f03c827..73773f10989aac4c0d14eedf6ff85eb901b7c681 100644 (file)
@@ -46,6 +46,7 @@
 #include "solib.h"
 #include "interps.h"
 #include "filesystem.h"
+#include "gdb_bfd.h"
 
 /* Architecture-specific operations.  */
 
@@ -360,9 +361,9 @@ solib_find (char *in_pathname, int *fd)
    it is used as file handle to open the file.  Throws an error if the file
    could not be opened.  Handles both local and remote file access.
 
-   PATHNAME must be malloc'ed by the caller.  If successful, the new BFD's
-   name will point to it.  If unsuccessful, PATHNAME will be freed and the
-   FD will be closed (unless FD was -1).  */
+   PATHNAME must be malloc'ed by the caller.  It will be freed by this
+   function.  If unsuccessful, the FD will be closed (unless FD was
+   -1).  */
 
 bfd *
 solib_bfd_fopen (char *pathname, int fd)
@@ -376,12 +377,10 @@ solib_bfd_fopen (char *pathname, int fd)
     }
   else
     {
-      abfd = bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
+      abfd = gdb_bfd_fopen (pathname, gnutarget, FOPEN_RB, fd);
 
       if (abfd)
        bfd_set_cacheable (abfd, 1);
-      else if (fd != -1)
-       close (fd);
     }
 
   if (!abfd)
@@ -391,6 +390,8 @@ solib_bfd_fopen (char *pathname, int fd)
             pathname, bfd_errmsg (bfd_get_error ()));
     }
 
+  xfree (pathname);
+
   return abfd;
 }
 
@@ -422,17 +423,16 @@ solib_bfd_open (char *pathname)
   /* Check bfd format.  */
   if (!bfd_check_format (abfd, bfd_object))
     {
-      bfd_close (abfd);
-      make_cleanup (xfree, found_pathname);
+      make_cleanup_bfd_unref (abfd);
       error (_("`%s': not in executable format: %s"),
-            found_pathname, bfd_errmsg (bfd_get_error ()));
+            bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
     }
 
   /* Check bfd arch.  */
   b = gdbarch_bfd_arch_info (target_gdbarch);
   if (!b->compatible (b, bfd_get_arch_info (abfd)))
     warning (_("`%s': Shared library architecture %s is not compatible "
-               "with target architecture %s."), found_pathname,
+               "with target architecture %s."), bfd_get_filename (abfd),
              bfd_get_arch_info (abfd)->printable_name, b->printable_name);
 
   return abfd;
@@ -468,7 +468,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.  */
@@ -592,6 +592,8 @@ solib_read_symbols (struct so_list *so, int flags)
     {
       volatile struct gdb_exception e;
 
+      flags |= current_inferior ()->symfile_flags;
+
       TRY_CATCH (e, RETURN_MASK_ERROR)
        {
          struct section_addr_info *sap;
@@ -758,6 +760,9 @@ update_solib_list (int from_tty, struct target_ops *target)
             unloaded before we remove it from GDB's tables.  */
          observer_notify_solib_unloaded (gdb);
 
+         VEC_safe_push (char_ptr, current_program_space->deleted_solibs,
+                        xstrdup (gdb->so_name));
+
          *gdb_link = gdb->next;
 
          /* Unless the user loaded it explicitly, free SO's objfile.  */
@@ -793,6 +798,7 @@ update_solib_list (int from_tty, struct target_ops *target)
          volatile struct gdb_exception e;
 
          i->pspace = current_program_space;
+         VEC_safe_push (so_list_ptr, current_program_space->added_solibs, i);
 
          TRY_CATCH (e, RETURN_MASK_ERROR)
            {
@@ -1229,7 +1235,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.028958 seconds and 4 git commands to generate.