Re: [PATCH] Fix m68k OS ABI sniffer

Kevin Buettner
2024-08-18T17:17:48Z

On Wed, 14 Aug 2024 18:51:40 +0200
Andreas Schwab <schwab@linux-m68k.org> wrote:

> 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;
> }

LGTM.

Reviewed-by: Kevin Buettner <kevinb@redhat.com>