Add support to readelf for reading OpenBSD ELF core notes.

Message ID YT0f7gGsPdCBfWHY@gmail.com
State New
Headers show
Series
  • Add support to readelf for reading OpenBSD ELF core notes.
Related show

Commit Message

Frederic Cambus Sept. 11, 2021, 9:30 p.m.
binutils/ChangeLog:

2021-09-11  Frederic Cambus  <fred@statdns.com>

	* readelf.c (get_openbsd_elfcore_note_type): New function.
	(process_note): Add support for OpenBSD core notes.
---
 binutils/ChangeLog |  5 +++++
 binutils/readelf.c | 24 ++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

-- 
2.31.1

Patch

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 858df6570ba..ea5a1789364 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@ 
+2021-09-11  Frederic Cambus  <fred@statdns.com>
+
+	* readelf.c (get_openbsd_elfcore_note_type): New function.
+	(process_note): Add support for OpenBSD core notes.
+
 2021-09-07  Luis Machado  <luis.machado@linaro.org>
 
 	Revert: [AArch64] MTE corefile support
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 4a6fcff3cc1..3b6f1a3ab1d 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -19989,6 +19989,26 @@  get_netbsd_elfcore_note_type (Filedata * filedata, unsigned e_type)
   return buff;
 }
 
+static const char *
+get_openbsd_elfcore_note_type (Filedata * filedata, unsigned e_type)
+{
+  switch (e_type)
+    {
+    case NT_OPENBSD_PROCINFO:
+      return _("OpenBSD procinfo structure");
+    case NT_OPENBSD_AUXV:
+      return _("OpenBSD ELF auxiliary vector data");
+    case NT_OPENBSD_REGS:
+      return _("OpenBSD regular registers");
+    case NT_OPENBSD_FPREGS:
+      return _("OpenBSD floating point registers");
+    case NT_OPENBSD_WCOOKIE:
+      return _("OpenBSD window cookie");
+    }
+
+  return get_note_type (filedata, e_type);
+}
+
 static const char *
 get_stapsdt_note_type (unsigned e_type)
 {
@@ -20770,6 +20790,10 @@  process_note (Elf_Internal_Note *  pnote,
     /* NetBSD-specific core file notes.  */
     return process_netbsd_elf_note (pnote);
 
+  else if (startswith (pnote->namedata, "OpenBSD"))
+    /* OpenBSD-specific core file notes.  */
+    nt = get_openbsd_elfcore_note_type (filedata, pnote->type);
+
   else if (startswith (pnote->namedata, "SPU/"))
     {
       /* SPU-specific core file notes.  */