[binutils-gdb] libsframe: use offsets to FDE and FRE sub-sections

Indu Bhagat ibhagat@sourceware.org
Sat Aug 23 19:12:37 GMT 2025


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

commit 0d90e0ce80bdc10408f15eb6d8380da46f33891d
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date:   Sat Aug 23 12:09:44 2025 -0700

    libsframe: use offsets to FDE and FRE sub-sections
    
    In SFrame format, the SFrame FDEs begin at an offset 'sfh_fdeoff' from
    the end of the SFrame header.  Similarly, the SFrame FREs begin at an
    offset 'sfh_freoff' from the end of the SFrame header.
    
    While the GNU assembler generates these subsections such that sfd_fdeoff
    is zero, the correct way to decode the SFrame section (conforming with
    the specification) is to use both sfh_fdeoff and sfh_freoff in
    sframe_decode.
    
    libsframe/
            * sframe.c (sframe_decode): Use offsets to SFrame FDE and FRE
            sub-sections as applicable.

Diff:
---
 libsframe/sframe.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 824d1fd7ed9..85500791f8a 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -969,12 +969,11 @@ sframe_decode (const char *sf_buf, size_t sf_size, int *errp)
       sframe_ret_set_errno (errp, SFRAME_ERR_NOMEM);
       goto decode_fail_free;
     }
-  memcpy (dctx->sfd_funcdesc, frame_buf, fidx_size);
+  /* SFrame FDEs are at an offset of sfh_fdeoff from SFrame header end.  */
+  memcpy (dctx->sfd_funcdesc, frame_buf + sfheaderp->sfh_fdeoff, fidx_size);
 
   debug_printf ("%u total fidx size\n", fidx_size);
 
-  frame_buf += (fidx_size);
-
   /* Handle the SFrame Frame Row Entry section.  */
   dctx->sfd_fres = (char *) malloc (sfheaderp->sfh_fre_len);
   if (dctx->sfd_fres == NULL)
@@ -982,7 +981,10 @@ sframe_decode (const char *sf_buf, size_t sf_size, int *errp)
       sframe_ret_set_errno (errp, SFRAME_ERR_NOMEM);
       goto decode_fail_free;
     }
-  memcpy (dctx->sfd_fres, frame_buf, sfheaderp->sfh_fre_len);
+  /* SFrame FREs are at an offset of sfh_freoff from SFrame header end.  */
+  memcpy (dctx->sfd_fres,
+	  frame_buf + sfheaderp->sfh_freoff,
+	  sfheaderp->sfh_fre_len);
 
   fre_bytes = sfheaderp->sfh_fre_len;
   dctx->sfd_fre_nbytes = fre_bytes;


More information about the Binutils-cvs mailing list