* h8300-tdep.c (h8300_push_dummy_call): Replace unsafe alloca
[deliverable/binutils-gdb.git] / gdb / solib-darwin.c
index 242f8cc1f6beb813fe6c4032dab9516bad7004bf..55ecb91de0db2b74a4bd7cf6ff4d8c774e6c243f 100644 (file)
@@ -357,6 +357,7 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
   gdb_byte *interp_name;
   CORE_ADDR load_addr = 0;
   bfd *dyld_bfd = NULL;
+  struct cleanup *cleanup;
 
   /* This method doesn't work with an attached process.  */
   if (current_inferior ()->attach_flag)
@@ -367,24 +368,31 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
   if (!interp_name)
     return;
 
+  cleanup = make_cleanup (null_cleanup, NULL);
+
   /* Create a bfd for the interpreter.  */
-  dyld_bfd = gdb_bfd_ref (bfd_openr (interp_name, gnutarget));
+  dyld_bfd = gdb_bfd_open (interp_name, gnutarget, -1);
   if (dyld_bfd)
     {
       bfd *sub;
 
+      make_cleanup_bfd_unref (dyld_bfd);
       sub = bfd_mach_o_fat_extract (dyld_bfd, bfd_object,
                                    gdbarch_bfd_arch_info (target_gdbarch));
       if (sub)
-       dyld_bfd = sub;
-      else
        {
-         gdb_bfd_unref (dyld_bfd);
-         dyld_bfd = NULL;
+         dyld_bfd = sub;
+         gdb_bfd_ref (sub);
+         make_cleanup_bfd_unref (sub);
        }
+      else
+       dyld_bfd = NULL;
     }
   if (!dyld_bfd)
-    return;
+    {
+      do_cleanups (cleanup);
+      return;
+    }
 
   /* We find the dynamic linker's base address by examining
      the current pc (which should point at the entry point for the
@@ -396,7 +404,7 @@ darwin_solib_get_all_image_info_addr_at_init (struct darwin_info *info)
   info->all_image_addr =
     lookup_symbol_from_bfd (dyld_bfd, "_dyld_all_image_infos");
 
-  gdb_bfd_unref (dyld_bfd);
+  do_cleanups (cleanup);
 
   if (info->all_image_addr == 0)
     return;
@@ -510,7 +518,7 @@ darwin_bfd_open (char *pathname)
                                gdbarch_bfd_arch_info (target_gdbarch));
   if (!res)
     {
-      make_cleanup_bfd_close (abfd);
+      make_cleanup_bfd_unref (abfd);
       error (_("`%s': not a shared-library: %s"),
             bfd_get_filename (abfd), bfd_errmsg (bfd_get_error ()));
     }
@@ -526,7 +534,8 @@ void
 _initialize_darwin_solib (void)
 {
   solib_darwin_pspace_data
-    = register_program_space_data_with_cleanup (darwin_pspace_data_cleanup);
+    = register_program_space_data_with_cleanup (NULL,
+                                               darwin_pspace_data_cleanup);
 
   darwin_so_ops.relocate_section_addresses = darwin_relocate_section_addresses;
   darwin_so_ops.free_so = darwin_free_so;
This page took 0.025357 seconds and 4 git commands to generate.