libsframe: add symbol versioning
authorIndu Bhagat <indu.bhagat@oracle.com>
Tue, 27 Jun 2023 18:54:12 +0000 (11:54 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Tue, 27 Jun 2023 19:01:56 +0000 (12:01 -0700)
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
libsframe/Makefile.in
libsframe/configure
libsframe/configure.ac
libsframe/libsframe.ver [new file with mode: 0644]

index 2d1d8fff06369b0b76f61ec5409e6cac76d544b0..a660e85c2ce562282cfaed27740d95e0311b6b56 100644 (file)
@@ -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
index 57f912caa13df7d9df0113b8df7e5cb7016fb091..08c780caa4a92ec966202c37a70b0a874b25f1ef 100644 (file)
@@ -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
index bf4dc45b431e852e64a1745b1e89ffdcbb940929..f7ad9c5e29a0c964e7f29508dab9f4364c5067e4 100755 (executable)
@@ -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
index b9ea363d00d99065a2049ffabbe1f94359ecf51c..8189e966e1c37b670caaaddb240a4d72601180f3 100644 (file)
@@ -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 (file)
index 0000000..2c2081f
--- /dev/null
@@ -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;