Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michal Lach <michal.lach@phoenix-rtos.com>
To: gdb-patches@sourceware.org
Cc: jakub.klimek@phoenix-rtos.com, michal.lach@phoenix-rtos.com,
	daniel.sawka@phoenix-rtos.com
Subject: [PATCH] gdb/sparc: implement PRSTATUS elf32-sparc handler
Date: Mon, 20 Apr 2026 13:46:02 +0200	[thread overview]
Message-ID: <20260420114608.597157-1-michal.lach@phoenix-rtos.com> (raw)

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


             reply	other threads:[~2026-04-20 11:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 11:46 Michal Lach [this message]
2026-04-20 18:42 ` Simon Marchi

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=20260420114608.597157-1-michal.lach@phoenix-rtos.com \
    --to=michal.lach@phoenix-rtos.com \
    --cc=daniel.sawka@phoenix-rtos.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jakub.klimek@phoenix-rtos.com \
    /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