public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Cc: Indu Bhagat <indu.bhagat@oracle.com>
Subject: [PATCH 03/12] libsframe: add new APIs to get SFrame version
Date: Tue, 27 Jun 2023 14:20:19 -0700	[thread overview]
Message-ID: <20230627212028.2138604-4-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20230627212028.2138604-1-indu.bhagat@oracle.com>

While the SFrame preamble is guaranteed to not change between versions,
providing these access APIs from the SFrame decoder and encoder APIs is
for convenience only.  The linker may want to use these APIs as the
format evolves.

include/
	* sframe-api.h (sframe_decoder_get_version): New declaration.
	(sframe_encoder_get_version): Likewise.

libsframe/
	* libsframe/libsframe.ver: Add new APIs.
	* libsframe/sframe.c (sframe_decoder_get_version): New
	definition.
	(sframe_encoder_get_version): Likewise.
---
 include/sframe-api.h    |  8 ++++++++
 libsframe/libsframe.ver |  2 ++
 libsframe/sframe.c      | 20 ++++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/include/sframe-api.h b/include/sframe-api.h
index 7594011a48f..7883b668e31 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -120,6 +120,10 @@ sframe_decoder_get_hdr_size (sframe_decoder_ctx *dctx);
 extern uint8_t
 sframe_decoder_get_abi_arch (sframe_decoder_ctx *dctx);
 
+/* Get the format version from the SFrame decoder context DCTX.  */
+extern uint8_t
+sframe_decoder_get_version (sframe_decoder_ctx *dctx);
+
 /* Return the number of function descriptor entries in the SFrame decoder
    DCTX.  */
 extern uint32_t
@@ -217,6 +221,10 @@ sframe_encoder_get_hdr_size (sframe_encoder_ctx *encoder);
 extern uint8_t
 sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder);
 
+/* Get the format version from the SFrame encoder context ENCODER.  */
+extern uint8_t
+sframe_encoder_get_version (sframe_encoder_ctx *encoder);
+
 /* Return the number of function descriptor entries in the SFrame encoder
    ENCODER.  */
 extern uint32_t
diff --git a/libsframe/libsframe.ver b/libsframe/libsframe.ver
index 2c2081f311a..3e2a5695e93 100644
--- a/libsframe/libsframe.ver
+++ b/libsframe/libsframe.ver
@@ -13,6 +13,7 @@ LIBSFRAME_1.0 {
     sframe_decode;
     sframe_decoder_get_hdr_size;
     sframe_decoder_get_abi_arch;
+    sframe_decoder_get_version;
     sframe_decoder_get_fixed_fp_offset;
     sframe_decoder_get_fixed_ra_offset;
     sframe_get_funcdesc_with_addr;
@@ -24,6 +25,7 @@ LIBSFRAME_1.0 {
     sframe_encoder_free;
     sframe_encoder_get_hdr_size;
     sframe_encoder_get_abi_arch;
+    sframe_encoder_get_version;
     sframe_encoder_get_num_fidx;
     sframe_encoder_add_fre;
     sframe_encoder_add_funcdesc;
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index fd966cfffd4..cb73a0ca87f 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -988,6 +988,16 @@ sframe_decoder_get_abi_arch (sframe_decoder_ctx *dctx)
   return sframe_header->sfh_abi_arch;
 }
 
+/* Get the format version from the SFrame decoder context DCTX.  */
+
+uint8_t
+sframe_decoder_get_version (sframe_decoder_ctx *dctx)
+{
+  sframe_header *dhp;
+  dhp = sframe_decoder_get_header (dctx);
+  return dhp->sfh_preamble.sfp_version;
+}
+
 /* Get the SFrame's fixed FP offset given the decoder context CTX.  */
 int8_t
 sframe_decoder_get_fixed_fp_offset (sframe_decoder_ctx *ctx)
@@ -1368,6 +1378,16 @@ sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder)
   return abi_arch;
 }
 
+/* Get the format version from the SFrame encoder context ENCODER.  */
+
+uint8_t
+sframe_encoder_get_version (sframe_encoder_ctx *encoder)
+{
+  sframe_header *ehp;
+  ehp = sframe_encoder_get_header (encoder);
+  return ehp->sfh_preamble.sfp_version;
+}
+
 /* Return the number of function descriptor entries in the SFrame encoder
    ENCODER.  */
 
-- 
2.39.2


  parent reply	other threads:[~2023-06-27 21:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 21:20 [PATCH 00/12] SFrame Version 2 - definition and support Indu Bhagat
2023-06-27 21:20 ` [PATCH 01/12] sframe.h: format bump to SFrame version 2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 02/12] gas: generate SFrame section with version SFRAME_VERSION_2 Indu Bhagat
2023-06-27 21:20 ` Indu Bhagat [this message]
2023-06-27 21:20 ` [PATCH 04/12] libsframe: add new APIs to add and get SFrame FDE in SFrame version 2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 05/12] libsframe: adjust version check in sframe_header_sanity_check_p Indu Bhagat
2023-06-27 21:20 ` [PATCH 06/12] libsframe: testsuite: fixes for SFRAME_VERSION_2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 07/12] bfd: linker: add support for rep_block_size for pltN entries Indu Bhagat
2023-06-27 21:20 ` [PATCH 08/12] bfd: linker: generate SFrame sections with version SFRAME_VERSION_2 Indu Bhagat
2023-06-27 21:20 ` [PATCH 09/12] objdump/readelf: adjust for SFRAME_VERSION_2 Indu Bhagat
2023-06-28 23:04   ` Hans-Peter Nilsson
2023-06-29  6:41     ` Indu Bhagat
2023-06-27 21:20 ` [PATCH 10/12] doc: sframe: update specification " Indu Bhagat
2023-06-27 21:20 ` [PATCH 11/12] doc: sframe: add details about alignment in the SFrame format Indu Bhagat
2023-06-27 21:20 ` [PATCH 12/12] binutils/NEWS: announce SFrame version 2 as the new default Indu Bhagat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230627212028.2138604-4-indu.bhagat@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).