]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd/ELF: Core file support for AArch64 FPMR
authorEzra Sitorus <ezra.sitorus@arm.com>
Mon, 17 Nov 2025 12:45:58 +0000 (12:45 +0000)
committerezra.sitorus <ezra.sitorus@arm.com>
Mon, 17 Nov 2025 12:47:09 +0000 (12:47 +0000)
The Floating Point Mode Register is a new register which controls the
behaviour of FP8 instructions. This is handled by the Linux kernel
through a new NT_ARM_FPMR register set.

This patch adds required code to support core file dumps with
NT_ARM_FPMR in them.

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

index c9aa3ff9ca9b39666df75a7a9c4aaf7b0399f176..418b4e91b8b6b3df5be8d1a1f53886b869717d0b 100644 (file)
@@ -3037,6 +3037,8 @@ extern char *elfcore_write_aarch_za
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_aarch_zt
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_fpmr
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_arc_v2
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_riscv_csr
index 1f4109ddf480c62b20b23541fdaa8f041ce1c9dd..bf50fc21f95d9ccb378703e1c33f5b395d5db378 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -61,6 +61,7 @@ SECTION
 #define NOTE_NAME_LINUX    "LINUX"
 
 /* Names of a pseudo-section which represent core notes.  */
+#define NOTE_PSEUDO_SECTION_AARCH_FPMR         ".reg-aarch-fpmr"
 #define NOTE_PSEUDO_SECTION_AARCH_GCS          ".reg-aarch-gcs"
 #define NOTE_PSEUDO_SECTION_AARCH_HW_BREAK     ".reg-aarch-hw-break"
 #define NOTE_PSEUDO_SECTION_AARCH_HW_WATCH     ".reg-aarch-hw-watch"
@@ -10731,6 +10732,15 @@ elfcore_grok_aarch_gcs (bfd *abfd, Elf_Internal_Note *note)
   return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_GCS, note);
 }
 
+/* Convert NOTE into the appropriate note pseudo-section for the AArch64 FPMR.
+ * Return TRUE if successful, otherwise return FALSE.  */
+
+static bool
+elfcore_grok_aarch_fpmr (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_AARCH_FPMR, note);
+}
+
 static bool
 elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note)
 {
@@ -11164,6 +11174,7 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
        {
        case NT_386_TLS:        return elfcore_grok_i386_tls (abfd, note);
        case NT_ARC_V2:         return elfcore_grok_arc_v2 (abfd, note);
+       case NT_ARM_FPMR:       return elfcore_grok_aarch_fpmr (abfd, note);
        case NT_ARM_GCS:        return elfcore_grok_aarch_gcs (abfd, note);
        case NT_ARM_HW_BREAK:   return elfcore_grok_aarch_hw_break (abfd, note);
        case NT_ARM_HW_WATCH:   return elfcore_grok_aarch_hw_watch (abfd, note);
@@ -12877,6 +12888,22 @@ elfcore_write_aarch_gcs (bfd *abfd, char *buf, int *bufsiz,
                             aarch_gcs, size);
 }
 
+/* Write the buffer of FPMR value in AARCH_FPMR (length SIZE) into
+   the note buffer BUF and update *BUFSIZ.  ABFD is the bfd the note is being
+   written into.  Return a pointer to the new start of the note buffer, to
+   replace BUF which may no longer be valid.  */
+
+char *
+elfcore_write_aarch_fpmr (bfd *abfd,
+                       char *buf,
+                       int *bufsiz,
+                       const void *aarch_fpmr,
+                       int size)
+{
+  return elfcore_write_note (abfd, buf, bufsiz,
+                            NOTE_NAME_LINUX, NT_ARM_FPMR, aarch_fpmr, size);
+}
+
 char *
 elfcore_write_arc_v2 (bfd *abfd,
                      char *buf,
@@ -12983,6 +13010,7 @@ elfcore_write_register_note (bfd *abfd,
     }
   note_writers [] =
     {
+      { NOTE_PSEUDO_SECTION_AARCH_FPMR,       elfcore_write_aarch_fpmr},
       { NOTE_PSEUDO_SECTION_AARCH_GCS,        elfcore_write_aarch_gcs},
       { NOTE_PSEUDO_SECTION_AARCH_HW_BREAK,   elfcore_write_aarch_hw_break},
       { NOTE_PSEUDO_SECTION_AARCH_HW_WATCH,   elfcore_write_aarch_hw_watch},
index 933dd34d4a869eb7dadee3f858999d11f0063ec0..633453ae2b21781be897ad46883dfb9a997749fb 100644 (file)
@@ -21437,6 +21437,8 @@ get_note_type (Filedata * filedata, unsigned e_type)
        return _("NT_ARM_ZT (AArch64 SME2 ZT registers)");
       case NT_ARM_PAC_ENABLED_KEYS:
        return _("NT_ARM_PAC_ENABLED_KEYS (AArch64 pointer authentication enabled keys)");
+      case NT_ARM_FPMR:
+       return _("NT_ARM_FPMR (AArch64 Floating Point Mode Register)");
       case NT_ARC_V2:
        return _("NT_ARC_V2 (ARC HS accumulator/extra registers)");
       case NT_RISCV_CSR:
index 8a2ab7b055e86cfab792255536e7dab3d605dee4..2db8a7d5a476e0ee80fc1fd5cd704ae546334633 100644 (file)
                                        /*   Note: name must be "LINUX".  */
 #define NT_ARM_ZT       0x40d           /* AArch64 SME2 ZT registers.  */
                                        /*   Note: name must be "LINUX".  */
+#define NT_ARM_FPMR     0x40e           /* AArch64 FPMR.  */
+                                       /*   Note: name must be "LINUX".  */
 #define NT_ARM_GCS     0x410           /* AArch64 Guarded Control Stack
                                           registers.  */
                                        /*   Note  name must be "LINUX".  */