[PATCH] Fix m68k OS ABI sniffer

Andreas Schwab
2024-08-14T16:52:04Z

Do not override the generic OS ABI sniffer.

Fixes: 3eba3a011a8 ("Various m68k fixes for gdb")
---
gdb/m68k-tdep.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 439ebd241e8..0d268aa947b 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -1353,11 +1353,19 @@ static enum gdb_osabi
m68k_osabi_sniffer (bfd *abfd)
{
unsigned int elfosabi = elf_elfheader (abfd)->e_ident[EI_OSABI];
+ enum gdb_osabi osabi = GDB_OSABI_UNKNOWN;

if (elfosabi == ELFOSABI_NONE)
- return GDB_OSABI_SVR4;
+ {
+ /* Check note sections. */
+ for (asection *sect : gdb_bfd_sections (abfd))
+ generic_elf_osabi_sniff_abi_tag_sections (abfd, sect, &osabi);
+
+ if (osabi == GDB_OSABI_UNKNOWN)
+ osabi = GDB_OSABI_SVR4;
+ }

- return GDB_OSABI_UNKNOWN;
+ return osabi;
}

void _initialize_m68k_tdep ();
--
2.46.0

--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."