public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: binutils@sourceware.org, gdb-patches@sourceware.org
Subject: [PATCH 3/5] Use pseudosections for NT_FREEBSD_X86_SEGBASES core dump notes.
Date: Thu, 24 Mar 2022 13:56:14 -0700	[thread overview]
Message-ID: <20220324205616.8517-4-jhb@FreeBSD.org> (raw)
In-Reply-To: <20220324205616.8517-1-jhb@FreeBSD.org>

This includes adding pseudosections when reading a core dump as well
as support for writing out a core dump note from a pseudosection.

bfd/ChangeLog:

	* elf-bfd.h (elfcore_write_x86_segbases): New.
	* elf.c (elfcore_grok_freebsd_note): Add pseudosections for
	NT_FREEBSD_X86_SEGBASES register notes.
	(elfcore_write_x86_segbases): New.
	(elfcore_write_register_note): Write NT_FREEBSD_X86_SEGBASES
	register notes.
---
 bfd/ChangeLog |  9 +++++++++
 bfd/elf-bfd.h |  2 ++
 bfd/elf.c     | 14 ++++++++++++++
 3 files changed, 25 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index d1a31efe59c..9085d3a7664 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2022-03-23  John Baldwin  <jhb@FreeBSD.org>
+
+	* elf-bfd.h (elfcore_write_x86_segbases): New.
+	* elf.c (elfcore_grok_freebsd_note): Add pseudosections for
+	NT_FREEBSD_X86_SEGBASES register notes.
+	(elfcore_write_x86_segbases): New.
+	(elfcore_write_register_note): Write NT_FREEBSD_X86_SEGBASES
+	register notes.
+
 2022-03-23  John Baldwin  <jhb@FreeBSD.org>
 
 	* elf.c (elfcore_grok_freebsd_note): Remove checks for namesz.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 5c3985f6e57..c7c0a793b15 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2786,6 +2786,8 @@ extern char *elfcore_write_prxfpreg
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_xstatereg
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_x86_segbases
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_ppc_vmx
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_ppc_vsx
diff --git a/bfd/elf.c b/bfd/elf.c
index a99149e50b3..37c53cfdf32 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -11027,6 +11027,9 @@ elfcore_grok_freebsd_note (bfd *abfd, Elf_Internal_Note *note)
     case NT_FREEBSD_PROCSTAT_AUXV:
       return elfcore_make_auxv_note_section (abfd, note, 4);
 
+    case NT_FREEBSD_X86_SEGBASES:
+      return elfcore_make_note_pseudosection (abfd, ".reg-x86-segbases", note);
+
     case NT_X86_XSTATE:
       return elfcore_grok_xstatereg (abfd, note);
 
@@ -11904,6 +11907,15 @@ elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
 			     note_name, NT_X86_XSTATE, xfpregs, size);
 }
 
+char *
+elfcore_write_x86_segbases (bfd *abfd, char *buf, int *bufsiz,
+			    const void *regs, int size)
+{
+  char *note_name = "FreeBSD";
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     note_name, NT_FREEBSD_X86_SEGBASES, regs, size);
+}
+
 char *
 elfcore_write_ppc_vmx (bfd *abfd,
 		       char *buf,
@@ -12441,6 +12453,8 @@ elfcore_write_register_note (bfd *abfd,
     return elfcore_write_prxfpreg (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-xstate") == 0)
     return elfcore_write_xstatereg (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-x86-segbases") == 0)
+    return elfcore_write_x86_segbases (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-ppc-vmx") == 0)
     return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-ppc-vsx") == 0)
-- 
2.34.1


  parent reply	other threads:[~2022-03-24 20:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 20:56 [PATCH 0/5] Handle FreeBSD's NT_X86_SEGBASES core dump note John Baldwin
2022-03-24 20:56 ` [PATCH 1/5] elfcore_grok_freebsd_note: Remove checks of note->namesz John Baldwin
2022-03-24 20:56 ` [PATCH 2/5] Recognize FreeBSD core dump note for x86 segment base registers John Baldwin
2022-03-24 20:56 ` John Baldwin [this message]
2022-03-24 20:56 ` [PATCH 4/5] FreeBSD/x86: Read segment base registers from NT_X86_SEGBASES John Baldwin
2022-03-24 20:56 ` [PATCH 5/5] Use I386_GSBASE_REGNUM in i386fbsd_get_thread_local_address John Baldwin

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=20220324205616.8517-4-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).