[PATCH] bfd: Add support to read note that describes xsave layout
Jan Beulich
jbeulich@suse.com
Thu Sep 11 07:40:39 GMT 2025
On 11.09.2025 09:17, Vignesh Balasubramanian wrote:
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -114,6 +114,7 @@ SECTION
> #define NOTE_PSEUDO_SECTION_X86_SEGBASES ".reg-x86-segbases"
> #define NOTE_PSEUDO_SECTION_XFP ".reg-xfp"
> #define NOTE_PSEUDO_SECTION_XSTATE ".reg-xstate"
> +#define NOTE_PSEUDO_SECTION_XSAVE_LAYOUT ".reg.xsave.layout"
Why dots instead of dashes as separators here, and ...
> @@ -10492,6 +10493,14 @@ elfcore_grok_sspreg (bfd *abfd, Elf_Internal_Note *note)
> return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_SSP, note);
> }
>
> +/* Linux dumps the XSAVE Layout description in a note named "LINUX"
> + with a note type of NT_X86_XSAVE_LAYOUT. */
> +static bool
> +elfcore_grok_xsave_layout_desc (bfd *abfd, Elf_Internal_Note *note)
> +{
> + return elfcore_make_note_pseudosection (abfd, ".reg-xsave-layout", note);
... why not using the #define here?
> @@ -12390,6 +12400,17 @@ elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
> note_name, NT_X86_XSTATE, xfpregs, size);
> }
>
> +char *
> +elfcore_write_xsave_layout (bfd *abfd, char *buf, int *bufsiz,
> + const void *xsave_layout, int size)
> +{
> + return elfcore_write_note (abfd, buf, bufsiz,
> + NOTE_NAME_LINUX,
> + NT_X86_XSAVE_LAYOUT,
> + xsave_layout,
> + size);
> +}
> +
> static char *
> elfcore_write_sspreg (bfd *abfd, char *buf, int *bufsiz,
> const void *ssp, int size)
> @@ -13035,7 +13056,8 @@ elfcore_write_register_note (bfd *abfd,
> { NOTE_PSEUDO_SECTION_TDESC, elfcore_write_gdb_tdesc},
> { NOTE_PSEUDO_SECTION_X86_SEGBASES, elfcore_write_x86_segbases},
> { NOTE_PSEUDO_SECTION_XFP, elfcore_write_prxfpreg},
> - { NOTE_PSEUDO_SECTION_XSTATE, elfcore_write_xstatereg} /* NB/ No comma. */
> + { NOTE_PSEUDO_SECTION_XSTATE, elfcore_write_xstatereg},
> + { NOTE_PSEUDO_SECTION_XSAVE_LAYOUT, elfcore_write_xsave_layout} /* NB/ No comma. */
> };
Considering the subject: There's more code here dealing with writing of
such a note ...
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -21375,6 +21375,8 @@ get_note_type (Filedata * filedata, unsigned e_type)
> return _("NT_386_IOPERM (x86 I/O permissions)");
> case NT_X86_XSTATE:
> return _("NT_X86_XSTATE (x86 XSAVE extended state)");
> + case NT_X86_XSAVE_LAYOUT:
> + return _("NT_X86_XSAVE_LAYOUT (x86 XSAVE Layout description)");
> case NT_X86_CET:
> return _("NT_X86_CET (x86 CET state)");
> case NT_X86_SHSTK:
... than the "reading" of it (you only recognize it aiui, without actually
displaying its contents in a human-readable manner). IOW I'd suggest
s/read/handle/ along with adding "minimal" for the subject.
Jan
More information about the Binutils
mailing list