/* Reading symbol files from memory.
- Copyright (C) 1986-2015 Free Software Foundation, Inc.
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
This file is part of GDB.
struct section_addr_info *sai;
unsigned int i;
struct cleanup *cleanup;
+ symfile_add_flags add_flags = 0;
if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
error (_("add-symbol-file-from-memory not supported for this target"));
error (_("Failed to read a valid object file image from memory."));
gdb_bfd_ref (nbfd);
+ /* Manage the new reference for the duration of this function. */
+ gdb_bfd_ref_ptr nbfd_holder (nbfd);
+
xfree (bfd_get_filename (nbfd));
if (name == NULL)
nbfd->filename = xstrdup ("shared object read from target memory");
else
nbfd->filename = name;
- cleanup = make_cleanup_bfd_unref (nbfd);
-
if (!bfd_check_format (nbfd, bfd_object))
error (_("Got object file from memory but can't read symbols: %s."),
bfd_errmsg (bfd_get_error ()));
sai = alloc_section_addr_info (bfd_count_sections (nbfd));
- make_cleanup (xfree, sai);
+ cleanup = make_cleanup (xfree, sai);
i = 0;
for (sec = nbfd->sections; sec != NULL; sec = sec->next)
if ((bfd_get_section_flags (nbfd, sec) & (SEC_ALLOC|SEC_LOAD)) != 0)
}
sai->num_sections = i;
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
+
objf = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
- from_tty ? SYMFILE_VERBOSE : 0,
- sai, OBJF_SHARED, NULL);
+ add_flags, sai, OBJF_SHARED, NULL);
add_target_sections_of_objfile (objf);
format should fix this. */
{
warning (_("Could not load vsyscall page "
- "because no executable was specified\n"
- "try using the \"file\" command first."));
+ "because no executable was specified"));
return;
}
args.bfd = bfd;