It assumes that object files do not have segments, and fully linked
files have a single segment. */
-struct symfile_segment_data *
+symfile_segment_data_up
default_symfile_segments (bfd *abfd)
{
int num_sections, i;
asection *sect;
- struct symfile_segment_data *data;
CORE_ADDR low, high;
/* Relocatable files contain enough information to position each
low = bfd_section_vma (sect);
high = low + bfd_section_size (sect);
- data = XCNEW (struct symfile_segment_data);
- data->num_segments = 1;
- data->segment_bases = XCNEW (CORE_ADDR);
- data->segment_sizes = XCNEW (CORE_ADDR);
+ symfile_segment_data_up data (new symfile_segment_data);
num_sections = bfd_count_sections (abfd);
- data->segment_info = XCNEWVEC (int, num_sections);
+
+ /* All elements are initialized to 0 (map to no segment). */
+ data->segment_info.resize (num_sections);
for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
{
data->segment_info[i] = 1;
}
- data->segment_bases[0] = low;
- data->segment_sizes[0] = high - low;
+ data->segments.emplace_back (low, high - low);
return data;
}
/* Make certain that the address points at real code, and not a
function descriptor. */
entry_point
- = gdbarch_convert_from_func_ptr_addr (get_objfile_arch (objfile),
+ = gdbarch_convert_from_func_ptr_addr (objfile->arch (),
entry_point,
current_top_target ());
/* Remove any ISA markers, so that this matches entries in the
symbol table. */
ei->entry_point
- = gdbarch_addr_bits_remove (get_objfile_arch (objfile), entry_point);
+ = gdbarch_addr_bits_remove (objfile->arch (), entry_point);
found = 0;
ALL_OBJFILE_OSECTIONS (objfile, osect)
struct objfile *objfile;
const int from_tty = add_flags & SYMFILE_VERBOSE;
const int mainline = add_flags & SYMFILE_MAINLINE;
+ const int always_confirm = add_flags & SYMFILE_ALWAYS_CONFIRM;
const int should_print = (print_symbol_loading_p (from_tty, mainline, 1)
&& (readnow_symbol_files
|| (add_flags & SYMFILE_NO_READ) == 0));
if ((add_flags & SYMFILE_NOT_FILENAME) != 0)
flags |= OBJF_NOT_FILENAME;
- /* Give user a chance to burp if we'd be
+ /* Give user a chance to burp if ALWAYS_CONFIRM or we'd be
interactively wiping out any existing symbols. */
- if ((have_full_symbols () || have_partial_symbols ())
- && mainline
- && from_tty
+ if (from_tty
+ && (always_confirm
+ || ((have_full_symbols () || have_partial_symbols ())
+ && mainline))
&& !query (_("Load new symbol table from \"%s\"? "), name))
error (_("Not confirmed."));
gdb_flush (gdb_stdout);
}
- gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget, -1));
+ gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget));
if (abfd == NULL)
{
}
/* Open the file for loading. */
- gdb_bfd_ref_ptr loadfile_bfd (gdb_bfd_open (filename.get (), gnutarget, -1));
+ gdb_bfd_ref_ptr loadfile_bfd (gdb_bfd_open (filename.get (), gnutarget));
if (loadfile_bfd == NULL)
perror_with_name (filename.get ());
a `shared library' on AIX is also an archive), then you should
stat on the archive name, not member name. */
if (objfile->obfd->my_archive)
- res = stat (objfile->obfd->my_archive->filename, &new_statbuf);
+ res = stat (bfd_get_filename (objfile->obfd->my_archive), &new_statbuf);
else
res = stat (objfile_name (objfile), &new_statbuf);
if (res != 0)
obfd_filename = bfd_get_filename (objfile->obfd);
/* Open the new BFD before freeing the old one, so that
the filename remains live. */
- gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget, -1));
+ gdb_bfd_ref_ptr temp (gdb_bfd_open (obfd_filename, gnutarget));
objfile->obfd = temp.release ();
if (objfile->obfd == NULL)
error (_("Can't open %s to read symbols."), obfd_filename);
will need to be called (see discussion below). */
obstack_free (&objfile->objfile_obstack, 0);
objfile->sections = NULL;
+ objfile->section_offsets.clear ();
+ objfile->sect_index_bss = -1;
+ objfile->sect_index_data = -1;
+ objfile->sect_index_rodata = -1;
+ objfile->sect_index_text = -1;
objfile->compunit_symtabs = NULL;
objfile->template_symbols = NULL;
objfile->static_links.reset (nullptr);
objfiles_changed ();
+ /* Recompute section offsets and section indices. */
+ objfile->sf->sym_offsets (objfile, {});
+
read_symbols (objfile, 0);
if (!objfile_has_symbols (objfile))
case ovly_auto: /* overlay debugging automatic */
/* Unles there is a gdbarch_overlay_update function,
there's really nothing useful to do here (can't really go auto). */
- gdbarch = get_objfile_arch (osect->objfile);
+ gdbarch = osect->objfile->arch ();
if (gdbarch_overlay_update_p (gdbarch))
{
if (overlay_cache_invalid)
ALL_OBJFILE_OSECTIONS (objfile, osect)
if (section_is_mapped (osect))
{
- struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ struct gdbarch *gdbarch = objfile->arch ();
const char *name;
bfd_vma lma, vma;
int size;
error (_("This target does not know how to read its overlay state."));
}
-/* Function: overlay_command
- A place-holder for a mis-typed command. */
-
/* Command list chain containing all defined "overlay" subcommands. */
static struct cmd_list_element *overlaylist;
-static void
-overlay_command (const char *args, int from_tty)
-{
- printf_unfiltered
- ("\"overlay\" must be followed by the name of an overlay command.\n");
- help_list (overlaylist, "overlay ", all_commands, gdb_stdout);
-}
-
/* Target Overlays for the "Simplest" overlay manager:
This is GDB's default target overlay layer. It works with the
static void
simple_free_overlay_table (void)
{
- if (cache_ovly_table)
- xfree (cache_ovly_table);
+ xfree (cache_ovly_table);
cache_novlys = 0;
cache_ovly_table = NULL;
cache_ovly_table_base = 0;
return 0;
}
- gdbarch = get_objfile_arch (ovly_table_msym.objfile);
+ gdbarch = ovly_table_msym.objfile->arch ();
word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
byte_order = gdbarch_byte_order (gdbarch);
{
int i;
asection *bsect = osect->the_bfd_section;
- struct gdbarch *gdbarch = get_objfile_arch (osect->objfile);
+ struct gdbarch *gdbarch = osect->objfile->arch ();
int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
return (*objfile->sf->sym_relocate) (objfile, sectp, buf);
}
-struct symfile_segment_data *
+symfile_segment_data_up
get_symfile_segment_data (bfd *abfd)
{
const struct sym_fns *sf = find_sym_fns (abfd);
return sf->sym_segments (abfd);
}
-void
-free_symfile_segment_data (struct symfile_segment_data *data)
-{
- xfree (data->segment_bases);
- xfree (data->segment_sizes);
- xfree (data->segment_info);
- xfree (data);
-}
-
/* Given:
- DATA, containing segment addresses from the object file ABFD, and
the mapping from ABFD's sections onto the segments that own them,
/* If we do not have segment mappings for the object file, we
can not relocate it by segments. */
gdb_assert (data != NULL);
- gdb_assert (data->num_segments > 0);
+ gdb_assert (data->segments.size () > 0);
for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
{
int which = data->segment_info[i];
- gdb_assert (0 <= which && which <= data->num_segments);
+ gdb_assert (0 <= which && which <= data->segments.size ());
/* Don't bother computing offsets for sections that aren't
loaded as part of any segment. */
if (which > num_segment_bases)
which = num_segment_bases;
- offsets[i] = segment_bases[which - 1] - data->segment_bases[which - 1];
+ offsets[i] = segment_bases[which - 1] - data->segments[which - 1].base;
}
return 1;
bfd *abfd = objfile->obfd;
int i;
asection *sect;
- struct symfile_segment_data *data;
- data = get_symfile_segment_data (objfile->obfd);
+ symfile_segment_data_up data
+ = get_symfile_segment_data (objfile->obfd);
if (data == NULL)
return;
- if (data->num_segments != 1 && data->num_segments != 2)
- {
- free_symfile_segment_data (data);
- return;
- }
+ if (data->segments.size () != 1 && data->segments.size () != 2)
+ return;
for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
{
objfile->sect_index_bss = sect->index;
}
}
-
- free_symfile_segment_data (data);
}
/* Listen for free_objfile events. */
on its own."), &cmdlist);
set_cmd_completer (c, filename_completer);
- add_prefix_cmd ("overlay", class_support, overlay_command,
- _("Commands for debugging overlays."), &overlaylist,
- "overlay ", 0, &cmdlist);
+ add_basic_prefix_cmd ("overlay", class_support,
+ _("Commands for debugging overlays."), &overlaylist,
+ "overlay ", 0, &cmdlist);
- add_com_alias ("ovly", "overlay", class_alias, 1);
- add_com_alias ("ov", "overlay", class_alias, 1);
+ add_com_alias ("ovly", "overlay", class_support, 1);
+ add_com_alias ("ov", "overlay", class_support, 1);
add_cmd ("map-overlay", class_support, map_overlay_command,
_("Assert that an overlay section is mapped."), &overlaylist);