]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: ld: sframe: Remove SFrame NULL FRE template
authorJens Remus <jremus@linux.ibm.com>
Tue, 1 Jul 2025 15:56:10 +0000 (17:56 +0200)
committerJens Remus <jremus@linux.ibm.com>
Tue, 1 Jul 2025 15:56:10 +0000 (17:56 +0200)
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>
bfd/elf64-x86-64.c

index 6867d4934695d9d1acf0d6b7d77927748939ad30..b9b3cf831c449304002266a11ac530f0fc0c8d8e 100644 (file)
@@ -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.  */