[binutils-gdb] bfd: ld: sframe: skip R_*_NONE relocations from input bfds

Claudiu Zissulescu claziss@sourceware.org
Fri Dec 12 15:19:33 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=db5b3831be576aee7df6f32a3fdc64bd7667686e

commit db5b3831be576aee7df6f32a3fdc64bd7667686e
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date:   Fri Dec 12 17:02:32 2025 +0200

    bfd: ld: sframe: skip R_*_NONE relocations from input bfds
    
    Fix PR ld/33401 - SFrame assertion when linking gav-0.9.1
    
    As the issue demonstrates, R_*_NONE relocations are not necessarily
    at the end of .sframe section (previously thought so with PR ld/33127).
    Skip over R_*_NONE relocs when they are strewn intermittently inside the
    .rela.sframe section.
    
    bfd/
            PR ld/33401
            * elf-sframe.c (sframe_decoder_init_func_bfdinfo):  Skip over
            R_*_NONE relocations.

Diff:
---
 bfd/elf-sframe.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index 8e4cfdd73d3..80043550777 100644
--- a/bfd/elf-sframe.c
+++ b/bfd/elf-sframe.c
@@ -121,13 +121,24 @@ sframe_decoder_init_func_bfdinfo (bfd *abfd,
     return true;
 
   rel = cookie->rels;
+  unsigned int reloc_index = 0;
   for (i = 0; i < fde_count; i++)
     {
       /* Bookkeep the relocation offset and relocation index of each function
-	 for later use.  */
+	 for later use.  There may be some R_*_NONE relocations intermingled
+	 (see PR ld/33401).  Skip over those.  */
+      while (rel->r_info == 0)
+	{
+	  reloc_index++;
+	  rel++;
+	}
+
+      BFD_ASSERT (reloc_index < sec->reloc_count);
+
       sframe_decoder_set_func_r_offset (sfd_info, i, rel->r_offset);
-      sframe_decoder_set_func_reloc_index (sfd_info, i, i);
+      sframe_decoder_set_func_reloc_index (sfd_info, i, reloc_index);
 
+      reloc_index++;
       rel++;
     }


More information about the Binutils-cvs mailing list