]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
arc: Add support for ARC HS extra registers in core files
authorAnton Kolesov <Anton.Kolesov@synopsys.com>
Mon, 15 May 2017 13:17:29 +0000 (16:17 +0300)
committerClaudiu Zissulescu <claziss@gmail.com>
Thu, 23 Apr 2020 08:09:09 +0000 (11:09 +0300)
When a coredump is generated, there are a few registers in
ARC HS that are put under a special section, namely ".reg-v2".
It is for backward compatibility reasons with older tools that
we have decided not to extend the generic ".reg" section.

This patch makes it possible to display the information better
regarding that section.  Compare the output of "readelf" without
and with these changes:

$ readelf -n core     # without the patch
  ...
  LINUX    0x0000000c  Unknown note type: (0x00000600)
   description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69

$ readelf -n core     # with the patch
  ...
  LINUX    0x0000000c  NT_ARC_V2 (ARC HS accumulator/extra registers)
   description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69

In another commit (soon to be submitted), GDB will makes use of these
changes to parse the extra section and its registers.

bfd/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

* elf-bfd.h (elfcore_write_arc_v2): Add prototype.
* elf.c (elfcore_grok_arc_v2): New function.
(elfcore_grok_note): Call the new function to handle the corresponding
note.
(elfcore_write_arc_v2): New function.
(elfcore_write_register_note): Call the new function to handle the
corresponding pseudo-sections.

binutils/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

* readelf.c (get_note_type): Handle NT_ARC_V2.

include/elf/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

* common.h (NT_ARC_V2): New macro definitions.

bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf.c
binutils/ChangeLog
binutils/readelf.c
include/ChangeLog
include/elf/common.h

index adba80c83847b7d9802fc09d9a96fe0eb9467ef3..c81b97b11e074960ed4528e15be3989a4cb316f9 100644 (file)
@@ -1,3 +1,13 @@
+2020-04-23  Anton Kolesov  <anton.kolesov@synopsys.com>
+
+       * elf-bfd.h (elfcore_write_arc_v2): Add prototype.
+       * elf.c (elfcore_grok_arc_v2): New function.
+       (elfcore_grok_note): Call the new function to handle the corresponding
+       note.
+       (elfcore_write_arc_v2): New function.
+       (elfcore_write_register_note): Call the new function to handle the
+       corresponding pseudo-sections.
+
 2020-04-22  Max Filippov  <jcmvbkbc@gmail.com>
 
        PR ld/25861
index 3ae98425e86f4c84823555f7830efd7fc2419bba..e69234d2ddec521cbcac925fb2690a908893a3b1 100644 (file)
@@ -2738,6 +2738,8 @@ extern char *elfcore_write_aarch_sve
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_aarch_pauth
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_arc_v2
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_lwpstatus
   (bfd *, char *, int *, long, int, const void *);
 extern char *elfcore_write_register_note
index f3364eeddf2a5db3b8e209e82c76278af574c83b..e9c525974bbf9c347f6544bb41111e894e1c5fe1 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9865,6 +9865,12 @@ elfcore_grok_aarch_pauth (bfd *abfd, Elf_Internal_Note *note)
   return elfcore_make_note_pseudosection (abfd, ".reg-aarch-pauth", note);
 }
 
+static bfd_boolean
+elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-arc-v2", note);
+}
+
 #if defined (HAVE_PRPSINFO_T)
 typedef prpsinfo_t   elfcore_psinfo_t;
 #if defined (HAVE_PRPSINFO32_T)                /* Sparc64 cross Sparc32 */
@@ -10424,6 +10430,13 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
       else
        return TRUE;
 
+    case NT_ARC_V2:
+      if (note->namesz == 6
+         && strcmp (note->namedata, "LINUX") == 0)
+       return elfcore_grok_arc_v2 (abfd, note);
+      else
+       return TRUE;
+
     case NT_ARM_VFP:
       if (note->namesz == 6
          && strcmp (note->namedata, "LINUX") == 0)
@@ -11835,6 +11848,18 @@ elfcore_write_aarch_pauth (bfd *abfd,
                             note_name, NT_ARM_PAC_MASK, aarch_pauth, size);
 }
 
+char *
+elfcore_write_arc_v2 (bfd *abfd,
+                     char *buf,
+                     int *bufsiz,
+                     const void *arc_v2,
+                     int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+                            note_name, NT_ARC_V2, arc_v2, size);
+}
+
 char *
 elfcore_write_register_note (bfd *abfd,
                             char *buf,
@@ -11917,6 +11942,8 @@ elfcore_write_register_note (bfd *abfd,
     return elfcore_write_aarch_sve (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-aarch-pauth") == 0)
     return elfcore_write_aarch_pauth (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-arc-v2") == 0)
+    return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size);
   return NULL;
 }
 
index 07626115c5307e75a2998ac8da91ba08474c8141..7f7e34020df8dd9c782ba0cde2224fc6fbfd64af 100644 (file)
@@ -1,3 +1,13 @@
+2020-04-23  Anton Kolesov  <anton.kolesov@synopsys.com>
+
+       * elf-bfd.h (elfcore_write_arc_v2): Add prototype.
+       * elf.c (elfcore_grok_arc_v2): New function.
+       (elfcore_grok_note): Call the new function to handle the corresponding
+       note.
+       (elfcore_write_arc_v2): New function.
+       (elfcore_write_register_note): Call the new function to handle the
+       corresponding pseudo-sections.
+
 2020-04-22  Max Filippov  <jcmvbkbc@gmail.com>
 
        PR ld/25861
index 4f80bd94b9301753cb729cfe1055d46082d03930..f3e374dc549a6e18669ac21209c09358a5b4c21d 100644 (file)
@@ -17642,6 +17642,8 @@ get_note_type (Filedata * filedata, unsigned e_type)
        return _("NT_ARM_HW_BREAK (AArch hardware breakpoint registers)");
       case NT_ARM_HW_WATCH:
        return _("NT_ARM_HW_WATCH (AArch hardware watchpoint registers)");
+      case NT_ARC_V2:
+       return _("NT_ARC_V2 (ARC HS accumulator/extra registers)");
       case NT_PSTATUS:
        return _("NT_PSTATUS (pstatus structure)");
       case NT_FPREGS:
index bf379cc2b6423425ccf6930af7666d43fc3d72f1..eea127a3c85b200de11d845b99f96f69aedc6591 100644 (file)
@@ -1,3 +1,7 @@
+2020-04-23  Anton Kolesov  <anton.kolesov@synopsys.com>
+
+       * elf/common.h (NT_ARC_V2): New macro definitions.
+
 2020-04-22  Max Filippov  <jcmvbkbc@gmail.com>
 
        PR ld/25861
index 6741c34a007aa5eb3940da1cfac0b2a773f507c0..26e6fbc8e6882c26d90a7186c7f5c22de6d8456d 100644 (file)
                                        /*   note name must be "LINUX".  */
 #define NT_ARM_PAC_MASK        0x406           /* AArch pointer authentication code masks */
                                        /*   note name must be "LINUX".  */
+#define NT_ARC_V2      0x600           /* ARC HS accumulator/extra registers.  */
+                                       /*   note name must be "LINUX".  */
 #define NT_SIGINFO     0x53494749      /* Fields of siginfo_t.  */
 #define NT_FILE                0x46494c45      /* Description of mapped files.  */