[PATCH v3 2/3] libsframe: Support for FDEs without any FREs
Jens Remus
jremus@linux.ibm.com
Wed Jul 23 13:17:57 GMT 2025
SFrame FDEs without any FREs will be later used to represent RA
undefined in SFrame.
Allow SFrame sections without any FREs, that can occur if they solely
contain FDEs without any FREs. For FDEs without and FREs set the
offset to the first FRE to zero.
libsframe/
* sframe.c (sframe_encoder_write_sframe): Allow SFrame sections
without any FREs. For FDEs without any FREs set the FRE offset
to zero.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
Notes (jremus):
Changes in V3:
- New patch.
Instead of using a new API sframe_encoder_write_sframe could directly
access ehp->sfh_num_fres. Thoughts?
libsframe/sframe.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index d84f1c2d0d78..d98fffcf69ae 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -1894,7 +1894,7 @@ sframe_encoder_write_sframe (sframe_encoder_ctx *encoder)
- buffers must be malloc'd by the caller. */
if ((contents == NULL) || (buf_size < hdr_size))
return sframe_set_errno (&err, SFRAME_ERR_BUF_INVAL);
- if (fr_info == NULL)
+ if (sframe_encoder_get_num_fres (encoder) > 0 && fr_info == NULL)
return sframe_set_errno (&err, SFRAME_ERR_FRE_INVAL);
/* Write out the FRE table first.
@@ -1917,6 +1917,13 @@ sframe_encoder_write_sframe (sframe_encoder_ctx *encoder)
fre_type = sframe_get_fre_type (fdep);
num_fres = fdep->sfde_func_num_fres;
+ /* FDEs without any FDEs have a FRE offset of zero. */
+ if (num_fres == 0)
+ fdep->sfde_func_start_fre_off = 0;
+
+ if (num_fres > 0 && fr_info == NULL)
+ return sframe_set_errno (&err, SFRAME_ERR_FRE_INVAL);
+
for (j = 0; j < num_fres; j++)
{
fre_index = global + j;
--
2.48.1
More information about the Binutils
mailing list