public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] libsframe: add library versioning
@ 2023-06-27 19:51 Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: remove sframe_get_funcdesc_with_addr API Indu Bhagat
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

lisbframe was first released with Bintuils 2.40.  As the library
evolves, some changes will break the ABI.  Add library versioning for
users to manage these changes.

For the next release of the library (libsframe.so.1), incompatible ABI
changes are planned. These will include:
 - Deprecation of some APIs, like sframe_get_funcdesc_with_addr (), and
 - Change in the contract of some APIs (e.g., return type, behavior).

In libtool-version, set the current to 1 to prepare for the upcoming
release.  Reset revision and age to 0.

Add libtool-version file to EXTRA_DIST.

libsframe/
	* Makefile.am: Use libtool versioning.
	* Makefile.in: Regenerated.
	* libtool-version: New file.
---
 libsframe/Makefile.am     |  5 +++++
 libsframe/Makefile.in     |  9 ++++++++-
 libsframe/libtool-version | 30 ++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 libsframe/libtool-version

diff --git a/libsframe/Makefile.am b/libsframe/Makefile.am
index 2d736624208..2d1d8fff063 100644
--- a/libsframe/Makefile.am
+++ b/libsframe/Makefile.am
@@ -29,6 +29,7 @@ INCDIR = $(srcdir)/../include
 # include libctf for swap.h
 AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../libctf
 AM_CFLAGS = @ac_libsframe_warn_cflags@
+libsframe_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
 
 if INSTALL_LIBBFD
 lib_LTLIBRARIES = libsframe.la
@@ -40,6 +41,10 @@ endif
 
 libsframe_la_SOURCES = sframe.c sframe-dump.c sframe-error.c
 libsframe_la_CPPFLAGS = $(AM_CPPFLAGS)
+libsframe_la_LDFLAGS = $(libsframe_version_info)
+
+EXTRA_DIST = libtool-version
+diststuff: $(EXTRA_DIST) info
 
 include doc/local.mk
 
diff --git a/libsframe/Makefile.in b/libsframe/Makefile.in
index c6a4cd56a9e..57f912caa13 100644
--- a/libsframe/Makefile.in
+++ b/libsframe/Makefile.in
@@ -180,6 +180,9 @@ AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
+libsframe_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(libsframe_la_LDFLAGS) $(LDFLAGS) -o $@
 @INSTALL_LIBBFD_FALSE@am_libsframe_la_rpath =
 @INSTALL_LIBBFD_TRUE@am_libsframe_la_rpath = -rpath $(libdir)
 @HAVE_COMPAT_DEJAGNU_TRUE@am__EXEEXT_1 = testsuite/libsframe.decode/be-flipping$(EXEEXT) \
@@ -519,12 +522,15 @@ INCDIR = $(srcdir)/../include
 # include libctf for swap.h
 AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../libctf
 AM_CFLAGS = @ac_libsframe_warn_cflags@
+libsframe_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
 @INSTALL_LIBBFD_TRUE@lib_LTLIBRARIES = libsframe.la
 @INSTALL_LIBBFD_FALSE@include_HEADERS = 
 @INSTALL_LIBBFD_TRUE@include_HEADERS = $(INCDIR)/sframe.h $(INCDIR)/sframe-api.h
 @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libsframe.la
 libsframe_la_SOURCES = sframe.c sframe-dump.c sframe-error.c
 libsframe_la_CPPFLAGS = $(AM_CPPFLAGS)
+libsframe_la_LDFLAGS = $(libsframe_version_info)
+EXTRA_DIST = libtool-version
 @BUILD_INFO_TRUE@AM_MAKEINFOFLAGS = --no-split
 
 # Setup the testing framework
@@ -654,7 +660,7 @@ clean-noinstLTLIBRARIES:
 	}
 
 libsframe.la: $(libsframe_la_OBJECTS) $(libsframe_la_DEPENDENCIES) $(EXTRA_libsframe_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(LINK) $(am_libsframe_la_rpath) $(libsframe_la_OBJECTS) $(libsframe_la_LIBADD) $(LIBS)
+	$(AM_V_CCLD)$(libsframe_la_LINK) $(am_libsframe_la_rpath) $(libsframe_la_OBJECTS) $(libsframe_la_LIBADD) $(LIBS)
 
 clean-checkPROGRAMS:
 	@list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
@@ -1568,6 +1574,7 @@ uninstall-am: uninstall-dvi-am uninstall-html-am \
 
 .PRECIOUS: Makefile
 
+diststuff: $(EXTRA_DIST) info
 
 @BUILD_INFO_TRUE@html-local: doc/sframe-spec/index.html
 @BUILD_INFO_TRUE@doc/sframe-spec/index.html: doc/sframe-spec.texi doc/$(am__dirstamp)
diff --git a/libsframe/libtool-version b/libsframe/libtool-version
new file mode 100644
index 00000000000..9dcbe48e47d
--- /dev/null
+++ b/libsframe/libtool-version
@@ -0,0 +1,30 @@
+# This file is used to maintain libtool version info for libsframe.  See
+# the libtool manual to understand the meaning of the fields.  This is
+# a separate file so that version updates don't involve re-running
+# automake.
+#
+# Here are a set of rules to help you update your library version
+# information:
+#
+# 1. Start with version information of `0:0:0' for each libtool library.
+#
+# 2. Update the version information only immediately before a public
+#    release of your software. More frequent updates are unnecessary,
+#    and only guarantee that the current interface number gets larger
+#    faster.
+#
+# 3. If the library source code has changed at all since the last
+#    update, then increment revision (`c:r:a' becomes `c:r+1:a').
+#
+# 4. If any interfaces have been added, removed, or changed since the
+#    last update, increment current, and set revision to 0.
+#
+# 5. Increase the age value only if the changes made to the ABI are backward
+#    compatible.
+#    a. If any interfaces have been added since the last public release,
+#       then increment age.
+#    b. If any interfaces have been removed since the last public release,
+#       then set age to 0.
+#
+# CURRENT:REVISION:AGE
+1:0:0
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: remove sframe_get_funcdesc_with_addr API
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: add symbol versioning Indu Bhagat
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

This is an incompatible ABI change in libsframe.

The interface provided by this function is not a healthy abstraction to
expose: the return type sframe_func_desc_entry, which is defined in
include/sframe.h (the SFrame binary format definition).  This ties up
the library in a undesirable way.  Most importantly, this function
should technically not be directly necessary for a stack tracer.  A
stack tracer will likely only need to do a sframe_find_fre ().

Rename the API to continue to use the functionality internally in the
library.  bfd/linker does not use this function.

Change the return type of the previous definition and make a note about
its planned deprecation.

include/
	* sframe-api.h:  Change return type of sframe_get_funcdesc_with_addr.
	Add comment for intention to deprecate.
libsframe/
	*sframe.c (sframe_get_funcdesc_with_addr): Change return type
	and set error code. This API is deprecated.
        (sframe_get_funcdesc_with_addr_internal): New definition for
	internal use.
	(sframe_find_fre): Use sframe_get_funcdesc_with_addr_internal
	instead.
---
 include/sframe-api.h | 11 +++++++----
 libsframe/sframe.c   | 20 ++++++++++++++++----
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/include/sframe-api.h b/include/sframe-api.h
index df1f5ccef4c..a00303a3598 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -133,10 +133,13 @@ sframe_decoder_get_fixed_fp_offset (sframe_decoder_ctx *dctx);
 extern int8_t
 sframe_decoder_get_fixed_ra_offset (sframe_decoder_ctx *dctx);
 
-/* Find the function descriptor entry which contains the specified address.  */
-extern sframe_func_desc_entry *
-sframe_get_funcdesc_with_addr (sframe_decoder_ctx *dctx,
-			       int32_t addr, int *errp);
+/* Find the function descriptor entry which contains the specified address.
+
+   Note: This function is deprecated and will be removed from future release
+   X+2 of the library.  */
+extern void *
+sframe_get_funcdesc_with_addr (sframe_decoder_ctx *dctx, int32_t addr,
+			       int *errp);
 
 /* Find the SFrame Frame Row Entry which contains the PC.  Returns
    SFRAME_ERR if failure.  */
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 7308a45ce88..8837f878fb0 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -950,12 +950,24 @@ sframe_decoder_get_fixed_ra_offset (sframe_decoder_ctx *ctx)
   return dhp->sfh_cfa_fixed_ra_offset;
 }
 
