[PATCH] bfd/aarch64: Core file support for FPMR

Luis luis.machado.foss@gmail.com
Sun Sep 7 00:52:29 GMT 2025


On 04/09/2025 12:23, Ezra.Sitorus@arm.com wrote:
> From: Ezra Sitorus <ezra.sitorus@arm.com>
> 
> Add required code to support core file dumps with NT_ARM_FPMR in them.

"... with NT_ARM_FPMR notes in them."

Probably personal taste (and up to binutils maintainers), but I would 
mention the feature this is related to in the commit message. That gives 
it more context. Doesn´t need to be as verbose as 
11e3488d3f787d51196a115fd9c6085e57bd9626, but should give you a 
potential example.

> ---
> Regression tested on aarch64-none-linux-gnu.
> 
> Ezra
> 
>   bfd/elf-bfd.h        |  2 ++
>   bfd/elf.c            | 28 ++++++++++++++++++++++++++++
>   binutils/readelf.c   |  2 ++
>   include/elf/common.h |  2 ++
>   4 files changed, 34 insertions(+)
> 
> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
> index de7cc410a99..7fff172b84e 100644
> --- a/bfd/elf-bfd.h
> +++ b/bfd/elf-bfd.h
> @@ -3003,6 +3003,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
> diff --git a/bfd/elf.c b/bfd/elf.c
> index 6ef60301091..6abfed057da 100644
> --- 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"
> @@ -10732,6 +10733,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 a bfd_section called ".reg-aarch-fpmr".  Return TRUE if

With the recent tidying of the code, this reference to ".reg-aarch-fpmr" 
is somewhat lost. I´d say this converts NOTE into the appropriate 
pseudo-section for the AArch64 FPMR register.

> +   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)
>   {
> @@ -11165,6 +11175,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);
> @@ -12878,6 +12889,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,
> @@ -12984,6 +13011,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},
> diff --git a/binutils/readelf.c b/binutils/readelf.c
> index 2affc713adb..dda4bb38b72 100644
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -21347,6 +21347,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:
> diff --git a/include/elf/common.h b/include/elf/common.h
> index 0d9a7b7a8a9..ebe893ebf13 100644
> --- a/include/elf/common.h
> +++ b/include/elf/common.h
> @@ -741,6 +741,8 @@
>   					/*   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.  */

That comment should probably say "AArch64 FPMR register." to follow the 
pattern of the other entries.


More information about the Binutils mailing list