Add BFD core support for Aarch64 SVE

Message ID 20180625111922.34545-1-alan.hayward@arm.com
State New
Headers show
Series
  • Add BFD core support for Aarch64 SVE
Related show

Commit Message

Alan Hayward June 25, 2018, 11:19 a.m.
Add checks for the NT_ARM_SVE section in a core file.

The NT_ARM_SVE section is documented here:
https://github.com/torvalds/linux/blob/master/Documentation/arm64/sve.txt
* A NT_ARM_SVE note will be added to each coredump for each thread of the
  dumped process.  The contents will be equivalent to the data that would have
  been read if a PTRACE_GETREGSET of NT_ARM_SVE were executed for each thread
  when the coredump was generated.

Tested with make check on aarch64 and with additional gdb code to read
in the section from a core file.

2018-06-25  Alan Hayward  <alan.hayward@arm.com>

bfd/
	* elf.c (elfcore_grok_aarch_sve): New function.
	(elfcore_grok_note): Check for Aarch64 SVE.
	(elfcore_write_aarch_sve): New function.
	(elfcore_write_register_note): Check for Aarch64 SVE.
	* elf-bfd.h(elfcore_grok_aarch_sve): New declaration.
---
 bfd/elf-bfd.h |  2 ++
 bfd/elf.c     | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

-- 
2.15.2 (Apple Git-101.1)

Comments

Alan Hayward July 2, 2018, 9:32 a.m. | #1
Ping.

If I could get this into master branch, then this will enable
me to get sve core support into gdb 8.2.

The changes follow existing code in binutils.


Thanks,
Alan.

> On 25 Jun 2018, at 12:19, Alan Hayward <Alan.Hayward@arm.com> wrote:

> 

> Add checks for the NT_ARM_SVE section in a core file.

> 

> The NT_ARM_SVE section is documented here:

> https://github.com/torvalds/linux/blob/master/Documentation/arm64/sve.txt

> * A NT_ARM_SVE note will be added to each coredump for each thread of the

>  dumped process.  The contents will be equivalent to the data that would have

>  been read if a PTRACE_GETREGSET of NT_ARM_SVE were executed for each thread

>  when the coredump was generated.

> 

> Tested with make check on aarch64 and with additional gdb code to read

> in the section from a core file.

> 

> 2018-06-25  Alan Hayward  <alan.hayward@arm.com>

> 

> bfd/

> 	* elf.c (elfcore_grok_aarch_sve): New function.

> 	(elfcore_grok_note): Check for Aarch64 SVE.

> 	(elfcore_write_aarch_sve): New function.

> 	(elfcore_write_register_note): Check for Aarch64 SVE.

> 	* elf-bfd.h(elfcore_grok_aarch_sve): New declaration.

> ---

> bfd/elf-bfd.h |  2 ++

> bfd/elf.c     | 27 +++++++++++++++++++++++++++

> 2 files changed, 29 insertions(+)

> 

> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h

> index 788fdf8e3d..6e850462da 100644

> --- a/bfd/elf-bfd.h

> +++ b/bfd/elf-bfd.h

> @@ -2598,6 +2598,8 @@ extern char *elfcore_write_aarch_hw_break

>   (bfd *, char *, int *, const void *, int);

> extern char *elfcore_write_aarch_hw_watch

>   (bfd *, char *, int *, const void *, int);

> +extern char *elfcore_write_aarch_sve

> +  (bfd *, char *, int *, const void *, int);

> extern char *elfcore_write_lwpstatus

>   (bfd *, char *, int *, long, int, const void *);

> extern char *elfcore_write_register_note

> diff --git a/bfd/elf.c b/bfd/elf.c

> index 0f75375128..feb2c6582f 100644

> --- a/bfd/elf.c

> +++ b/bfd/elf.c

> @@ -9340,6 +9340,12 @@ elfcore_grok_aarch_hw_watch (bfd *abfd, Elf_Internal_Note *note)

>   return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note);

> }

> 

> +static bfd_boolean

> +elfcore_grok_aarch_sve (bfd *abfd, Elf_Internal_Note *note)

> +{

> +  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-sve", note);

> +}

> +

> #if defined (HAVE_PRPSINFO_T)

> typedef prpsinfo_t   elfcore_psinfo_t;

> #if defined (HAVE_PRPSINFO32_T)		/* Sparc64 cross Sparc32 */

> @@ -9836,6 +9842,13 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)

>       else

> 	return TRUE;