+/* Find the function descriptor entry which contains the specified address
+   ADDR.
+   This function is deprecated and will be removed from libsframe.so.2.  */
+
+void *
+sframe_get_funcdesc_with_addr (sframe_decoder_ctx *ctx __attribute__ ((unused)),
+			       int32_t addr __attribute__ ((unused)),
+			       int *errp)
+{
+  return sframe_ret_set_errno (errp, SFRAME_ERR_INVAL);
+}
+
 /* Find the function descriptor entry starting which contains the specified
    address ADDR.  */
 
-sframe_func_desc_entry *
-sframe_get_funcdesc_with_addr (sframe_decoder_ctx *ctx,
-			       int32_t addr, int *errp)
+static sframe_func_desc_entry *
+sframe_get_funcdesc_with_addr_internal (sframe_decoder_ctx *ctx, int32_t addr,
+					int *errp)
 {
   sframe_header *dhp;
   sframe_func_desc_entry *fdp;
@@ -1053,7 +1065,7 @@ sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
     return sframe_set_errno (&err, SFRAME_ERR_INVAL);
 
   /* Find the FDE which contains the PC, then scan its fre entries.  */
-  fdep = sframe_get_funcdesc_with_addr (ctx, pc, &err);
+  fdep = sframe_get_funcdesc_with_addr_internal (ctx, pc, &err);
   if (fdep == NULL || ctx->sfd_fres == NULL)
     return sframe_set_errno (&err, SFRAME_ERR_DCTX_INVAL);
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: add symbol versioning
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: remove sframe_get_funcdesc_with_addr API Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: update the semantics of sframe_fre_get_ra_offset Indu Bhagat
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Define an empty base version LIBSFRAME_0.0 and add all symbols to
version LIBSFRAME_1.0.

The previous release of libsframe (libsframe.so.0) did not have
versioned symbols.  Adding a libsframe.ver file so that future releases
of the library (and its consumers) can manage the changes better.

For Solaris ld, use -M mapfile command line option.  libsframe does not
restrict the set of exported symbols, so at this time there is no need
to fall back on the libtool's -export-symbols option for platforms where
some other linker (with a different command line option for symbol
versioning) may be used.

libsframe/
	* Makefile.am: Use symbol versioning for libsframe.
	* Makefile.in: Regenerated.
	* configure: Check for Solaris ld.
	* configure.ac: Regenerated.
	* libsframe.ver: New file.
---
 libsframe/Makefile.am   | 14 +++++++--
 libsframe/Makefile.in   |  9 ++++--
 libsframe/configure     | 63 +++++++++++++++++++++++++++++++++++++++--
 libsframe/configure.ac  | 28 ++++++++++++++++++
 libsframe/libsframe.ver | 36 +++++++++++++++++++++++
 5 files changed, 144 insertions(+), 6 deletions(-)
 create mode 100644 libsframe/libsframe.ver

diff --git a/libsframe/Makefile.am b/libsframe/Makefile.am
index 2d1d8fff063..a660e85c2ce 100644
--- a/libsframe/Makefile.am
+++ b/libsframe/Makefile.am
@@ -30,6 +30,16 @@ INCDIR = $(srcdir)/../include
 AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../libctf
 AM_CFLAGS = @ac_libsframe_warn_cflags@
 libsframe_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+# libsframe does not restrict the set of exported symbols.  So, if linker does
+# not support symbol versioning, there is no need to fall back on libtool's
+# -export-symbols option.
+if HAVE_LD_VERSION_SCRIPT
+if HAVE_SOLARIS_LD
+  libsframe_version_script = -Wl,-M -Wl,$(srcdir)/libsframe.ver
+else
+  libsframe_version_script = -Wl,--version-script=$(srcdir)/libsframe.ver
+endif
+endif
 
 if INSTALL_LIBBFD
 lib_LTLIBRARIES = libsframe.la
@@ -41,9 +51,9 @@ endif
 
 libsframe_la_SOURCES = sframe.c sframe-dump.c sframe-error.c
 libsframe_la_CPPFLAGS = $(AM_CPPFLAGS)
-libsframe_la_LDFLAGS = $(libsframe_version_info)
+libsframe_la_LDFLAGS = $(libsframe_version_info) $(libsframe_version_script)
 
-EXTRA_DIST = libtool-version
+EXTRA_DIST = libtool-version libsframe.ver
 diststuff: $(EXTRA_DIST) info
 
 include doc/local.mk
diff --git a/libsframe/Makefile.in b/libsframe/Makefile.in
index 57f912caa13..08c780caa4a 100644
--- a/libsframe/Makefile.in
+++ b/libsframe/Makefile.in
@@ -523,14 +523,19 @@ INCDIR = $(srcdir)/../include
 AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../libctf
 AM_CFLAGS = @ac_libsframe_warn_cflags@
 libsframe_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version`
+@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_FALSE@libsframe_version_script = -Wl,--version-script=$(srcdir)/libsframe.ver
+# libsframe does not restrict the set of exported symbols.  So, if linker does
+# not support symbol versioning, there is no need to fall back on libtool's
+# -export-symbols option.
+@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_TRUE@libsframe_version_script = -Wl,-M -Wl,$(srcdir)/libsframe.ver
 @INSTALL_LIBBFD_TRUE@lib_LTLIBRARIES = libsframe.la
 @INSTALL_LIBBFD_FALSE@include_HEADERS = 
 @INSTALL_LIBBFD_TRUE@include_HEADERS = $(INCDIR)/sframe.h $(INCDIR)/sframe-api.h
 @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libsframe.la
 libsframe_la_SOURCES = sframe.c sframe-dump.c sframe-error.c
 libsframe_la_CPPFLAGS = $(AM_CPPFLAGS)
-libsframe_la_LDFLAGS = $(libsframe_version_info)
-EXTRA_DIST = libtool-version
+libsframe_la_LDFLAGS = $(libsframe_version_info) $(libsframe_version_script)
+EXTRA_DIST = libtool-version libsframe.ver
 @BUILD_INFO_TRUE@AM_MAKEINFOFLAGS = --no-split
 
 # Setup the testing framework
diff --git a/libsframe/configure b/libsframe/configure
index bf4dc45b431..f7ad9c5e29a 100755
--- a/libsframe/configure
+++ b/libsframe/configure
@@ -643,6 +643,10 @@ INSTALL_LIBBFD_TRUE
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
+HAVE_LD_VERSION_SCRIPT_FALSE
+HAVE_LD_VERSION_SCRIPT_TRUE
+HAVE_SOLARIS_LD_FALSE
+HAVE_SOLARIS_LD_TRUE
 BUILD_INFO_FALSE
 BUILD_INFO_TRUE
 COMPAT_DEJAGNU
@@ -11482,7 +11486,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11485 "configure"
+#line 11489 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11588,7 +11592,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11591 "configure"
+#line 11595 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12335,6 +12339,53 @@ else
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if using Solaris linker" >&5
+$as_echo_n "checking if using Solaris linker... " >&6; }
+SLD=`$LD --version 2>&1 | grep Solaris`
+if test "$SLD"; then
+  have_solaris_ld=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  have_solaris_ld=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+ if test "$have_solaris_ld" = "yes"; then
+  HAVE_SOLARIS_LD_TRUE=
+  HAVE_SOLARIS_LD_FALSE='#'
+else
+  HAVE_SOLARIS_LD_TRUE='#'
+  HAVE_SOLARIS_LD_FALSE=
+fi
+
+
+if test "$have_solaris_ld" = "yes"; then
+  GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
+else
+  GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
+fi
+
+if test "$GLD"; then
+  have_ld_version_script=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  have_ld_version_script=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Versioned symbols not enabled." >&5
+$as_echo "$as_me: WARNING: *** Versioned symbols not enabled." >&2;}
+fi
+ if test "$have_ld_version_script" = "yes"; then
+  HAVE_LD_VERSION_SCRIPT_TRUE=
+  HAVE_LD_VERSION_SCRIPT_FALSE='#'
+else
+  HAVE_LD_VERSION_SCRIPT_TRUE='#'
+  HAVE_LD_VERSION_SCRIPT_FALSE=
+fi
+
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
@@ -12810,6 +12861,14 @@ if test -z "${BUILD_INFO_TRUE}" && test -z "${BUILD_INFO_FALSE}"; then
   as_fn_error $? "conditional \"BUILD_INFO\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_SOLARIS_LD_TRUE}" && test -z "${HAVE_SOLARIS_LD_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_SOLARIS_LD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
   as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
diff --git a/libsframe/configure.ac b/libsframe/configure.ac
index b9ea363d00d..8189e966e1c 100644
--- a/libsframe/configure.ac
+++ b/libsframe/configure.ac
@@ -81,6 +81,34 @@ else
 fi
 AM_CONDITIONAL(BUILD_INFO, test "${build_info}" = yes)
 
+dnl Determine if using Solaris linker
+AC_MSG_CHECKING([if using Solaris linker])
+SLD=`$LD --version 2>&1 | grep Solaris`
+if test "$SLD"; then
+  have_solaris_ld=yes
+  AC_MSG_RESULT(yes)
+else
+  have_solaris_ld=no
+  AC_MSG_RESULT(no)
+fi
+AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
+
+if test "$have_solaris_ld" = "yes"; then
+  GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
+else
+  GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
+fi
+
+if test "$GLD"; then
+  have_ld_version_script=yes
+  AC_MSG_RESULT(yes)
+else
+  have_ld_version_script=no
+  AC_MSG_RESULT(no)
+  AC_MSG_WARN(*** Versioned symbols not enabled.)
+fi
+AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
+
 AM_MAINTAINER_MODE
 AM_INSTALL_LIBBFD
 
diff --git a/libsframe/libsframe.ver b/libsframe/libsframe.ver
new file mode 100644
index 00000000000..2c2081f311a
--- /dev/null
+++ b/libsframe/libsframe.ver
@@ -0,0 +1,36 @@
+LIBSFRAME_0.0 { };
+
+LIBSFRAME_1.0 {
+  global:
+    sframe_decoder_free;
+    sframe_fde_create_func_info;
+    sframe_calc_fre_type;
+    sframe_fre_get_base_reg_id;
+    sframe_fre_get_cfa_offset;
+    sframe_fre_get_fp_offset;
+    sframe_fre_get_ra_offset;
+    sframe_fre_get_ra_mangled_p;
+    sframe_decode;
+    sframe_decoder_get_hdr_size;
+    sframe_decoder_get_abi_arch;
+    sframe_decoder_get_fixed_fp_offset;
+    sframe_decoder_get_fixed_ra_offset;
+    sframe_get_funcdesc_with_addr;
+    sframe_find_fre;
+    sframe_decoder_get_num_fidx;
+    sframe_decoder_get_funcdesc;
+    sframe_decoder_get_fre;
+    sframe_encode;
+    sframe_encoder_free;
+    sframe_encoder_get_hdr_size;
+    sframe_encoder_get_abi_arch;
+    sframe_encoder_get_num_fidx;
+    sframe_encoder_add_fre;
+    sframe_encoder_add_funcdesc;
+    sframe_encoder_write;
+    dump_sframe;
+    sframe_errmsg;
+
+  local:
+    *;
+} LIBSFRAME_0.0;
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: update the semantics of sframe_fre_get_ra_offset
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: remove sframe_get_funcdesc_with_addr API Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: add symbol versioning Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: update the semantics of sframe_fre_get_fp_offset Indu Bhagat
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Until now, sframe_fre_get_ra_offset () would return
SFRAME_ERR_FREOFFSET_NOPRESENT if the ABI uses fixed RA offset (e.g.,
AMD64).  A stack tracer, then, will call an explicit
sframe_decoder_get_fixed_ra_offset () to get the RA offset.

On second look, it appears to make sense to hide these details of
whether the RA offset is fixed or not from the consumer.  Now, with the
changed semantics, the call to sframe_fre_get_ra_offset () will fetch
the fixed RA offset if applicable, or get the RA offset from FRE when
there is no fixed RA offset.

Adjustments need to be made to ensure the textual dump remains the same
as preivous.  Currently, e.g., if RA is not being tracked per FRE,
following is seen with objdump --sframe:

    STARTPC         CFA       FP        RA
    000000000000NNNN  sp+X      u         u

This patch changes the behavior of sframe_fre_get_ra_offset: it turns an
error into non-error.  This change will be included with the next
release of libsframe, where all exposed symbols will be versioned for
the first time.

libsframe/
	* sframe.c (sframe_fre_get_ra_offset): Return the fixed offset,
	if applicable.  Else return the RA offset from the FRE.
	* sframe-dump.c (dump_sframe_func_with_fres): Make adjustments
	to keep the textual dump same as previous.
---
 libsframe/sframe-dump.c | 12 ++++++++----
 libsframe/sframe.c      | 14 +++++++++-----
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 6d266392cd7..2491b4391f3 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -164,11 +164,15 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx,
 	strcpy (temp, "u");
       printf ("%-10s", temp);
 
-      /* Dump RA info.  */
-      if (err[2] == 0)
-	sprintf (temp, "c%+d", ra_offset);
-      else
+      /* Dump RA info.
+	 If an ABI does not track RA offset, e.g., AMD64, display a 'u',
+	 else display the offset d as 'c+-d'.  */
+      if (sframe_decoder_get_fixed_ra_offset(sfd_ctx)
+	  != SFRAME_CFA_FIXED_RA_INVALID)
 	strcpy (temp, "u");
+      else if (err[2] == 0)
+	sprintf (temp, "c%+d", ra_offset);
+
       /* Mark SFrame FRE's RA information with "[s]" if the RA is mangled
 	 with signature bits.  */
       const char *ra_mangled_p_str
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 8837f878fb0..3d1b5575f0b 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -665,11 +665,15 @@ int32_t
 sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx,
 			  sframe_frame_row_entry *fre, int *errp)
 {
-  sframe_header *dhp = sframe_decoder_get_header (dctx);
-  /* If the RA offset was not being tracked, return an error code so the caller
-     can gather the fixed RA offset from the SFrame header.  */
-  if (dhp->sfh_cfa_fixed_ra_offset != SFRAME_CFA_FIXED_RA_INVALID)
-    return sframe_set_errno (errp, SFRAME_ERR_FREOFFSET_NOPRESENT);
+  int8_t ra_offset = sframe_decoder_get_fixed_ra_offset (dctx);
+  /* If the RA offset was not being tracked, return the fixed RA offset
+     from the SFrame header.  */
+  if (ra_offset != SFRAME_CFA_FIXED_RA_INVALID)
+    {
+      if (errp)
+	*errp = 0;
+      return ra_offset;
+    }
 
   /* Otherwise, get the RA offset from the FRE.  */
   return sframe_get_fre_offset (fre, SFRAME_FRE_RA_OFFSET_IDX, errp);
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: update the semantics of sframe_fre_get_fp_offset
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (2 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: update the semantics of sframe_fre_get_ra_offset Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: use uint32_t for fre_type and fde_type function args Indu Bhagat
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Until now, sframe_fre_get_fp_offset () would return
SFRAME_ERR_FREOFFSET_NOPRESENT if the ABI uses fixed FP offset.  A stack
tracer, then, would call an explicit sframe_decoder_get_fixed_fp_offset ()
to get the FP offset.

On second look, it appears to make sense to hide these details of
whether the FP offset is fixed or not in an ABI from the consumer.  Now,
with the changed semantics, the call to sframe_fre_get_fp_offset () will
fetch the fixed FP offset if applicable, or get the FP offset from FRE
when there is no fixed FP offset.

This patch changes the behavior of sframe_fre_get_fp_offset (): it turns
an error into non-error.  This change will be included with the next
release of libsframe, where all the exposed symbols will be versioned
with version node LIBSFRAME_1.0 for the first time.

libsframe/
	* sframe.c (sframe_fre_get_fp_offset): Return the fixed offset, if
	applicable. Else return the FP offset from the FRE.
---
 libsframe/sframe.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 3d1b5575f0b..912d34352a1 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -644,16 +644,21 @@ sframe_fre_get_fp_offset (sframe_decoder_ctx *dctx,
 			  sframe_frame_row_entry *fre, int *errp)
 {
   uint32_t fp_offset_idx = 0;
-  sframe_header *dhp = sframe_decoder_get_header (dctx);
-  /* If the FP offset is not being tracked, return an error code so the caller
-     can gather the fixed FP offset from the SFrame header.  */
-  if (dhp->sfh_cfa_fixed_fp_offset != SFRAME_CFA_FIXED_FP_INVALID)
-    return sframe_set_errno (errp, SFRAME_ERR_FREOFFSET_NOPRESENT);
+  int8_t fp_offset = sframe_decoder_get_fixed_fp_offset (dctx);
+  /* If the FP offset is not being tracked, return the fixed FP offset
+     from the SFrame header.  */
+  if (fp_offset != SFRAME_CFA_FIXED_FP_INVALID)
+    {
+      if (errp)
+	*errp = 0;
+      return fp_offset;
+    }
 
   /* In some ABIs, the stack offset to recover RA (using the CFA) from is
      fixed (like AMD64).  In such cases, the stack offset to recover FP will
      appear at the second index.  */
-  fp_offset_idx = ((dhp->sfh_cfa_fixed_ra_offset != SFRAME_CFA_FIXED_RA_INVALID)
+  fp_offset_idx = ((sframe_decoder_get_fixed_ra_offset (dctx)
+		    != SFRAME_CFA_FIXED_RA_INVALID)
 		   ? SFRAME_FRE_RA_OFFSET_IDX
 		   : SFRAME_FRE_FP_OFFSET_IDX);
   return sframe_get_fre_offset (fre, fp_offset_idx, errp);
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: use uint32_t for fre_type and fde_type function args
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (3 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: update the semantics of sframe_fre_get_fp_offset Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: bfd: use uint32_t for return type of sframe_calc_fre_type Indu Bhagat
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

The API sframe_fde_create_func_info is provided by libsframe.  Current
users are the bfd linker.  Adjust the argument type for the variables
carrying the SFrame FRE type and SFrame FDE type to consistenly use
uint32_t type alias.

include/
	* sframe-api.h (sframe_fde_create_func_info): Use uint32_t
	instead of unsigned int.
libsframe/
	* sframe.c (sframe_get_fre_type): Likewise.
	(sframe_get_fde_type): Likewise.
	(flip_fre_start_address): Likewise.
	(sframe_fre_start_addr_size): Likewise.
	(sframe_fre_entry_size): Likewise.
	(flip_fre): Likewise.
	(flip_sframe): Likewise.
	(sframe_fde_create_func_info): Likewise.
	(sframe_calc_fre_type): Likewise.
	(sframe_decode_fre_start_address): Likewise.
	(sframe_decode_fre): Likewise.
	(sframe_find_fre): Likewise.
	(sframe_decoder_get_fre): Likewise.
	(sframe_encoder_add_fre): Likewise.
	(sframe_encoder_write_fre_start_addr): Likewise.
	(sframe_encoder_write_fre): Likewise.
	(sframe_encoder_write_sframe): Likewise.
---
 include/sframe-api.h |  2 +-
 libsframe/sframe.c   | 42 +++++++++++++++++++++---------------------
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/include/sframe-api.h b/include/sframe-api.h
index a00303a3598..d04ebe85d11 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -94,7 +94,7 @@ sframe_errmsg (int error);
 /* Create an FDE function info bye given an FRE_TYPE and an FDE_TYPE.  */
 
 extern unsigned char
-sframe_fde_create_func_info (unsigned int fre_type, unsigned int fde_type);
+sframe_fde_create_func_info (uint32_t fre_type, uint32_t fde_type);
 
 /* Gather the FRE type given the function size.  */
 
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 912d34352a1..7391df0d3b5 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -132,19 +132,19 @@ sframe_get_fre_ra_mangled_p (uint8_t fre_info)
 
 /* Access functions for info from function descriptor entry.  */
 
-static unsigned int
+static uint32_t
 sframe_get_fre_type (sframe_func_desc_entry *fdep)
 {
-  unsigned int fre_type = 0;
+  uint32_t fre_type = 0;
   if (fdep)
     fre_type = SFRAME_V1_FUNC_FRE_TYPE (fdep->sfde_func_info);
   return fre_type;
 }
 
-static unsigned int
+static uint32_t
 sframe_get_fde_type (sframe_func_desc_entry *fdep)
 {
-  unsigned int fde_type = 0;
+  uint32_t fde_type = 0;
   if (fdep)
     fde_type = SFRAME_V1_FUNC_FDE_TYPE (fdep->sfde_func_info);
   return fde_type;
@@ -221,7 +221,7 @@ sframe_header_sanity_check_p (sframe_header *hp)
 /* Flip the start address pointed to by FP.  */
 
 static void
-flip_fre_start_address (char *addr, unsigned int fre_type)
+flip_fre_start_address (char *addr, uint32_t fre_type)
 {
   if (fre_type == SFRAME_FRE_TYPE_ADDR2)
     {
@@ -257,7 +257,7 @@ flip_fre_stack_offsets (char *offsets, uint8_t offset_size, uint8_t offset_cnt)
 /* Get the FRE start address size, given the FRE_TYPE.  */
 
 static size_t
-sframe_fre_start_addr_size (unsigned int fre_type)
+sframe_fre_start_addr_size (uint32_t fre_type)
 {
   size_t addr_size = 0;
   switch (fre_type)
@@ -329,7 +329,7 @@ sframe_fre_offset_bytes_size (uint8_t fre_info)
    includes the starting address, FRE info, and all the offsets.  */
 
 static size_t
-sframe_fre_entry_size (sframe_frame_row_entry *frep, unsigned int fre_type)
+sframe_fre_entry_size (sframe_frame_row_entry *frep, uint32_t fre_type)
 {
   if (frep == NULL)
     return 0;
@@ -363,7 +363,7 @@ sframe_decoder_get_funcdesc_at_index (sframe_decoder_ctx *ctx,
 }
 
 static int
-flip_fre (char *fp, unsigned int fre_type, size_t *fre_size)
+flip_fre (char *fp, uint32_t fre_type, size_t *fre_size)
 {
   uint8_t fre_info;
   uint8_t offset_size, offset_cnt;
@@ -416,7 +416,7 @@ flip_sframe (char *frame_buf, size_t buf_size, uint32_t to_foreign)
   sframe_func_desc_entry *fdep;
   unsigned int num_fdes = 0;
   unsigned int num_fres = 0;
-  unsigned int fre_type = 0;
+  uint32_t fre_type = 0;
   uint32_t fre_offset = 0;
   size_t esz = 0;
   size_t hdrsz = 0;
@@ -585,8 +585,8 @@ sframe_decoder_free (sframe_decoder_ctx **dctxp)
 /* FIXME API for linker.  Revisit if its better placed somewhere else?  */
 
 unsigned char
-sframe_fde_create_func_info (unsigned int fre_type,
-			     unsigned int fde_type)
+sframe_fde_create_func_info (uint32_t fre_type,
+			     uint32_t fde_type)
 {
   unsigned char func_info;
   sframe_assert (fre_type == SFRAME_FRE_TYPE_ADDR1
@@ -604,7 +604,7 @@ sframe_fde_create_func_info (unsigned int fre_type,
 unsigned int
 sframe_calc_fre_type (size_t func_size)
 {
-  unsigned int fre_type = 0;
+  uint32_t fre_type = 0;
   if (func_size < SFRAME_FRE_TYPE_ADDR1_LIMIT)
     fre_type = SFRAME_FRE_TYPE_ADDR1;
   else if (func_size < SFRAME_FRE_TYPE_ADDR2_LIMIT)
@@ -717,7 +717,7 @@ sframe_frame_row_entry_copy (sframe_frame_row_entry *dst,
 static int
 sframe_decode_fre_start_address (const char *fre_buf,
 				 uint32_t *fre_start_addr,
-				 unsigned int fre_type)
+				 uint32_t fre_type)
 {
   uint32_t saddr = 0;
   int err = 0;
@@ -762,7 +762,7 @@ sframe_decode_fre_start_address (const char *fre_buf,
 
 static int
 sframe_decode_fre (const char *fre_buf, sframe_frame_row_entry *fre,
-		   unsigned int fre_type, size_t *esz)
+		   uint32_t fre_type, size_t *esz)
 {
   int err = 0;
   const char *stack_offsets = NULL;
@@ -1056,7 +1056,7 @@ sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
 {
   sframe_frame_row_entry cur_fre;
   sframe_func_desc_entry *fdep;
-  unsigned int fre_type, fde_type;
+  uint32_t fre_type, fde_type;
   uint32_t end_ip_offset, i;
   int32_t start_ip, end_ip;
   int32_t func_start_addr;
@@ -1178,7 +1178,7 @@ sframe_decoder_get_fre (sframe_decoder_ctx *ctx,
   sframe_frame_row_entry ifre;
   const char *fres;
   uint32_t i;
-  unsigned int fre_type;
+  uint32_t fre_type;
   size_t esz = 0;
   int err = 0;
 
@@ -1359,7 +1359,7 @@ sframe_encoder_add_fre (sframe_encoder_ctx *encoder,
   sframe_func_desc_entry *fdep;
   sframe_frame_row_entry *ectx_frep;
   size_t offsets_sz, esz;
-  unsigned int fre_type;
+  uint32_t fre_type;
   size_t fre_tbl_sz;
   int err = 0;
 
@@ -1505,7 +1505,7 @@ sframe_encoder_add_funcdesc (sframe_encoder_ctx *encoder,
     = encoder->sfe_fre_nbytes;
 #if 0
   // Linker optimization test code cleanup later ibhagat TODO FIXME
-  unsigned int fre_type = sframe_calc_fre_type (func_size);
+  uint32_t fre_type = sframe_calc_fre_type (func_size);
 
   fd_info->entry[fd_info->count].sfde_func_info
     = sframe_fde_func_info (fre_type);
@@ -1549,7 +1549,7 @@ sframe_sort_funcdesc (sframe_encoder_ctx *encoder)
 static int
 sframe_encoder_write_fre_start_addr (char *contents,
 				     uint32_t fre_start_addr,
-				     unsigned int fre_type,
+				     uint32_t fre_type,
 				     size_t fre_start_addr_sz)
 {
   int err = 0;
@@ -1584,7 +1584,7 @@ sframe_encoder_write_fre_start_addr (char *contents,
 
 static int
 sframe_encoder_write_fre (char *contents, sframe_frame_row_entry *frep,
-			  unsigned int fre_type, size_t *esz)
+			  uint32_t fre_type, size_t *esz)
 {
   size_t fre_sz;
   size_t fre_start_addr_sz;
@@ -1644,7 +1644,7 @@ sframe_encoder_write_sframe (sframe_encoder_ctx *encoder)
   sframe_func_desc_entry *fdep;
   sframe_frame_row_entry *frep;
 
-  unsigned int fre_type;
+  uint32_t fre_type;
   int err = 0;
 
   contents = encoder->sfe_data;
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: bfd: use uint32_t for return type of sframe_calc_fre_type
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (4 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: use uint32_t for fre_type and fde_type function args Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: use uint8_t instead of unsigned char for abi_arch Indu Bhagat
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Use uint32_t type alias consistently for all APIs in libsframe.

bfd/
	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Adjust for the
	changed return type.
libsframe/
	* sframe.c (sframe_calc_fre_type): Use uint32_t for return type.
include/
	* sframe-api.h (sframe_calc_fre_type): Likewise.
---
 bfd/elfxx-x86.c      | 2 +-
 include/sframe-api.h | 2 +-
 libsframe/sframe.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 8e13a92e7f9..ffd02f137d1 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -1832,7 +1832,7 @@ _bfd_x86_elf_create_sframe_plt (bfd *output_bfd,
   bool plt0_generated_p;
   unsigned int plt0_entry_size;
   unsigned char func_info;
-  unsigned int fre_type;
+  uint32_t fre_type;
   /* The dynamic plt section for which .sframe stack trace information is being
      created.  */
   asection *dpltsec;
diff --git a/include/sframe-api.h b/include/sframe-api.h
index d04ebe85d11..70829ec87cb 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -98,7 +98,7 @@ sframe_fde_create_func_info (uint32_t fre_type, uint32_t fde_type);
 
 /* Gather the FRE type given the function size.  */
 
-extern unsigned int
+extern uint32_t
 sframe_calc_fre_type (size_t func_size);
 
 /* The SFrame Decoder.  */
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 7391df0d3b5..8e9dc0a9d2c 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -601,7 +601,7 @@ sframe_fde_create_func_info (uint32_t fre_type,
 /* Get the FRE type given the function size.  */
 /* FIXME API for linker.  Revisit if its better placed somewhere else?  */
 
-unsigned int
+uint32_t
 sframe_calc_fre_type (size_t func_size)
 {
   uint32_t fre_type = 0;
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: use uint8_t instead of unsigned char for abi_arch
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (5 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: bfd: use uint32_t for return type of sframe_calc_fre_type Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: use uint8_t for return type of sframe_fre_get_base_reg_id Indu Bhagat
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Use uint8_t consistently for identifying ABI/arch in SFrame format.

bfd/
	* elf-sframe.c (_bfd_elf_merge_section_sframe):
libsframe/
	* sframe-dump.c (is_sframe_abi_arch_aarch64): Use uint8_t for
	local variable.
	* sframe.c (sframe_decoder_get_abi_arch): Update return type to
	uint8_t.
	(sframe_encoder_get_abi_arch): Likewise.
include/
	* sframe-api.h (sframe_decoder_get_abi_arch): Likewise.
	(sframe_encoder_get_abi_arch): Likewise.
---
 bfd/elf-sframe.c        |  2 +-
 include/sframe-api.h    |  4 ++--
 libsframe/sframe-dump.c |  6 +++---
 libsframe/sframe.c      | 12 ++++++------
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index 57d67989bf9..069f7564fb4 100644
--- a/bfd/elf-sframe.c
+++ b/bfd/elf-sframe.c
@@ -325,7 +325,7 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
   struct sframe_enc_info *sfe_info;
   sframe_decoder_ctx *sfd_ctx;
   sframe_encoder_ctx *sfe_ctx;
-  unsigned char sfd_ctx_abi_arch;
+  uint8_t sfd_ctx_abi_arch;
   int8_t sfd_ctx_fixed_fp_offset;
   int8_t sfd_ctx_fixed_ra_offset;
   int encerr = 0;
diff --git a/include/sframe-api.h b/include/sframe-api.h
index 70829ec87cb..e62a7a38285 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -117,7 +117,7 @@ extern unsigned int
 sframe_decoder_get_hdr_size (sframe_decoder_ctx *dctx);
 
 /* Get the SFrame's abi/arch info.  */
-extern unsigned char
+extern uint8_t
 sframe_decoder_get_abi_arch (sframe_decoder_ctx *dctx);
 
 /* Return the number of function descriptor entries in the SFrame decoder
@@ -214,7 +214,7 @@ extern unsigned int
 sframe_encoder_get_hdr_size (sframe_encoder_ctx *encoder);
 
 /* Get the abi/arch info from the SFrame encoder context CTX.  */
-extern unsigned char
+extern uint8_t
 sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder);
 
 /* Return the number of function descriptor entries in the SFrame encoder
diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 2491b4391f3..37ce9d70eb3 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -32,9 +32,9 @@ is_sframe_abi_arch_aarch64 (sframe_decoder_ctx *sfd_ctx)
 {
   bool aarch64_p = false;
 
-  unsigned char abi_arch = sframe_decoder_get_abi_arch (sfd_ctx);
-  if ((abi_arch == SFRAME_ABI_AARCH64_ENDIAN_BIG)
-      || (abi_arch == SFRAME_ABI_AARCH64_ENDIAN_LITTLE))
+  uint8_t abi_arch = sframe_decoder_get_abi_arch (sfd_ctx);
+  if (abi_arch == SFRAME_ABI_AARCH64_ENDIAN_BIG
+      || abi_arch == SFRAME_ABI_AARCH64_ENDIAN_LITTLE)
     aarch64_p = true;
 
   return aarch64_p;
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 8e9dc0a9d2c..2d7e4a4a462 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -931,13 +931,13 @@ sframe_decoder_get_hdr_size (sframe_decoder_ctx *ctx)
   return sframe_get_hdr_size (dhp);
 }
 
-/* Get the SFrame's abi/arch info given the decoder context CTX.  */
+/* Get the SFrame's abi/arch info given the decoder context DCTX.  */
 
-unsigned char
-sframe_decoder_get_abi_arch (sframe_decoder_ctx *ctx)
+uint8_t
+sframe_decoder_get_abi_arch (sframe_decoder_ctx *dctx)
 {
   sframe_header *sframe_header;
-  sframe_header = sframe_decoder_get_header (ctx);
+  sframe_header = sframe_decoder_get_header (dctx);
   return sframe_header->sfh_abi_arch;
 }
 
@@ -1322,10 +1322,10 @@ sframe_encoder_get_hdr_size (sframe_encoder_ctx *encoder)
 
 /* Get the abi/arch info from the SFrame encoder context ENCODER.  */
 
-unsigned char
+uint8_t
 sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder)
 {
-  unsigned char abi_arch = 0;
+  uint8_t abi_arch = 0;
   sframe_header *ehp;
   ehp = sframe_encoder_get_header (encoder);
   if (ehp)
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: use uint8_t for return type of sframe_fre_get_base_reg_id
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (6 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: use uint8_t instead of unsigned char for abi_arch Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: use appropriate data types for args of sframe_encode Indu Bhagat
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Use a more appropriate data type.

include/
	* sframe-api.h (sframe_fre_get_base_reg_id): Use uint8_t as
	return type.
libsframe/
	* sframe-dump.c (dump_sframe_func_with_fres): Use uint8_t type
	for base reg id.
	* sframe.c (sframe_fre_get_base_reg_id): Use uin8_t as return
	type.
---
 include/sframe-api.h    | 2 +-
 libsframe/sframe-dump.c | 2 +-
 libsframe/sframe.c      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/sframe-api.h b/include/sframe-api.h
index e62a7a38285..46614925c68 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -173,7 +173,7 @@ extern void
 dump_sframe (sframe_decoder_ctx *decoder, uint64_t addr);
 
 /* Get the base reg id from the FRE info.  Sets errp if fails.  */
-extern unsigned int
+extern uint8_t
 sframe_fre_get_base_reg_id (sframe_frame_row_entry *fre, int *errp);
 
 /* Get the CFA offset from the FRE.  If the offset is invalid, sets errp.  */
diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c
index 37ce9d70eb3..4799652f727 100644
--- a/libsframe/sframe-dump.c
+++ b/libsframe/sframe-dump.c
@@ -105,7 +105,7 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_ctx,
   int32_t cfa_offset = 0;
   int32_t fp_offset = 0;
   int32_t ra_offset = 0;
-  unsigned int base_reg_id = 0;
+  uint8_t base_reg_id = 0;
   int err[3] = {0, 0, 0};
 
   sframe_frame_row_entry fre;
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 2d7e4a4a462..b885e3df5ec 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -618,7 +618,7 @@ sframe_calc_fre_type (size_t func_size)
 
 /* Get the base reg id from the FRE info.  Set errp if failure.  */
 
-unsigned int
+uint8_t
 sframe_fre_get_base_reg_id (sframe_frame_row_entry *fre, int *errp)
 {
   if (fre == NULL)
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: use appropriate data types for args of sframe_encode
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (7 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: use uint8_t for return type of sframe_fre_get_base_reg_id Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] libsframe: bfd: use uint32_t for return type of get_num_fidx APIs Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] binutils/NEWS: add note about upcoming libsframe changes Indu Bhagat
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

include/
	* sframe-api.h (sframe_encode): Use of uint8_t is more
	appropriate.
libsframe/
	* sframe.c (sframe_encode): Likewise.
---
 include/sframe-api.h | 2 +-
 libsframe/sframe.c   | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/sframe-api.h b/include/sframe-api.h
index 46614925c68..9cb2db0edb9 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -202,7 +202,7 @@ sframe_fre_get_ra_mangled_p (sframe_decoder_ctx *dctx,
 /* Create an encoder context with the given SFrame format version VER, FLAGS
    and ABI information.  Sets errp if failure.  */
 extern sframe_encoder_ctx *
-sframe_encode (unsigned char ver, unsigned char flags, int abi,
+sframe_encode (uint8_t ver, uint8_t flags, uint8_t abi_arch,
 	       int8_t fixed_fp_offset, int8_t fixed_ra_offset, int *errp);
 
 /* Free the encoder context.  */
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index b885e3df5ec..40927f06933 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -1248,10 +1248,11 @@ sframe_encoder_get_funcdesc_at_index (sframe_encoder_ctx *encoder,
 }
 
 /* Create an encoder context with the given SFrame format version VER, FLAGS
-   and ABI information.  Sets errp if failure.  */
+   and ABI information.  Uses the ABI specific FIXED_FP_OFFSET and
+   FIXED_RA_OFFSET values as provided.  Sets errp if failure.  */
 
 sframe_encoder_ctx *
-sframe_encode (unsigned char ver, unsigned char flags, int abi_arch,
+sframe_encode (uint8_t ver, uint8_t flags, uint8_t abi_arch,
 	       int8_t fixed_fp_offset, int8_t fixed_ra_offset, int *errp)
 {
   sframe_header *hp;
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] libsframe: bfd: use uint32_t for return type of get_num_fidx APIs
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (8 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: use appropriate data types for args of sframe_encode Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  2023-06-27 19:51 ` [COMMITTED] binutils/NEWS: add note about upcoming libsframe changes Indu Bhagat
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Keep the data types usage in libsframe look consistent.

bfd/
	* elf-sframe.c (_bfd_elf_merge_section_sframe): Use uint32_t
	type alias.
	* libsframe/sframe.c (sframe_decoder_get_funcdesc_at_index):
	Likewise.
	(sframe_decoder_get_num_fidx): Likewise.
	(sframe_encoder_get_num_fidx): Likewise.
include/
	* sframe-api.h (sframe_decoder_get_num_fidx): Likewise.
	(sframe_encoder_get_num_fidx): Likewise.
---
 bfd/elf-sframe.c     |  6 +++---
 include/sframe-api.h |  4 ++--
 libsframe/sframe.c   | 10 +++++-----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index 069f7564fb4..013a892e08a 100644
--- a/bfd/elf-sframe.c
+++ b/bfd/elf-sframe.c
@@ -403,10 +403,10 @@ _bfd_elf_merge_section_sframe (bfd *abfd,
   /* Iterate over the function descriptor entries and the FREs of the
      function from the decoder context.  Add each of them to the encoder
      context, if suitable.  */
-  unsigned int i = 0, j = 0, cur_fidx = 0;
+  uint32_t i = 0, j = 0, cur_fidx = 0;
 
-  unsigned int num_fidx = sframe_decoder_get_num_fidx (sfd_ctx);
-  unsigned int num_enc_fidx = sframe_encoder_get_num_fidx (sfe_ctx);
+  uint32_t num_fidx = sframe_decoder_get_num_fidx (sfd_ctx);
+  uint32_t num_enc_fidx = sframe_encoder_get_num_fidx (sfe_ctx);
 
   for (i = 0; i < num_fidx; i++)
     {
diff --git a/include/sframe-api.h b/include/sframe-api.h
index 9cb2db0edb9..7594011a48f 100644
--- a/include/sframe-api.h
+++ b/include/sframe-api.h
@@ -122,7 +122,7 @@ sframe_decoder_get_abi_arch (sframe_decoder_ctx *dctx);
 
 /* Return the number of function descriptor entries in the SFrame decoder
    DCTX.  */
-extern unsigned int
+extern uint32_t
 sframe_decoder_get_num_fidx (sframe_decoder_ctx *dctx);
 
 /* Get the fixed FP offset from the decoder context DCTX.  */
@@ -219,7 +219,7 @@ sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder);
 
 /* Return the number of function descriptor entries in the SFrame encoder
    ENCODER.  */
-extern unsigned int
+extern uint32_t
 sframe_encoder_get_num_fidx (sframe_encoder_ctx *encoder);
 
 /* Add an FRE to function at FUNC_IDX'th function descriptor index entry in
diff --git a/libsframe/sframe.c b/libsframe/sframe.c
index 40927f06933..29142436b84 100644
--- a/libsframe/sframe.c
+++ b/libsframe/sframe.c
@@ -349,7 +349,7 @@ sframe_decoder_get_funcdesc_at_index (sframe_decoder_ctx *ctx,
 				      uint32_t func_idx)
 {
   sframe_func_desc_entry *fdep;
-  unsigned int num_fdes;
+  uint32_t num_fdes;
   int err;
 
   num_fdes = sframe_decoder_get_num_fidx (ctx);
@@ -1119,10 +1119,10 @@ sframe_find_fre (sframe_decoder_ctx *ctx, int32_t pc,
 /* Return the number of function descriptor entries in the SFrame decoder
    DCTX.  */
 
-unsigned int
+uint32_t
 sframe_decoder_get_num_fidx (sframe_decoder_ctx *ctx)
 {
-  unsigned int num_fdes = 0;
+  uint32_t num_fdes = 0;
   sframe_header *dhp = NULL;
   dhp = sframe_decoder_get_header (ctx);
   if (dhp)
@@ -1337,10 +1337,10 @@ sframe_encoder_get_abi_arch (sframe_encoder_ctx *encoder)
 /* Return the number of function descriptor entries in the SFrame encoder
    ENCODER.  */
 
-unsigned int
+uint32_t
 sframe_encoder_get_num_fidx (sframe_encoder_ctx *encoder)
 {
-  unsigned int num_fdes = 0;
+  uint32_t num_fdes = 0;
   sframe_header *ehp = NULL;
   ehp = sframe_encoder_get_header (encoder);
   if (ehp)
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [COMMITTED] binutils/NEWS: add note about upcoming libsframe changes
  2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
                   ` (9 preceding siblings ...)
  2023-06-27 19:51 ` [COMMITTED] libsframe: bfd: use uint32_t for return type of get_num_fidx APIs Indu Bhagat
@ 2023-06-27 19:51 ` Indu Bhagat
  10 siblings, 0 replies; 12+ messages in thread
From: Indu Bhagat @ 2023-06-27 19:51 UTC (permalink / raw)
  To: binutils; +Cc: Indu Bhagat

Some of these changes update the ABI in an incompatible way.
---
 binutils/NEWS | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/binutils/NEWS b/binutils/NEWS
index 8e1b1ee63e9..00ef7c43610 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -7,6 +7,12 @@
 
 * Objdump's --private option can now be used on PE format files to display the
   fields in the file header and section headers.
+
+* New versioned release of libsframe: libsframe.so.1.  This release introduces
+  versioned symbols with version node name LIBSFRAME_1.0.  This release also
+  updates the ABI in an incompatible way: this includes removal of
+  sframe_get_funcdesc_with_addr API, change in the behavior of
+  sframe_fre_get_ra_offset and sframe_fre_get_fp_offset APIs.
   
 Changes in 2.40:
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-27 19:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 19:51 [COMMITTED] libsframe: add library versioning Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: remove sframe_get_funcdesc_with_addr API Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: add symbol versioning Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: update the semantics of sframe_fre_get_ra_offset Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: update the semantics of sframe_fre_get_fp_offset Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: use uint32_t for fre_type and fde_type function args Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: bfd: use uint32_t for return type of sframe_calc_fre_type Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: use uint8_t instead of unsigned char for abi_arch Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: use uint8_t for return type of sframe_fre_get_base_reg_id Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: use appropriate data types for args of sframe_encode Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] libsframe: bfd: use uint32_t for return type of get_num_fidx APIs Indu Bhagat
2023-06-27 19:51 ` [COMMITTED] binutils/NEWS: add note about upcoming libsframe changes Indu Bhagat

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).