Blame SOURCES/gdb-rhbz1669953-aarch64-sve-binutils.patch

689258
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
689258
From: Keith Seitz <keiths@redhat.com>
689258
Date: Tue, 19 Mar 2019 11:38:37 -0700
689258
Subject: gdb-rhbz1669953-aarch64-sve-binutils.patch
689258
689258
;; Fix 'gdb fails to read zN registers from corefile with aarch64 SVE'
689258
;; Alan Hayward, RH BZ 1669953
689258
689258
Add checks for the NT_ARM_SVE section in a core file.
689258
689258
The NT_ARM_SVE section is documented here:
689258
  https://github.com/torvalds/linux/blob/master/Documentation/arm64/sve.txt
689258
  * A NT_ARM_SVE note will be added to each coredump for each thread of the
689258
   dumped process.  The contents will be equivalent to the data that would have
689258
   been read if a PTRACE_GETREGSET of NT_ARM_SVE were executed for each thread
689258
   when the coredump was generated.
689258
689258
        * elf.c (elfcore_grok_aarch_sve): New function.
689258
        (elfcore_grok_note): Check for Aarch64 SVE.
689258
        (elfcore_write_aarch_sve): New function.
689258
        (elfcore_write_register_note): Check for Aarch64 SVE.
689258
        * elf-bfd.h(elfcore_grok_aarch_sve): New declaration.
689258
689258
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
689258
--- a/bfd/elf-bfd.h
689258
+++ b/bfd/elf-bfd.h
689258
@@ -2601,6 +2601,8 @@ extern char *elfcore_write_aarch_hw_break
689258
   (bfd *, char *, int *, const void *, int);
689258
 extern char *elfcore_write_aarch_hw_watch
689258
   (bfd *, char *, int *, const void *, int);
689258
+extern char *elfcore_write_aarch_sve
689258
+  (bfd *, char *, int *, const void *, int);
689258
 extern char *elfcore_write_lwpstatus
689258
   (bfd *, char *, int *, long, int, const void *);
689258
 extern char *elfcore_write_register_note
689258
diff --git a/bfd/elf.c b/bfd/elf.c
689258
--- a/bfd/elf.c
689258
+++ b/bfd/elf.c
689258
@@ -9340,6 +9340,12 @@ elfcore_grok_aarch_hw_watch (bfd *abfd, Elf_Internal_Note *note)
689258
   return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note);
689258
 }
689258
 
689258
+static bfd_boolean
689258
+elfcore_grok_aarch_sve (bfd *abfd, Elf_Internal_Note *note)
689258
+{
689258
+  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-sve", note);
689258
+}
689258
+
689258
 #if defined (HAVE_PRPSINFO_T)
689258
 typedef prpsinfo_t   elfcore_psinfo_t;
689258
 #if defined (HAVE_PRPSINFO32_T)		/* Sparc64 cross Sparc32 */
689258
@@ -9836,6 +9842,13 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
689258
       else
689258
 	return TRUE;
689258
 
689258
+    case NT_ARM_SVE:
689258
+      if (note->namesz == 6
689258
+	  && strcmp (note->namedata, "LINUX") == 0)
689258
+	return elfcore_grok_aarch_sve (abfd, note);
689258
+      else
689258
+	return TRUE;
689258
+
689258
     case NT_PRPSINFO:
689258
     case NT_PSINFO:
689258
       if (bed->elf_backend_grok_psinfo)
689258
@@ -11027,6 +11040,18 @@ elfcore_write_aarch_hw_watch (bfd *abfd,
689258
 			     note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size);
689258
 }
689258
 
689258
+char *
689258
+elfcore_write_aarch_sve (bfd *abfd,
689258
+			 char *buf,
689258
+			 int *bufsiz,
689258
+			 const void *aarch_sve,
689258
+			 int size)
689258
+{
689258
+  char *note_name = "LINUX";
689258
+  return elfcore_write_note (abfd, buf, bufsiz,
689258
+			     note_name, NT_ARM_SVE, aarch_sve, size);
689258
+}
689258
+
689258
 char *
689258
 elfcore_write_register_note (bfd *abfd,
689258
 			     char *buf,
689258
@@ -11079,6 +11104,8 @@ elfcore_write_register_note (bfd *abfd,
689258
     return elfcore_write_aarch_hw_break (abfd, buf, bufsiz, data, size);
689258
   if (strcmp (section, ".reg-aarch-hw-watch") == 0)
689258
     return elfcore_write_aarch_hw_watch (abfd, buf, bufsiz, data, size);
689258
+  if (strcmp (section, ".reg-aarch-sve") == 0)
689258
+    return elfcore_write_aarch_sve (abfd, buf, bufsiz, data, size);
689258
   return NULL;
689258
 }
689258