public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add support to readelf for reading OpenBSD ELF core notes.
@ 2021-09-11 21:30 Frederic Cambus
       [not found] ` <YVGb0gOIrce63C7A@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Cambus @ 2021-09-11 21:30 UTC (permalink / raw)
  To: binutils

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(+)

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.  */
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add support to readelf for reading OpenBSD ELF core notes.
       [not found] ` <YVGb0gOIrce63C7A@gmail.com>
@ 2021-09-27 17:17   ` John Baldwin
  2021-09-29 12:03     ` Frederic Cambus
  2021-09-30  0:41     ` Alan Modra
  0 siblings, 2 replies; 4+ messages in thread
From: John Baldwin @ 2021-09-27 17:17 UTC (permalink / raw)
  To: Frederic Cambus, binutils

On 9/27/21 3:24 AM, Frederic Cambus wrote:
> On Sat, Sep 11, 2021 at 11:30:22PM +0200, Frederic Cambus wrote:
>> 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.
> 
> Friendly ping. Anyone willing to have a look at this? Thanks.

I think this looks fine, but I am not an approver for binutils.

I noticed that there are also #define's for NT_OPENBSD_XFPREGS
(presumably for SSE regs on i386?) and NT_OPENBSD_IDENT.  Did
you want to handle those as well?  (That is, does modern OpenBSD
generate those?)  The first one is probably a simple change to
your existing patch.  NT_OPENBSD_IDENT might be more involved if
it is similar to NT_NETBSD_IDENT.

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add support to readelf for reading OpenBSD ELF core notes.
  2021-09-27 17:17   ` John Baldwin
@ 2021-09-29 12:03     ` Frederic Cambus
  2021-09-30  0:41     ` Alan Modra
  1 sibling, 0 replies; 4+ messages in thread
From: Frederic Cambus @ 2021-09-29 12:03 UTC (permalink / raw)
  To: binutils

On Mon, Sep 27, 2021 at 10:17:02AM -0700, John Baldwin wrote:

(Resending this as I didn't see it appear in the Binutils mailing list
archives on sourceware.org or on marc.info, so I'm suspecting a delivery
issue. Please accept my apologies if it had indeed been delivered the
first time.)

> > > 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.
> > 
> > Friendly ping. Anyone willing to have a look at this? Thanks.
> 
> I think this looks fine, but I am not an approver for binutils.

Thanks for your feedback.

> I noticed that there are also #define's for NT_OPENBSD_XFPREGS
> (presumably for SSE regs on i386?) and NT_OPENBSD_IDENT.  Did
> you want to handle those as well?  (That is, does modern OpenBSD
> generate those?)  The first one is probably a simple change to
> your existing patch.  NT_OPENBSD_IDENT might be more involved if
> it is similar to NT_NETBSD_IDENT.

The #define for NT_OPENBSD_XFPREGS is also present in OpenBSD own header
files [1], but the NT_OPENBSD_XFPREGS notes are not generated on OpenBSD,
and to the best of my knowledge have never been generated. The notes
which are generated are described here: https://man.openbsd.org/core.5

Regarding the NT_OPENBSD_IDENT note, it is generated on OpenBSD, but its
content is hardcoded [2] and the version number is not populated.

[1]: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/exec_elf.h?rev=1.90&content-type=text/x-cvsweb-markup
[2]: https://cvsweb.openbsd.org/src/lib/csu/os-note-elf.h?rev=1.5&content-type=text/x-cvsweb-markup

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Add support to readelf for reading OpenBSD ELF core notes.
  2021-09-27 17:17   ` John Baldwin
  2021-09-29 12:03     ` Frederic Cambus
@ 2021-09-30  0:41     ` Alan Modra
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Modra @ 2021-09-30  0:41 UTC (permalink / raw)
  To: John Baldwin; +Cc: Frederic Cambus, binutils

On Mon, Sep 27, 2021 at 10:17:02AM -0700, John Baldwin wrote:
> On 9/27/21 3:24 AM, Frederic Cambus wrote:
> > On Sat, Sep 11, 2021 at 11:30:22PM +0200, Frederic Cambus wrote:
> > > 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.
> > 
> > Friendly ping. Anyone willing to have a look at this? Thanks.
> 
> I think this looks fine, but I am not an approver for binutils.

Thanks for chiming in.  I've committed the patch.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-30  0:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 21:30 [PATCH] Add support to readelf for reading OpenBSD ELF core notes Frederic Cambus
     [not found] ` <YVGb0gOIrce63C7A@gmail.com>
2021-09-27 17:17   ` John Baldwin
2021-09-29 12:03     ` Frederic Cambus
2021-09-30  0:41     ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).