[binutils-gdb] libsframe: refactor sframe_decoder_add_funcdesc for internal use
Indu Bhagat
ibhagat@sourceware.org
Wed Dec 24 08:57:12 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ca80bc6dab4d297a2ee08a197c6480e1898add2
commit 7ca80bc6dab4d297a2ee08a197c6480e1898add2
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date: Wed Dec 24 00:51:43 2025 -0800
libsframe: refactor sframe_decoder_add_funcdesc for internal use
sframe_encoder_add_funcdesc () was added for SFRAME_VERSION_1. This has
since been obsoleted by introduction of SFRAME_VERSION_2 and its
corresponding sframe_decoder_add_funcdesc_v2 API.
Refactor the functionality into an internal-only API:
sframe_encoder_add_funcdesc_internal (). Ensure it returns the error
code for the caller to take necessary action or pass to user.
Keep only two args for sframe_encoder_add_funcdesc: function size and
function start addr. This simple barebone API will be used in a
subsequent commit to adjust the link-time behaviour of SFrame sections.
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
* sframe-api.h (sframe_encoder_add_funcdesc): Remove args to
create the barebone API.
libsframe/
* sframe.c (sframe_encoder_add_funcdesc): Refactor out into
sframe_encoder_add_funcdesc_internal. Change args.
(sframe_encoder_add_funcdesc_v2): Use the new internal API.
* libsframe.ver: Move sframe_encoder_add_funcdesc to 2.1 node.
Diff:
---
include/sframe-api.h | 8 +++-----
libsframe/libsframe.ver | 2 +-
libsframe/sframe.c | 50 +++++++++++++++++++++++++++++--------------------
3 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/include/sframe-api.h b/include/sframe-api.h
index 7e37e6af84d..fc46b855fa5 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -288,14 +288,12 @@ sframe_encoder_add_fre (sframe_encoder_ctx *ectx,
unsigned int func_idx,
sframe_frame_row_entry *frep);
-/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE and
- FUNC_INFO to the encoder context ECTX. */
+/* Add a new SFrame function descriptor entry with START_ADDR and FUNC_SIZE to
+ the encoder context ECTX. */
extern int
sframe_encoder_add_funcdesc (sframe_encoder_ctx *ectx,
int32_t start_addr,
- uint32_t func_size,
- unsigned char func_info,
- uint32_t num_fres);
+ uint32_t func_size);
/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE,
FUNC_INFO and REP_BLOCK_SIZE to the encoder context ECTX. This API is valid
diff --git a/libsframe/libsframe.ver b/libsframe/libsframe.ver
index fdd08a11ad9..18ab92839e1 100644
--- a/libsframe/libsframe.ver
+++ b/libsframe/libsframe.ver
@@ -32,7 +32,6 @@ LIBSFRAME_2.0 {
sframe_encoder_get_offsetof_fde_start_addr;
sframe_encoder_get_num_fidx;
sframe_encoder_add_fre;
- sframe_encoder_add_funcdesc;
sframe_encoder_add_funcdesc_v2;
dump_sframe;
sframe_errmsg;
@@ -44,5 +43,6 @@ LIBSFRAME_2.0 {
LIBSFRAME_2.1 {
global:
sframe_fre_get_ra_undefined_p;
+ sframe_encoder_add_funcdesc;
sframe_encoder_write;
} LIBSFRAME_2.0;
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index d85b53142c7..6e220055282 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -1777,24 +1777,19 @@ bad:
}
/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE and
- FUNC_INFO to the encoder context ECTX. */
+ FUNC_INFO to the encoder context ECTX. Caller must make sure that ECTX
+ exists. */
-int
-sframe_encoder_add_funcdesc (sframe_encoder_ctx *ectx,
- int32_t start_addr,
- uint32_t func_size,
- unsigned char func_info,
- uint32_t num_fres ATTRIBUTE_UNUSED)
+static int
+sframe_encoder_add_funcdesc_internal (sframe_encoder_ctx *ectx,
+ int32_t start_addr,
+ uint32_t func_size)
{
sframe_header *ehp;
sf_fde_tbl *fd_info;
size_t fd_tbl_sz;
int err = 0;
- /* FIXME book-keep num_fres for error checking. */
- if (ectx == NULL)
- return sframe_set_errno (&err, SFRAME_ERR_INVAL);
-
fd_info = ectx->sfe_funcdesc;
ehp = sframe_encoder_get_header (ectx);
@@ -1840,7 +1835,6 @@ sframe_encoder_add_funcdesc (sframe_encoder_ctx *ectx,
fd_info->entry[fd_info->count].sfde_func_info
= sframe_fde_func_info (fre_type);
#endif
- fd_info->entry[fd_info->count].func_info = func_info;
fd_info->count++;
ectx->sfe_funcdesc = fd_info;
ehp->sfh_num_fdes++;
@@ -1851,7 +1845,25 @@ bad:
free (fd_info);
ectx->sfe_funcdesc = NULL;
ehp->sfh_num_fdes = 0;
- return -1;
+ return err;
+}
+
+/* Add a new SFrame function descriptor entry with START_PC_OFFSET and
+ FUNC_SIZE to the encoder context ECTX. */
+
+int
+sframe_encoder_add_funcdesc (sframe_encoder_ctx *ectx, int32_t start_pc_offset,
+ uint32_t func_size)
+{
+ int err = 0;
+ if (ectx == NULL || sframe_encoder_get_version (ectx) == SFRAME_VERSION_1)
+ return sframe_set_errno (&err, SFRAME_ERR_INVAL);
+
+ err = sframe_encoder_add_funcdesc_internal (ectx, start_pc_offset, func_size);
+ if (err)
+ return err;
+
+ return 0;
}
/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE,
@@ -1866,18 +1878,16 @@ sframe_encoder_add_funcdesc_v2 (sframe_encoder_ctx *ectx,
uint8_t rep_block_size,
uint32_t num_fres ATTRIBUTE_UNUSED)
{
- sf_fde_tbl *fd_info;
- int err;
-
+ int err = 0;
if (ectx == NULL || sframe_encoder_get_version (ectx) == SFRAME_VERSION_1)
return sframe_set_errno (&err, SFRAME_ERR_INVAL);
- err = sframe_encoder_add_funcdesc (ectx, start_addr, func_size, func_info,
- num_fres);
+ err = sframe_encoder_add_funcdesc_internal (ectx, start_addr, func_size);
if (err)
- return SFRAME_ERR;
+ return err;
- fd_info = ectx->sfe_funcdesc;
+ sf_fde_tbl *fd_info = ectx->sfe_funcdesc;
+ fd_info->entry[fd_info->count-1].func_info = func_info;
fd_info->entry[fd_info->count-1].func_rep_size = rep_block_size;
return 0;
More information about the Binutils-cvs
mailing list