Use -Bsymbolic-functions and -Bsymbolic

This avoids dynamic lookups to resolve symbols inside the library, but
disallows symbol interposition.

* m4/symbolic.m4: New file.
* buddy/m4/symbolic.m4: New link.
* configure.ac, buddy/configure.ac: Add AX_SYMBOLIC.
* buddy/src/Makefile.am, iface/ltsmin/Makefile.am, src/Makefile.am,
wrap/python/Makefile.am: Link with $(SYMBOLIC_LDFLAGS).
This commit is contained in:
Alexandre Duret-Lutz 2015-11-10 08:31:54 +01:00
parent 0553842347
commit 86abd6c1c0
8 changed files with 40 additions and 4 deletions

View file

@ -19,6 +19,7 @@ AC_PROG_YACC
AC_PROG_CXX AC_PROG_CXX
LT_INIT([win32-dll]) LT_INIT([win32-dll])
AX_BSYMBOLIC
# Use -Werror since using -fvisibility under MinGW is only a warning. # Use -Werror since using -fvisibility under MinGW is only a warning.
# (The option is ignored anyway since this does not make sense under windows). # (The option is ignored anyway since this does not make sense under windows).

1
buddy/m4/symbolic.m4 Symbolic link
View file

@ -0,0 +1 @@
../../m4/symbolic.m4

View file

@ -5,7 +5,7 @@ BUDDY_FLAGS = -I$(top_builddir) -DVERSION=23 -DBUDDY_DLL_EXPORTS -DBUDDY_DLL
lib_LTLIBRARIES = libbddx.la lib_LTLIBRARIES = libbddx.la
# See the `Updating version info' node of the Libtool manual before # See the `Updating version info' node of the Libtool manual before
# changing this. # changing this.
libbddx_la_LDFLAGS = -no-undefined -version-info 0:0:0 libbddx_la_LDFLAGS = -no-undefined -version-info 0:0:0 $(SYMBOLIC_LDFLAGS)
libbddx_la_CPPFLAGS = $(BUDDY_FLAGS) libbddx_la_CPPFLAGS = $(BUDDY_FLAGS)
libbddx_la_SOURCES = \ libbddx_la_SOURCES = \
bddio.c \ bddio.c \

View file

