[PATCH] gdb/sparc: implement PRSTATUS elf32-sparc handler

Simon Marchi simark@simark.ca
Mon Apr 20 18:42:33 GMT 2026


Adding binutils@sourceware.org, since this targets code in "bfd".

Can someone from binutils review this?

Thanks,

Simon

On 4/20/26 7:46 AM, Michal Lach wrote:
> From: Jakub Klimek <jakub.klimek@phoenix-rtos.com>
> 
> Some SPARC ELF32 coredumps emit a PRSTATUS note which is left unparsed
> without a handler in GDB, leading to incorrectly viewed coredumps.
> ---
>  bfd/elf32-sparc.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
> index a5f5d058196..837b2e16fff 100644
> --- a/bfd/elf32-sparc.c
> +++ b/bfd/elf32-sparc.c
> @@ -31,6 +31,34 @@
> 
>  /* Support for core dump NOTE sections.  */
> 
> +static bool
> +elf32_sparc_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
> +{
> +  int offset;
> +  size_t size;
> +
> +  switch (note->descsz)
> +    {
> +    default:
> +      return false;
> +    case 228:
> +      /* pr_cursig */
> +      elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
> +
> +      /* pr_pid */
> +      elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
> +
> +      /* pr_reg */
> +      offset = 72;
> +      size = 152;
> +
> +      break;
> +    }
> +
> +  /* Make a ".reg/999" section.  */
> +  return _bfd_elfcore_make_pseudosection (abfd, ".reg", size, note->descpos + offset);
> +}
> +
>  static bool
>  elf32_sparc_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
>  {
> @@ -230,6 +258,7 @@ elf32_sparc_reloc_type_class (const struct bfd_link_info *info,
>  					elf32_sparc_merge_private_bfd_data
>  #define elf_backend_final_write_processing \
>  					elf32_sparc_final_write_processing
> +#define elf_backend_grok_prstatus	elf32_sparc_grok_prstatus
>  #define elf_backend_grok_psinfo		elf32_sparc_grok_psinfo
>  #define elf_backend_reloc_type_class	elf32_sparc_reloc_type_class
> 
> --
> 2.53.0
> 


More information about the Binutils mailing list