]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
include: libsframe: add APIs for offsetof FDE func start addr field
authorIndu Bhagat <indu.bhagat@oracle.com>
Thu, 22 May 2025 22:24:47 +0000 (15:24 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 28 May 2025 04:58:13 +0000 (21:58 -0700)
These APIs will be later used by the linker to arrange SFrame FDEs in
the output SFrame section.

include/
        * sframe-api.h (sframe_decoder_get_offsetof_fde_start_addr): New
declaration.
        (sframe_encoder_get_offsetof_fde_start_addr): Likewise.

libsframe/
        * libsframe.ver: List the new APIs.
        * sframe.c (sframe_decoder_get_offsetof_fde_start_addr): New
definition.
        (sframe_encoder_get_offsetof_fde_start_addr): Likewise.

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

index a5f1a592151e0f5bac7341c6e31c6ae997112230..80d546a624df5bca0e44826a2fe31970f95bdfd9 100644 (file)
@@ -128,6 +128,12 @@ sframe_decoder_get_version (sframe_decoder_ctx *dctx);
 extern uint8_t
 sframe_decoder_get_flags (sframe_decoder_ctx *dctx);
 
+/* Get the offset of the SFrame FDE function start address field in the SFrame
+   decoder context DCTX.  */
+uint32_t
+sframe_decoder_get_offsetof_fde_start_addr (sframe_decoder_ctx *dctx,
+                                           uint32_t func_idx, int *errp);
+
 /* Return the number of function descriptor entries in the SFrame decoder
    DCTX.  */
 extern uint32_t
@@ -246,6 +252,12 @@ sframe_encoder_get_version (sframe_encoder_ctx *encoder);
 extern uint8_t
 sframe_encoder_get_flags (sframe_encoder_ctx *encoder);
 
+/* Get the offset of the SFrame FDE function start address field in the SFrame
+   encoder context ENCODER.  */
+uint32_t
+sframe_encoder_get_offsetof_fde_start_addr (sframe_encoder_ctx *encoder,
+                                           uint32_t func_idx, int *errp);
+
 /* Return the number of function descriptor entries in the SFrame encoder
    ENCODER.  */
 extern uint32_t
index 7038d6947041195c964b777a40350d31dd8bd152..06324eecfc562941a4f3ba79cd85177bf6eaa037 100644 (file)
@@ -41,5 +41,7 @@ LIBSFRAME_1.0 {
 
 LIBSFRAME_1.1 {
     sframe_decoder_get_flags;
+    sframe_decoder_get_offsetof_fde_start_addr;
     sframe_encoder_get_flags;
+    sframe_encoder_get_offsetof_fde_start_addr;
 } LIBSFRAME_1.0;
index e7df62741a6a5c2f2dc528d602cf7a24c1a48def..8e9990058b6b2b8f5036d2505ca5ad6c893a92ab 100644 (file)
@@ -1016,6 +1016,26 @@ sframe_decoder_get_fixed_ra_offset (sframe_decoder_ctx *ctx)
   return dhp->sfh_cfa_fixed_ra_offset;
 }
 
+/* Get the offset of the sfde_func_start_address field (from the start of the
+   on-disk layout of the SFrame section) of the FDE at FUNC_IDX in the decoder
+   context DCTX.
+
+   If FUNC_IDX is more than the number of SFrame FDEs in the section, sets
+   error code in ERRP, but returns the offset.  */
+
+uint32_t
+sframe_decoder_get_offsetof_fde_start_addr (sframe_decoder_ctx *dctx,
+                                           uint32_t func_idx, int *errp)
+{
+  if (func_idx >= sframe_decoder_get_num_fidx (dctx))
+    sframe_ret_set_errno (errp, SFRAME_ERR_FDE_NOTFOUND);
+  else if (errp)
+    *errp = 0;
+
+  return (sframe_decoder_get_hdr_size (dctx)
+         + func_idx * sizeof (sframe_func_desc_entry));
+}
+
 /* Find the function descriptor entry which contains the specified address
    ADDR.
    This function is deprecated and will be removed from libsframe.so.2.  */
@@ -1436,6 +1456,27 @@ sframe_encoder_get_num_fidx (sframe_encoder_ctx *encoder)
   return num_fdes;
 }
 
+/* Get the offset of the sfde_func_start_address field (from the start of the
+   on-disk layout of the SFrame section) of the FDE at FUNC_IDX in the encoder
+   context ENCODER.
+
+   If FUNC_IDX is more than the number of SFrame FDEs in the section, sets
+   error code in ERRP, but returns the offset.  This may be used by the linker
+   when arranging input FDEs into the output section to be emitted.  */
+
+uint32_t
+sframe_encoder_get_offsetof_fde_start_addr (sframe_encoder_ctx *encoder,
+                                           uint32_t func_idx, int *errp)
+{
+  if (func_idx >= sframe_encoder_get_num_fidx (encoder))
+    sframe_ret_set_errno (errp, SFRAME_ERR_FDE_INVAL);
+  else if (errp)
+    *errp = 0;
+
+  return (sframe_encoder_get_hdr_size (encoder)
+         + func_idx * sizeof (sframe_func_desc_entry));
+}
+
 /* Add an FRE to function at FUNC_IDX'th function descriptor entry in
    the encoder context.  */