Use gdb_bfd_sections in ELF osabi tag sniffing
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-09-19 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.
This commit is contained in:
parent
5bb6e9dd70
commit
b35c1d1cf4
@ -1,3 +1,12 @@
|
|||||||
|
2020-09-19 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.
|
||||||
|
|
||||||
2020-09-19 Tom Tromey <tom@tromey.com>
|
2020-09-19 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* dwarf2/read.c (locate_dwz_sections): Change parameters.
|
* dwarf2/read.c (locate_dwz_sections): Change parameters.
|
||||||
|
@ -8863,9 +8863,10 @@ arm_elf_osabi_sniffer (bfd *abfd)
|
|||||||
if (elfosabi == ELFOSABI_ARM)
|
if (elfosabi == ELFOSABI_ARM)
|
||||||
/* GNU tools use this value. Check note sections in this case,
|
/* GNU tools use this value. Check note sections in this case,
|
||||||
as well. */
|
as well. */
|
||||||
bfd_map_over_sections (abfd,
|
{
|
||||||
generic_elf_osabi_sniff_abi_tag_sections,
|
for (asection *sect : gdb_bfd_sections (abfd))
|
||||||
&osabi);
|
generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
|
||||||
|
}
|
||||||
|
|
||||||
/* Anything else will be handled by the generic ELF sniffer. */
|
/* Anything else will be handled by the generic ELF sniffer. */
|
||||||
return osabi;
|
return osabi;
|
||||||
|
@ -226,9 +226,8 @@ mips_sde_elf_osabi_sniffer (bfd *abfd)
|
|||||||
|
|
||||||
/* If the generic sniffer gets a hit, return and let other sniffers
|
/* If the generic sniffer gets a hit, return and let other sniffers
|
||||||
get a crack at it. */
|
get a crack at it. */
|
||||||
bfd_map_over_sections (abfd,
|
for (asection *sect : gdb_bfd_sections (abfd))
|
||||||
generic_elf_osabi_sniff_abi_tag_sections,
|
generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
|
||||||
&osabi);
|
|
||||||
if (osabi != GDB_OSABI_UNKNOWN)
|
if (osabi != GDB_OSABI_UNKNOWN)
|
||||||
return GDB_OSABI_UNKNOWN;
|
return GDB_OSABI_UNKNOWN;
|
||||||
|
|
||||||
|
10
gdb/osabi.c
10
gdb/osabi.c
@ -23,6 +23,7 @@
|
|||||||
#include "arch-utils.h"
|
#include "arch-utils.h"
|
||||||
#include "gdbcmd.h"
|
#include "gdbcmd.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
#include "gdb_bfd.h"
|
||||||
|
|
||||||
#include "elf-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. */
|
/* Generic sniffer for ELF flavoured files. */
|
||||||
|
|
||||||
void
|
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;
|
const char *name;
|
||||||
unsigned int sectsize;
|
unsigned int sectsize;
|
||||||
char *note;
|
char *note;
|
||||||
@ -561,9 +562,8 @@ generic_elf_osabi_sniffer (bfd *abfd)
|
|||||||
/* And likewise ELFOSABI_HPUX. For some reason the default
|
/* And likewise ELFOSABI_HPUX. For some reason the default
|
||||||
value for the EI_OSABI field is ELFOSABI_HPUX for all PA-RISC
|
value for the EI_OSABI field is ELFOSABI_HPUX for all PA-RISC
|
||||||
targets (with the exception of GNU/Linux). */
|
targets (with the exception of GNU/Linux). */
|
||||||
bfd_map_over_sections (abfd,
|
for (asection *sect : gdb_bfd_sections (abfd))
|
||||||
generic_elf_osabi_sniff_abi_tag_sections,
|
generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
|
||||||
&osabi);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELFOSABI_FREEBSD:
|
case ELFOSABI_FREEBSD:
|
||||||
|
@ -86,8 +86,8 @@ const char *gdbarch_osabi_name (enum gdb_osabi);
|
|||||||
const char *osabi_triplet_regexp (enum gdb_osabi osabi);
|
const char *osabi_triplet_regexp (enum gdb_osabi osabi);
|
||||||
|
|
||||||
/* Helper routine for ELF file sniffers. This looks at ABI tag note
|
/* 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
|
sections to determine the OS ABI from the note. */
|
||||||
via bfd_map_over_sections. */
|
void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
|
||||||
void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *, void *);
|
enum gdb_osabi *);
|
||||||
|
|
||||||
#endif /* OSABI_H */
|
#endif /* OSABI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user