#include "solib.h"
#include "interps.h"
#include "filesystem.h"
+#include "gdb_bfd.h"
/* Architecture-specific operations. */
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)
}
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)
pathname, bfd_errmsg (bfd_get_error ()));
}
+ xfree (pathname);
+
return abfd;
}
/* 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;
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. */
{
volatile struct gdb_exception e;
+ flags |= current_inferior ()->symfile_flags;
+
TRY_CATCH (e, RETURN_MASK_ERROR)
{
struct section_addr_info *sap;
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. */
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)
{
{
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