@ -118,6 +118,7 @@ LTDL_INIT([subproject convenience])
link_all_deplibs=yes link_all_deplibs=yes
link_all_deplibs_CXX=yes link_all_deplibs_CXX=yes
AX_BSYMBOLIC
AC_ARG_ENABLE([python], AC_ARG_ENABLE([python],
[AC_HELP_STRING([--disable-python], [AC_HELP_STRING([--disable-python],

View file

@ -29,6 +29,7 @@ lib_LTLIBRARIES = libspotltsmin.la
libspotltsmin_la_LIBADD = \ libspotltsmin_la_LIBADD = \
$(top_builddir)/src/libspot.la \ $(top_builddir)/src/libspot.la \
$(top_builddir)/ltdl/libltdlc.la -lpthread $(top_builddir)/ltdl/libltdlc.la -lpthread
libspotltsmin_la_LDFLAGS = -no-undefined $(SYMBOLIC_LDFLAGS)
libspotltsmin_la_SOURCES = ltsmin.cc libspotltsmin_la_SOURCES = ltsmin.cc
noinst_PROGRAMS = modelcheck noinst_PROGRAMS = modelcheck

31
m4/symbolic.m4 Normal file
View file

@ -0,0 +1,31 @@
dnl This was addapted from a patch submitted written by H.J. Lu for GCC.
dnl https://gcc.gnu.org/ml/gcc/2007-01/msg00363.html
dnl The -Bsymbolic-functions is no-longer part of the --help of ld, but
dnl we can call ld -Bsymbolic-functions --help and it will choke if the
dnl option is not supported.
dnl Substitute SYMBOLIC_LDFLAGS with -Bsymbolic-functions for GNU linker
dnl if it is supported.
AC_DEFUN([AC_LIB_PROG_LD_GNU_SYMBOLIC],
[AC_CACHE_CHECK([if the GNU linker ($LD) supports -Bsymbolic-functions],
acl_cv_prog_gnu_ld_symbolic, [
acl_cv_prog_gnu_ld_symbolic=no
if test x"$with_gnu_ld" = x"yes"; then
if $LD -Bsymbolic-functions -Bsymbolic --help>/dev/null 2>&1 </dev/null; then
acl_cv_prog_gnu_ld_symbolic=yes
fi
fi])
if test x"$acl_cv_prog_gnu_ld_symbolic" = x"yes"; then
SYMBOLIC_LDFLAGS="-Wl,-Bsymbolic-functions -Wl,-Bsymbolic"
else
SYMBOLIC_LDFLAGS=''
fi
AC_SUBST([SYMBOLIC_LDFLAGS])])
AC_DEFUN([AX_BSYMBOLIC],
[AC_ARG_ENABLE([Bsymbolic],
[AS_HELP_STRING([--disable-Bsymbolic],
[disable linking with -Bsymbolic])],
[], [enable_Bsymbolic=yes])
if test "$enable_Bsymbolic" != "no"; then
AC_LIB_PROG_LD_GNU_SYMBOLIC
fi])

View file

@ -30,7 +30,7 @@ SUBDIRS = misc priv tl graph twa twaalgos ta taalgos kripke \
lib_LTLIBRARIES = libspot.la lib_LTLIBRARIES = libspot.la
libspot_la_SOURCES = libspot_la_SOURCES =
libspot_la_LDFLAGS = $(BUDDY_LDFLAGS) -no-undefined libspot_la_LDFLAGS = $(BUDDY_LDFLAGS) -no-undefined $(SYMBOLIC_LDFLAGS)
libspot_la_LIBADD = \ libspot_la_LIBADD = \
kripke/libkripke.la \ kripke/libkripke.la \
kripkeparse/libkripkeparse.la \ kripkeparse/libkripkeparse.la \

View file

@ -36,7 +36,7 @@ MAINTAINERCLEANFILES = \
## spot ## spot
_spot_impl_la_SOURCES = $(srcdir)/spot_impl_wrap.cxx _spot_impl_la_SOURCES = $(srcdir)/spot_impl_wrap.cxx
_spot_impl_la_LDFLAGS = -avoid-version -module _spot_impl_la_LDFLAGS = -avoid-version -module -no-undefined $(SYMBOLIC_LDFLAGS)
_spot_impl_la_LIBADD = $(top_builddir)/src/libspot.la _spot_impl_la_LIBADD = $(top_builddir)/src/libspot.la
$(srcdir)/spot_impl_wrap.cxx: $(srcdir)/spot_impl.i $(srcdir)/spot_impl_wrap.cxx: $(srcdir)/spot_impl.i
@ -49,7 +49,8 @@ $(srcdir)/spot_impl.py: $(srcdir)/spot_impl.i
## buddy ## buddy
_buddy_la_SOURCES = $(srcdir)/buddy_wrap.cxx _buddy_la_SOURCES = $(srcdir)/buddy_wrap.cxx
_buddy_la_LDFLAGS = -avoid-version -module $(BUDDY_LDFLAGS) _buddy_la_LDFLAGS = -avoid-version -module $(BUDDY_LDFLAGS) \
-no-undefined $(SYMBOLIC_LDFLAGS)
$(srcdir)/buddy_wrap.cxx: $(srcdir)/buddy.i $(srcdir)/buddy_wrap.cxx: $(srcdir)/buddy.i
$(SWIG) -c++ -python $(BUDDY_CPPFLAGS) $(srcdir)/buddy.i $(SWIG) -c++ -python $(BUDDY_CPPFLAGS) $(srcdir)/buddy.i