]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[SFrame-V3] libsframe: add V3 APIs for adding and getting SFrame FDE
authorIndu Bhagat <indu.bhagat@oracle.com>
Wed, 13 Aug 2025 00:13:15 +0000 (17:13 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Tue, 9 Dec 2025 08:26:13 +0000 (00:26 -0800)
(Similar to V2) Add two new APIs for adding and getting SFrame FDE:
 - sframe_encoder_add_funcdesc_v3
 - sframe_decoder_get_funcdesc_v3

Note the argument for the function start address is int64_t instead of
int32_t (the latter is used in sframe_encoder_add_funcdesc_v2 and
sframe_encoder_get_funcdesc_v2).  The new V3 APIs will be used in a
subsequent commit to extend SFrame V3 to support text > 2 GiB by
allowing int64_t offsets by default.

Similar to the analogous V2 APIs, they return 0 on success and
SFRAME_ERR on failure.

include/
        * sframe-api.h (sframe_decoder_get_funcdesc_v3): New
declaration.
        (sframe_encoder_add_funcdesc_v3): Likewise.
libsframe/
* libsframe.ver: Add the new APIs.
        * sframe.c (sframe_decoder_get_funcdesc_v3): New definition.
        (sframe_encoder_add_funcdesc_v3): Likewise.

include/sframe-api.h
libsframe/libsframe.ver
libsframe/sframe.c

index 3521c188ec0efca82f2b59479c99bb2fd35b99c2..a4ba797794f7944ba712d17a553c14c6382affa7 100644 (file)
@@ -182,6 +182,18 @@ sframe_decoder_get_funcdesc_v2 (const sframe_decoder_ctx *ctx,
                                unsigned char *func_info,
                                uint8_t *rep_block_size);
 
+/* Get the data (NUM_FRES, FUNC_SIZE, FUNC_START_ADDRESS, FUNC_INFO,
+   REP_BLOCK_SIZE) from the SFrame function descriptor entry at the I'th index
+   in the decoder object DCTX.  If failed, return SFRAME_ERR.  */
+extern int
+sframe_decoder_get_funcdesc_v3 (const sframe_decoder_ctx *dctx,
+                               unsigned int i,
+                               uint32_t *num_fres,
+                               uint32_t *func_size,
+                               int64_t *func_start_address,
+                               unsigned char *func_info,
+                               uint8_t *rep_block_size);
+
 /* SFrame textual dump.  */
 extern void
 dump_sframe (const sframe_decoder_ctx *decoder, uint64_t addr);
@@ -295,7 +307,17 @@ sframe_encoder_add_funcdesc_v2 (sframe_encoder_ctx *ectx,
                                uint8_t rep_block_size,
                                uint32_t num_fres);
 
-/* Serialize the contents of the encoder context ECTX and return the buffer.
+/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE,
+   FUNC_INFO and REP_BLOCK_SIZE to the encoder context ECTX.  */
+extern int
+sframe_encoder_add_funcdesc_v3 (sframe_encoder_ctx *ectx,
+                               int64_t start_addr,
+                               uint32_t func_size,
+                               unsigned char func_info,
+                               uint8_t rep_block_size,
+                               uint32_t num_fres);
+
+/* Serialize the contents of the encoder object ECTX and return the buffer.
    ENCODED_SIZE is updated to the size of the buffer.
    Sets ERRP if failure.  */
 extern char  *
index 4086a397c891122eedff257947d46f5b9c30487e..990274974861116cf8395ce0ade99e0cb7d9d1d9 100644 (file)
@@ -22,6 +22,7 @@ LIBSFRAME_3.0 {
     sframe_find_fre;
     sframe_decoder_get_num_fidx;
     sframe_decoder_get_funcdesc_v2;
+    sframe_decoder_get_funcdesc_v3;
     sframe_decoder_get_fre;
     sframe_encode;
     sframe_encoder_free;
@@ -34,6 +35,7 @@ LIBSFRAME_3.0 {
     sframe_encoder_add_fre;
     sframe_encoder_add_funcdesc;
     sframe_encoder_add_funcdesc_v2;
+    sframe_encoder_add_funcdesc_v3;
     sframe_encoder_write;
     dump_sframe;
     sframe_errmsg;
index 44b04d090c809bce161b8c9f073c05147272e0a8..afa8923b733b478840b10328406a841c8f656928 100644 (file)
@@ -1521,6 +1521,43 @@ sframe_decoder_get_funcdesc_v2 (const sframe_decoder_ctx *dctx,
 
   return 0;
 }
+
+/* Get the data (NUM_FRES, FUNC_SIZE, FUNC_START_ADDRESS, FUNC_INFO,
+   REP_BLOCK_SIZE) from the SFrame function descriptor entry at the I'th index
+   in the decoder object DCTX.  If failed, return SFRAME_ERR.  */
+
+int
+sframe_decoder_get_funcdesc_v3 (const sframe_decoder_ctx *dctx,
+                               unsigned int i,
+                               uint32_t *num_fres,
+                               uint32_t *func_size,
+                               int64_t *func_start_address,
+                               unsigned char *func_info,
+                               uint8_t *rep_block_size)
+{
+  int err = 0;
+  if (dctx == NULL || sframe_decoder_get_version (dctx) != SFRAME_VERSION_3)
+    return sframe_set_errno (&err, SFRAME_ERR_INVAL);
+
+  sframe_func_desc_entry_int *fdp
+    = sframe_decoder_get_funcdesc_at_index (dctx, i);
+  if (fdp == NULL)
+    return sframe_set_errno (&err, SFRAME_ERR_FDE_NOTFOUND);
+
+  if (num_fres)
+    *num_fres = fdp->func_num_fres;
+  if (func_start_address)
+    *func_start_address = fdp->func_start_addr;
+  if (func_size)
+    *func_size = fdp->func_size;
+  if (func_info)
+    *func_info = fdp->func_info;
+  if (rep_block_size)
+    *rep_block_size = fdp->func_rep_size;
+
+  return 0;
+}
+
 /* Get the FRE_IDX'th FRE of the function at FUNC_IDX'th function
    descriptor entry in the SFrame decoder CTX.  Returns error code as
    applicable.  */
@@ -1946,6 +1983,32 @@ sframe_encoder_add_funcdesc_v2 (sframe_encoder_ctx *ectx,
   return 0;
 }
 
+/* Add a new SFrame function descriptor entry with START_ADDR, FUNC_SIZE,
+   FUNC_INFO and REP_BLOCK_SIZE to the encoder context ECTX.  */
+
+int
+sframe_encoder_add_funcdesc_v3 (sframe_encoder_ctx *ectx,
+                               int64_t start_addr,
+                               uint32_t func_size,
+                               unsigned char func_info,
+                               uint8_t rep_block_size,
+                               uint32_t num_fres ATTRIBUTE_UNUSED)
+{
+  int err = 0;
+  if (ectx == NULL || sframe_encoder_get_version (ectx) != SFRAME_VERSION_3)
+    return sframe_set_errno (&err, SFRAME_ERR_INVAL);
+
+  err = sframe_encoder_add_funcdesc_internal (ectx, start_addr, func_size);
+  if (err)
+    return err;
+
+  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;
+}
+
 static int
 sframe_sort_funcdesc (sframe_encoder_ctx *ectx)
 {