> 

> +    case NT_ARM_SVE:

> +      if (note->namesz == 6

> +	  && strcmp (note->namedata, "LINUX") == 0)

> +	return elfcore_grok_aarch_sve (abfd, note);

> +      else

> +	return TRUE;

> +

>     case NT_PRPSINFO:

>     case NT_PSINFO:

>       if (bed->elf_backend_grok_psinfo)

> @@ -11027,6 +11040,18 @@ elfcore_write_aarch_hw_watch (bfd *abfd,

> 			     note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size);

> }

> 

> +char *

> +elfcore_write_aarch_sve (bfd *abfd,

> +			 char *buf,

> +			 int *bufsiz,

> +			 const void *aarch_sve,

> +			 int size)

> +{

> +  char *note_name = "LINUX";

> +  return elfcore_write_note (abfd, buf, bufsiz,

> +			     note_name, NT_ARM_SVE, aarch_sve, size);

> +}

> +

> char *

> elfcore_write_register_note (bfd *abfd,

> 			     char *buf,

> @@ -11079,6 +11104,8 @@ elfcore_write_register_note (bfd *abfd,

>     return elfcore_write_aarch_hw_break (abfd, buf, bufsiz, data, size);

>   if (strcmp (section, ".reg-aarch-hw-watch") == 0)

>     return elfcore_write_aarch_hw_watch (abfd, buf, bufsiz, data, size);

> +  if (strcmp (section, ".reg-aarch-sve") == 0)

> +    return elfcore_write_aarch_sve (abfd, buf, bufsiz, data, size);

>   return NULL;

> }

> 

> -- 

> 2.15.2 (Apple Git-101.1)

>
Nick Clifton July 6, 2018, 3:29 p.m. | #2
Hi Alan,

> Ping.


Sorry - lots ot do.

> If I could get this into master branch, then this will enable

> me to get sve core support into gdb 8.2.


 
>> bfd/

>> 	* elf.c (elfcore_grok_aarch_sve): New function.

>> 	(elfcore_grok_note): Check for Aarch64 SVE.

>> 	(elfcore_write_aarch_sve): New function.

>> 	(elfcore_write_register_note): Check for Aarch64 SVE.

 
Approved and applied.

Cheers
  Nick

Patch

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 788fdf8e3d..6e850462da 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2598,6 +2598,8 @@  extern char *elfcore_write_aarch_hw_break
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_aarch_hw_watch
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_sve
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_lwpstatus
   (bfd *, char *, int *, long, int, const void *);
 extern char *elfcore_write_register_note
diff --git a/bfd/elf.c b/bfd/elf.c
index 0f75375128..feb2c6582f 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9340,6 +9340,12 @@  elfcore_grok_aarch_hw_watch (bfd *abfd, Elf_Internal_Note *note)
   return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note);
 }
 
+static bfd_boolean
+elfcore_grok_aarch_sve (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-sve", note);
+}
+
 #if defined (HAVE_PRPSINFO_T)
 typedef prpsinfo_t   elfcore_psinfo_t;
 #if defined (HAVE_PRPSINFO32_T)		/* Sparc64 cross Sparc32 */
@@ -9836,6 +9842,13 @@  elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
       else
 	return TRUE;
 
+    case NT_ARM_SVE:
+      if (note->namesz == 6
+	  && strcmp (note->namedata, "LINUX") == 0)
+	return elfcore_grok_aarch_sve (abfd, note);
+      else
+	return TRUE;
+
     case NT_PRPSINFO:
     case NT_PSINFO:
       if (bed->elf_backend_grok_psinfo)
@@ -11027,6 +11040,18 @@  elfcore_write_aarch_hw_watch (bfd *abfd,
 			     note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size);
 }
 
+char *
+elfcore_write_aarch_sve (bfd *abfd,
+			 char *buf,
+			 int *bufsiz,
+			 const void *aarch_sve,
+			 int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     note_name, NT_ARM_SVE, aarch_sve, size);
+}
+
 char *
 elfcore_write_register_note (bfd *abfd,
 			     char *buf,
@@ -11079,6 +11104,8 @@  elfcore_write_register_note (bfd *abfd,
     return elfcore_write_aarch_hw_break (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-aarch-hw-watch") == 0)
     return elfcore_write_aarch_hw_watch (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-aarch-sve") == 0)
+    return elfcore_write_aarch_sve (abfd, buf, bufsiz, data, size);
   return NULL;
 }