+2020-10-12 Tom Tromey <tom@tromey.com>
+
+ * solib.c (solib_map_sections): Update.
+ * record-full.c (record_full_core_open_1): Update.
+ * exec.h (build_section_table): Return a target_section_table.
+ * exec.c (exec_file_attach): Update.
+ (build_section_table): Return a target_section_table.
+ * corelow.c (core_target::core_target): Update.
+ * bfd-target.c (target_bfd::target_bfd): Update.
+
2020-10-12 Tom Tromey <tom@tromey.com>
* target.c (target_section_by_addr, memory_xfer_partial_1):
}
target_bfd::target_bfd (struct bfd *abfd)
- : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd))
+ : m_bfd (gdb_bfd_ref_ptr::new_reference (abfd)),
+ m_table (build_section_table (abfd))
{
- build_section_table (abfd, &m_table);
}
target_ops *
bfd_get_filename (core_bfd));
/* Find the data section */
- if (build_section_table (core_bfd, &m_core_section_table))
- error (_("\"%s\": Can't find sections: %s"),
- bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ()));
+ m_core_section_table = build_section_table (core_bfd);
build_file_mappings ();
}
int load_via_target = 0;
const char *scratch_pathname, *canonical_pathname;
int scratch_chan;
- target_section_table sections;
char **matching;
if (is_target_filename (filename))
gdb_bfd_errmsg (bfd_get_error (), matching).c_str ());
}
- if (build_section_table (exec_bfd, §ions))
- {
- /* Make sure to close exec_bfd, or else "run" might try to use
- it. */
- exec_close ();
- error (_("\"%ps\": can't find the file sections: %s"),
- styled_string (file_name_style.style (), scratch_pathname),
- bfd_errmsg (bfd_get_error ()));
- }
+ target_section_table sections = build_section_table (exec_bfd);
exec_bfd_mtime = bfd_get_mtime (exec_bfd);
table->sections.clear ();
}
-/* Builds a section table, given args BFD, TABLE.
- Returns 0 if OK, 1 on error. */
+/* Builds a section table, given args BFD, TABLE. */
-int
-build_section_table (struct bfd *some_bfd, target_section_table *table)
+target_section_table
+build_section_table (struct bfd *some_bfd)
{
- table->sections.clear ();
+ target_section_table table;
+
for (asection *asect : gdb_bfd_sections (some_bfd))
{
flagword aflag;
if (!(aflag & SEC_ALLOC))
continue;
- table->sections.emplace_back ();
- target_section § = table->sections.back ();
+ table.sections.emplace_back ();
+ target_section § = table.sections.back ();
sect.owner = NULL;
sect.the_bfd_section = asect;
sect.addr = bfd_section_vma (asect);
sect.endaddr = sect.addr + bfd_section_size (asect);
}
- /* We could realloc the table, but it probably loses for most files. */
- return 0;
+ return table;
}
/* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the
#define exec_bfd_mtime current_program_space->ebfd_mtime
#define exec_filename current_program_space->pspace_exec_filename
-/* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR.
- Returns 0 if OK, 1 on error. */
+/* Builds a section table, given args BFD. */
-extern int build_section_table (struct bfd *, struct target_section_table *);
+extern target_section_table build_section_table (struct bfd *);
/* Remove all entries from TABLE. */
for (i = 0; i < regnum; i ++)
record_full_core_regbuf->raw_supply (i, *regcache);
- if (build_section_table (core_bfd, &record_full_core_sections))
- {
- delete record_full_core_regbuf;
- record_full_core_regbuf = NULL;
- error (_("\"%s\": Can't find sections: %s"),
- bfd_get_filename (core_bfd), bfd_errmsg (bfd_get_error ()));
- }
+ record_full_core_sections = build_section_table (core_bfd);
push_target (&record_full_core_ops);
record_full_restore ();
if (so->sections == nullptr)
so->sections = new target_section_table;
- if (build_section_table (so->abfd, so->sections))
- {
- error (_("Can't find the file sections in `%s': %s"),
- bfd_get_filename (so->abfd), bfd_errmsg (bfd_get_error ()));
- }
+ *so->sections = build_section_table (so->abfd);
for (target_section &p : so->sections->sections)
{