]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd: ld: sframe: skip R_*_NONE relocations from input bfds
authorIndu Bhagat <indu.bhagat@oracle.com>
Fri, 12 Dec 2025 15:02:32 +0000 (17:02 +0200)
committerClaudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
Fri, 12 Dec 2025 15:14:23 +0000 (17:14 +0200)
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.

bfd/elf-sframe.c

index 8e4cfdd73d3df69a980a32eff2df7043ab7124aa..80043550777ff7c7c872f87cf04ccedbfc72492b 100644 (file)
@@ -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++;
     }