From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 08/13] Use gdb_bfd_sections in ELF osabi tag sniffing
Date: Fri, 28 Aug 2020 10:23:44 -0600 [thread overview]
Message-ID: <20200828162349.987-9-tom@tromey.com> (raw)
In-Reply-To: <20200828162349.987-1-tom@tromey.com>
This changes some ELF osabi tag-sniffing functions to avoid
bfd_map_over_sections, in favor of iteration. I could only readily
test the generic one.
gdb/ChangeLog
2020-08-28 Tom Tromey <tom@tromey.com>
* osabi.h (generic_elf_osabi_sniff_abi_tag_sections): Update.
* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Change
parameters.
(generic_elf_osabi_sniffer): Use foreach.
* mips-sde-tdep.c (mips_sde_elf_osabi_sniffer): Use foreach.
* arm-tdep.c (arm_elf_osabi_sniffer): Use foreach.
---
gdb/ChangeLog | 9 +++++++++
gdb/arm-tdep.c | 7 ++++---
gdb/mips-sde-tdep.c | 5 ++---
gdb/osabi.c | 10 +++++-----
gdb/osabi.h | 6 +++---
5 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 074eedb4800..962ad1a40bc 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -8754,9 +8754,10 @@ arm_elf_osabi_sniffer (bfd *abfd)
if (elfosabi == ELFOSABI_ARM)
/* GNU tools use this value. Check note sections in this case,
as well. */
- bfd_map_over_sections (abfd,
- generic_elf_osabi_sniff_abi_tag_sections,
- &osabi);
+ {
+ for (asection *sect : gdb_bfd_sections (abfd))
+ generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
+ }
/* Anything else will be handled by the generic ELF sniffer. */
return osabi;
diff --git a/gdb/mips-sde-tdep.c b/gdb/mips-sde-tdep.c
index 685c3c7263c..1d282c219e5 100644
--- a/gdb/mips-sde-tdep.c
+++ b/gdb/mips-sde-tdep.c
@@ -226,9 +226,8 @@ mips_sde_elf_osabi_sniffer (bfd *abfd)
/* If the generic sniffer gets a hit, return and let other sniffers
get a crack at it. */
- bfd_map_over_sections (abfd,
- generic_elf_osabi_sniff_abi_tag_sections,
- &osabi);
+ for (asection *sect : gdb_bfd_sections (abfd))
+ generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
if (osabi != GDB_OSABI_UNKNOWN)
return GDB_OSABI_UNKNOWN;
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 627b9d98151..e8a813b62f2 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -23,6 +23,7 @@
#include "arch-utils.h"
#include "gdbcmd.h"
#include "command.h"
+#include "gdb_bfd.h"
#include "elf-bfd.h"
@@ -439,9 +440,9 @@ check_note (bfd *abfd, asection *sect, char *note, unsigned int *sectsize,
/* Generic sniffer for ELF flavoured files. */
void
-generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect, void *obj)
+generic_elf_osabi_sniff_abi_tag_sections (bfd *abfd, asection *sect,
+ enum gdb_osabi *osabi)
{
- enum gdb_osabi *osabi = (enum gdb_osabi *) obj;
const char *name;
unsigned int sectsize;
char *note;
@@ -561,9 +562,8 @@ generic_elf_osabi_sniffer (bfd *abfd)
/* And likewise ELFOSABI_HPUX. For some reason the default
value for the EI_OSABI field is ELFOSABI_HPUX for all PA-RISC
targets (with the exception of GNU/Linux). */
- bfd_map_over_sections (abfd,
- generic_elf_osabi_sniff_abi_tag_sections,
- &osabi);
+ for (asection *sect : gdb_bfd_sections (abfd))
+ generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
break;
case ELFOSABI_FREEBSD:
diff --git a/gdb/osabi.h b/gdb/osabi.h
index a7e6a10d019..9b7ab1818c0 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -86,8 +86,8 @@ const char *gdbarch_osabi_name (enum gdb_osabi);
const char *osabi_triplet_regexp (enum gdb_osabi osabi);
/* Helper routine for ELF file sniffers. This looks at ABI tag note
- sections to determine the OS ABI from the note. It should be called
- via bfd_map_over_sections. */
-void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *, void *);
+ sections to determine the OS ABI from the note. */
+void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
+ enum gdb_osabi *);
#endif /* OSABI_H */
--
2.17.2
next prev 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 ` [PATCH 05/13] Use gdb_bfd_sections in build_objfile_section_table Tom Tromey
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 ` Tom Tromey [this message]
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-9-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