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

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