public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] libsframe: add symbol versioning
@ 2023-06-27 19:42 Indu Bhagat
  0 siblings, 0 replies; only message in thread
From: Indu Bhagat @ 2023-06-27 19:42 UTC (permalink / raw)
  To: bfd-cvs, gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=99fde044fc332b97616b395393b2590c510b0e6f

commit 99fde044fc332b97616b395393b2590c510b0e6f
Author: Indu Bhagat <indu.bhagat@oracle.com>
Date:   Tue Jun 27 11:54:12 2023 -0700

    libsframe: add symbol versioning
    
    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.

Diff:
---
 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(-)

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27 19:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 19:42 [binutils-gdb] libsframe: add symbol versioning 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).