[PATCH 1/1] bfd: Handle note of type NT_X86_SHSTK

H.J. Lu hjl.tools@gmail.com
Thu May 8 12:37:35 GMT 2025


On Fri, Feb 14, 2025 at 12:43 AM Christina Schimpe
<christina.schimpe@intel.com> wrote:
>
> ---
>  bfd/elf.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>
> diff --git a/bfd/elf.c b/bfd/elf.c
> index 129cac58382..03fe7efc961 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -10389,6 +10389,12 @@ elfcore_grok_xstatereg (bfd *abfd, Elf_Internal_Note *note)
>    return elfcore_make_note_pseudosection (abfd, ".reg-xstate", note);
>  }
>
> +static bool
> +elfcore_grok_sspreg (bfd *abfd, Elf_Internal_Note *note)
> +{
> +  return elfcore_make_note_pseudosection (abfd, ".reg-ssp", note);
> +}
> +
>  static bool
>  elfcore_grok_ppc_vmx (bfd *abfd, Elf_Internal_Note *note)
>  {
> @@ -11084,6 +11090,13 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
>        else
>         return true;
>
> +    case NT_X86_SHSTK:         /* Linux CET extension.  */
> +      if (note->namesz == 6
> +         && strcmp (note->namedata, "LINUX") == 0)
> +       return elfcore_grok_sspreg (abfd, note);
> +      else
> +       return true;
> +
>      case NT_PPC_VMX:
>        if (note->namesz == 6
>           && strcmp (note->namedata, "LINUX") == 0)
> @@ -12534,6 +12547,15 @@ elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
>                              note_name, NT_X86_XSTATE, xfpregs, size);
>  }
>
> +static char *
> +elfcore_write_sspreg (bfd *abfd, char *buf, int *bufsiz,
> +                     const void *ssp, int size)
> +{
> +  const char *note_name = "LINUX";
> +  return elfcore_write_note (abfd, buf, bufsiz,
> +                            note_name, NT_X86_SHSTK, ssp, size);
> +}
> +
>  char *
>  elfcore_write_x86_segbases (bfd *abfd, char *buf, int *bufsiz,
>                             const void *regs, int size)
> @@ -13129,6 +13151,8 @@ elfcore_write_register_note (bfd *abfd,
>      return elfcore_write_xstatereg (abfd, buf, bufsiz, data, size);
>    if (strcmp (section, ".reg-x86-segbases") == 0)
>      return elfcore_write_x86_segbases (abfd, buf, bufsiz, data, size);
> +  if (strcmp (section, ".reg-ssp") == 0)
> +    return elfcore_write_sspreg (abfd, buf, bufsiz, data, size);
>    if (strcmp (section, ".reg-ppc-vmx") == 0)
>      return elfcore_write_ppc_vmx (abfd, buf, bufsiz, data, size);
>    if (strcmp (section, ".reg-ppc-vsx") == 0)
> --
> 2.34.1
>
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de
> Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.

-- 
H.J.


More information about the Binutils mailing list