Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 05/13] Use gdb_bfd_sections in build_objfile_section_table
Date: Fri, 28 Aug 2020 10:23:41 -0600	[thread overview]
Message-ID: <20200828162349.987-6-tom@tromey.com> (raw)
In-Reply-To: <20200828162349.987-1-tom@tromey.com>

This changes build_objfile_section_table to avoid
bfd_map_over_sections, in favor of iteration.

gdb/ChangeLog
2020-08-28  Tom Tromey  <tom@tromey.com>

	* objfiles.c (add_to_objfile_sections): Rename from
	add_to_objfile_sections_full.
	(add_to_objfile_sections): Remove.
	(build_objfile_section_table): Use foreach.
---
 gdb/ChangeLog  |  7 +++++++
 gdb/objfiles.c | 29 +++++++++++------------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 3aa7973e0d5..471a5c4c393 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -257,13 +257,13 @@ objfile_lookup_static_link (struct objfile *objfile,
 
 \f
 
-/* Called via bfd_map_over_sections to build up the section table that
-   the objfile references.  The objfile contains pointers to the start
-   of the table (objfile->sections) and to the first location after
-   the end of the table (objfile->sections_end).  */
+/* Build up the section table that the objfile references.  The
+   objfile contains pointers to the start of the table
+   (objfile->sections) and to the first location after the end of the
+   table (objfile->sections_end).  */
 
 static void
-add_to_objfile_sections_full (struct bfd *abfd, struct bfd_section *asect,
+add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
 			      struct objfile *objfile, int force)
 {
   struct obj_section *section;
@@ -283,13 +283,6 @@ add_to_objfile_sections_full (struct bfd *abfd, struct bfd_section *asect,
   section->ovly_mapped = 0;
 }
 
-static void
-add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
-			 void *objfilep)
-{
-  add_to_objfile_sections_full (abfd, asect, (struct objfile *) objfilep, 0);
-}
-
 /* Builds a section table for OBJFILE.
 
    Note that the OFFSET and OVLY_MAPPED in each table entry are
@@ -304,14 +297,14 @@ build_objfile_section_table (struct objfile *objfile)
 				      count,
 				      struct obj_section);
   objfile->sections_end = (objfile->sections + count);
-  bfd_map_over_sections (objfile->obfd,
-			 add_to_objfile_sections, (void *) objfile);
+  for (asection *sect : gdb_bfd_sections (objfile->obfd))
+    add_to_objfile_sections (objfile->obfd, sect, objfile, 0);
 
   /* See gdb_bfd_section_index.  */
-  add_to_objfile_sections_full (objfile->obfd, bfd_com_section_ptr, objfile, 1);
-  add_to_objfile_sections_full (objfile->obfd, bfd_und_section_ptr, objfile, 1);
-  add_to_objfile_sections_full (objfile->obfd, bfd_abs_section_ptr, objfile, 1);
-  add_to_objfile_sections_full (objfile->obfd, bfd_ind_section_ptr, objfile, 1);
+  add_to_objfile_sections (objfile->obfd, bfd_com_section_ptr, objfile, 1);
+  add_to_objfile_sections (objfile->obfd, bfd_und_section_ptr, objfile, 1);
+  add_to_objfile_sections (objfile->obfd, bfd_abs_section_ptr, objfile, 1);
+  add_to_objfile_sections (objfile->obfd, bfd_ind_section_ptr, objfile, 1);
 }
 
 /* Given a pointer to an initialized bfd (ABFD) and some flag bits,
-- 
2.17.2



  parent reply	other threads:[~2020-08-28 16:23 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28 16:23 [PATCH 00/13] Use gdb_bfd_sections in more places Tom Tromey
2020-08-28 16:23 ` [PATCH 01/13] Add a new overload of gdb_bfd_sections Tom Tromey
2020-08-28 16:34   ` Simon Marchi
2020-08-28 19:25     ` Tom Tromey
2020-08-28 16:23 ` [PATCH 02/13] Use gdb_bfd_sections in core_target_open Tom Tromey
2020-08-28 16:23 ` [PATCH 03/13] Use gdb_bfd_sections in gdb_bfd_close_or_warn Tom Tromey
2020-08-28 16:23 ` [PATCH 04/13] Use gdb_bfd_sections in get_stap_base_address Tom Tromey
2020-08-28 17:06   ` Simon Marchi
2020-08-28 16:23 ` Tom Tromey [this message]
2020-08-28 16:23 ` [PATCH 06/13] Use gdb_bfd_sections in symfile.c Tom Tromey
2020-08-28 17:00   ` Simon Marchi
2020-08-28 17:06     ` Simon Marchi
2020-08-28 16:23 ` [PATCH 07/13] Use gdb_bfd_sections in dwarf2/read.c Tom Tromey
2020-08-28 16:23 ` [PATCH 08/13] Use gdb_bfd_sections in ELF osabi tag sniffing Tom Tromey
2020-08-28 16:23 ` [PATCH 09/13] Use gdb_bfd_sections in gcore_memory_sections Tom Tromey
2020-08-28 16:23 ` [PATCH 10/13] Use gdb_bfd_sections in restore_command Tom Tromey
2020-08-28 17:12   ` Simon Marchi
2020-08-29 15:47     ` Tom Tromey
2020-08-29 15:49       ` Simon Marchi
2020-08-28 16:23 ` [PATCH 11/13] Use gdb_bfd_sections in elf_symfile_read Tom Tromey
2020-08-28 16:23 ` [PATCH 12/13] Use gdb_bfd_sections in build_section_table Tom Tromey
2020-08-28 16:23 ` [PATCH 13/13] Use gdb_bfd_sections in generic_load Tom Tromey
2020-08-28 17:14 ` [PATCH 00/13] Use gdb_bfd_sections in more places Simon Marchi
2020-08-31 18:19 ` John Baldwin
2020-09-19 18:07 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200828162349.987-6-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox