[PATCH 3/3] ld: Cleanup sframe_decoder_init_func_bfdinfo use of cookie->rel

Jens Remus jremus@linux.ibm.com
Fri Feb 21 16:56:40 GMT 2025


The loop does set cookie->rel to the i-th relocation twice.  At the
beginning using the loop counter.  At the end by incrementing.  One
approach is sufficient.

bfd/
	* elf-sframe.c (sframe_decoder_init_func_bfdinfo):

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
 bfd/elf-sframe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index 67ed874e0252..db166d485f9e 100644
--- a/bfd/elf-sframe.c
+++ b/bfd/elf-sframe.c
@@ -118,9 +118,9 @@ sframe_decoder_init_func_bfdinfo (bfd *abfd,
   if ((sec->flags & SEC_LINKER_CREATED) && cookie->rels == NULL)
     return true;
 
+  cookie->rel = cookie->rels;
   for (i = 0; i < fde_count; i++)
     {
-      cookie->rel = cookie->rels + i;
       BFD_ASSERT (cookie->rel < cookie->relend);
       /* Bookkeep the relocation offset and relocation index of each function
 	 for later use.  */
-- 
2.45.2



More information about the Binutils mailing list