diff options
author | Tom Tromey <tom@tromey.com> | 2020-10-12 15:53:16 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-10-12 20:18:47 -0600 |
commit | 2d128614d4101354d8125449539dc3255c37d345 (patch) | |
tree | 4d07bd7567401171c8ea9edd5cee5170b0a0f3b9 /gdb/exec.c | |
parent | bb2a67773c5e06545c39a6373be720c7d3d9eeb5 (diff) | |
download | fsf-binutils-gdb-2d128614d4101354d8125449539dc3255c37d345.zip fsf-binutils-gdb-2d128614d4101354d8125449539dc3255c37d345.tar.gz fsf-binutils-gdb-2d128614d4101354d8125449539dc3255c37d345.tar.bz2 |
build_section_table cannot fail
I noticed that build_section_table cannot fail. This patch changes it
to return a target_section_table and then removes the dead code.
gdb/ChangeLog
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.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r-- | gdb/exec.c | 28 |
1 files changed, 9 insertions, 19 deletions
@@ -413,7 +413,6 @@ exec_file_attach (const char *filename, int from_tty) 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)) @@ -503,15 +502,7 @@ exec_file_attach (const char *filename, int from_tty) 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); @@ -594,13 +585,13 @@ clear_section_table (struct target_section_table *table) 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; @@ -615,16 +606,15 @@ build_section_table (struct bfd *some_bfd, target_section_table *table) 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 |