[PATCH] x86: ld: sframe: Remove SFrame NULL FRE template

Indu Bhagat indu.bhagat@oracle.com
Tue Jul 1 00:08:16 GMT 2025


On 6/27/25 7:10 AM, Jens Remus wrote:
> A SFrame NULL FRE template is used as NULL value in some but not all
> instances to initialize unused elements of SFrame FRE pointer arrays of
> fixed size.  Additionally it is erroneously used as SFrame FRE template
> for PLT GOT entries.
> 
> Define a separate SFrame FRE template for PLT GOT entries with the same
> properties as the SFrame NULL FRE and use that for all PLT GOT entries.
> Remove the SFrame NULL FRE template, as initialization of unused array
> elements is not required, as demonstrated by the instances where it was
> not done.
> 
> bfd/
> 	* elf64-x86-64.c (elf_x86_64_sframe_null_fre): Remove.
> 	(elf_x86_64_sframe_pltgot_fre1): New SFrame FRE template for
> 	PLT GOT entries.
> 	(elf_x86_64_sframe_non_lazy_plt,
> 	elf_x86_64_sframe_non_lazy_ibt_plt): Do not initialize unused
> 	FRE array elements with elf_x86_64_sframe_null_fre.  Use
> 	elf_x86_64_sframe_pltgot_fre1 for PLT GOT.
> 	(elf_x86_64_sframe_plt, elf_x86_64_sframe_ibt_plt): Use
> 	elf_x86_64_sframe_pltgot_fre1 for PLT GOT.
> 
> Signed-off-by: Jens Remus <jremus@linux.ibm.com>

Hi Jens,

Looks good to me.  Thanks for working on this.

Indu

> ---
> 
> Notes (jremus):
>      This was noticed when wrongly using the term SFrame NULL FRE in my s390
>      SFrame support series:
>      https://inbox.sourceware.org/binutils/41c78ff7-d35d-4e70-8719-a6024d8882d2@linux.ibm.com/
> 
>   bfd/elf64-x86-64.c | 31 ++++++++++++++++---------------
>   1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
> index 6867d4934695..b9b3cf831c44 100644
> --- a/bfd/elf64-x86-64.c
> +++ b/bfd/elf64-x86-64.c
> @@ -868,13 +868,6 @@ static const bfd_byte elf_x86_64_eh_frame_non_lazy_plt[] =
>     DW_CFA_nop, DW_CFA_nop, DW_CFA_nop
>   };
>   
> -static const sframe_frame_row_entry elf_x86_64_sframe_null_fre =
> -{
> -  0,
> -  {16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* 12 bytes.  */
> -  SFRAME_V1_FRE_INFO (SFRAME_BASE_REG_SP, 1, SFRAME_FRE_OFFSET_1B) /* FRE info.  */
> -};
> -
>   /* .sframe FRE covering the .plt section entry.  */
>   static const sframe_frame_row_entry elf_x86_64_sframe_plt0_fre1 =
>   {
> @@ -923,6 +916,14 @@ static const sframe_frame_row_entry elf_x86_64_sframe_sec_pltn_fre1 =
>     SFRAME_V1_FRE_INFO (SFRAME_BASE_REG_SP, 1, SFRAME_FRE_OFFSET_1B) /* FRE info.  */
>   };
>   
> +/* .sframe FRE covering the .plt.got section entry.  */
> +static const sframe_frame_row_entry elf_x86_64_sframe_pltgot_fre1 =
> +{
> +  0, /* SFrame FRE start address.  */
> +  {16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* 12 bytes.  */
> +  SFRAME_V1_FRE_INFO (SFRAME_BASE_REG_SP, 1, SFRAME_FRE_OFFSET_1B) /* FRE info.  */
> +};
> +
>   /* SFrame helper object for non-lazy PLT.  */
>   static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_plt =
>   {
> @@ -933,14 +934,14 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_plt =
>     LAZY_PLT_ENTRY_SIZE,
>     1, /* Number of FREs for PLTn.  */
>     /* Array of SFrame FREs for plt.  */
> -  { &elf_x86_64_sframe_sec_pltn_fre1, &elf_x86_64_sframe_null_fre },
> +  { &elf_x86_64_sframe_sec_pltn_fre1 },
>     0,
>     0, /* There is no second PLT necessary.  */
> -  { &elf_x86_64_sframe_null_fre },
> +  { },
>     NON_LAZY_PLT_ENTRY_SIZE,
>     1, /* Number of FREs for PLT GOT.  */
>     /* Array of SFrame FREs for PLT GOT.  */
> -  { &elf_x86_64_sframe_null_fre },
> +  { &elf_x86_64_sframe_pltgot_fre1 },
>   };
>   
>   /* SFrame helper object for non-lazy IBT enabled PLT.  */
> @@ -953,14 +954,14 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_non_lazy_ibt_plt =
>     LAZY_PLT_ENTRY_SIZE,
>     1, /* Number of FREs for PLTn.  */
>     /* Array of SFrame FREs for plt.  */
> -  { &elf_x86_64_sframe_sec_pltn_fre1, &elf_x86_64_sframe_null_fre },
> +  { &elf_x86_64_sframe_sec_pltn_fre1 },
>     0,
>     0, /* There is no second PLT necessary.  */
> -  { &elf_x86_64_sframe_null_fre },
> +  { },
>     LAZY_PLT_ENTRY_SIZE,
>     1, /* Number of FREs for PLT GOT.  */
>     /* Array of SFrame FREs for PLT GOT.  */
> -  { &elf_x86_64_sframe_null_fre },
> +  { &elf_x86_64_sframe_pltgot_fre1 },
>   };
>   
>   /* SFrame helper object for lazy PLT. */
> @@ -981,7 +982,7 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_plt =
>     NON_LAZY_PLT_ENTRY_SIZE,
>     1, /* Number of FREs for PLT GOT.  */
>     /* Array of SFrame FREs for PLT GOT.  */
> -  { &elf_x86_64_sframe_null_fre },
> +  { &elf_x86_64_sframe_pltgot_fre1 },
>   };
>   
>   /* SFrame helper object for lazy PLT with IBT. */
> @@ -1002,7 +1003,7 @@ static const struct elf_x86_sframe_plt elf_x86_64_sframe_ibt_plt =
>     LAZY_PLT_ENTRY_SIZE,
>     1, /* Number of FREs for PLT GOT.  */
>     /* Array of SFrame FREs for PLT GOT.  */
> -  { &elf_x86_64_sframe_null_fre },
> +  { &elf_x86_64_sframe_pltgot_fre1 },
>   };
>   
>   /* These are the standard parameters.  */



More information about the Binutils mailing list