diff options
author | Tom Tromey <tom@tromey.com> | 2020-09-19 11:54:49 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-09-19 11:54:54 -0600 |
commit | 8a6bb1d130b61887011463417bd8662dc41757fa (patch) | |
tree | d4f44793c4af6a5dfdacce0e6a8ec225f6ab603e | |
parent | 08f93a1a93f9b344a92dc9e411c83d70acfdf857 (diff) | |
download | gdb-8a6bb1d130b61887011463417bd8662dc41757fa.zip gdb-8a6bb1d130b61887011463417bd8662dc41757fa.tar.gz gdb-8a6bb1d130b61887011463417bd8662dc41757fa.tar.bz2 |
Use gdb_bfd_sections in build_section_table
This changes build_section_table to avoid bfd_map_over_sections, in
favor of iteration. In this situation it seemed simple to just remove
the helper function entirely.
gdb/ChangeLog
2020-09-19 Tom Tromey <tom@tromey.com>
* exec.c (add_to_section_table): Remove.
(build_section_table): Use foreach.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/exec.c | 50 |
2 files changed, 25 insertions, 30 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 469b6c7..7a5e122 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2020-09-19 Tom Tromey <tom@tromey.com> + * exec.c (add_to_section_table): Remove. + (build_section_table): Use foreach. + +2020-09-19 Tom Tromey <tom@tromey.com> + * elfread.c (elf_locate_sections): Change parameters. (elf_symfile_read): Use foreach. @@ -587,35 +587,6 @@ file_command (const char *arg, int from_tty) } -/* Locate all mappable sections of a BFD file. - table_pp_char is a char * to get it through bfd_map_over_sections; - we cast it back to its proper type. */ - -static void -add_to_section_table (bfd *abfd, struct bfd_section *asect, - void *table_pp_char) -{ - struct target_section **table_pp = (struct target_section **) table_pp_char; - flagword aflag; - - gdb_assert (abfd == asect->owner); - - /* Check the section flags, but do not discard zero-length sections, since - some symbols may still be attached to this section. For instance, we - encountered on sparc-solaris 2.10 a shared library with an empty .bss - section to which a symbol named "_end" was attached. The address - of this symbol still needs to be relocated. */ - aflag = bfd_section_flags (asect); - if (!(aflag & SEC_ALLOC)) - return; - - (*table_pp)->owner = NULL; - (*table_pp)->the_bfd_section = asect; - (*table_pp)->addr = bfd_section_vma (asect); - (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (asect); - (*table_pp)++; -} - /* See exec.h. */ void @@ -665,7 +636,26 @@ build_section_table (struct bfd *some_bfd, struct target_section **start, xfree (*start); *start = XNEWVEC (struct target_section, count); *end = *start; - bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end); + for (asection *asect : gdb_bfd_sections (some_bfd)) + { + flagword aflag; + + /* Check the section flags, but do not discard zero-length + sections, since some symbols may still be attached to this + section. For instance, we encountered on sparc-solaris 2.10 + a shared library with an empty .bss section to which a symbol + named "_end" was attached. The address of this symbol still + needs to be relocated. */ + aflag = bfd_section_flags (asect); + if (!(aflag & SEC_ALLOC)) + continue; + + (*end)->owner = NULL; + (*end)->the_bfd_section = asect; + (*end)->addr = bfd_section_vma (asect); + (*end)->endaddr = (*end)->addr + bfd_section_size (asect); + (*end)++; + } gdb_assert (*end <= *start + count); |