diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2021-09-27 20:31:21 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2021-09-27 20:31:24 +0100 |
commit | ea9c2009115d7e00732f5ad316c10a171fc66a53 (patch) | |
tree | 964e06b495b0f2eea0b157a8765093ed265dac6e /libctf/configure.ac | |
parent | bef9ef8ca0f941d743c77cc55b5fe7985990b2a7 (diff) | |
download | gdb-ea9c2009115d7e00732f5ad316c10a171fc66a53.zip gdb-ea9c2009115d7e00732f5ad316c10a171fc66a53.tar.gz gdb-ea9c2009115d7e00732f5ad316c10a171fc66a53.tar.bz2 |
libctf: try several possibilities for linker versioning flags
Checking for linker versioning by just grepping ld --help output for
mentions of --version-script is inadequate now that Solaris 11.4
implements a --version-script with different semantics. Try linking a
test program with a small wildcard-using version script with each
supported set of flags in turn, to make sure that linker versioning is
not only advertised but actually works.
The Solaris "GNU-compatible" linker versioning is not quite
GNU-compatible enough, but we can work around the differences by
generating a new version script that removes the comments from the
original (Solaris ld requires #-style comments), and making another
version script for libctf-nonbfd in particular which doesn't mention any
of the symbols that appear in libctf.la, to avoid Solaris ld introducing
corresponding new NOTYPE symbols to match the version script.
libctf/ChangeLog
2021-09-27 Nick Alcock <nick.alcock@oracle.com>
PR libctf/27967
* configure.ac (VERSION_FLAGS): Replace with...
(ac_cv_libctf_version_script): ... this multiple test.
(VERSION_FLAGS_NOBFD): Substitute this too.
* Makefile.am (libctf_nobfd_la_LDFLAGS): Use it. Split out...
(libctf_ldflags_nover): ... non-versioning flags here.
(libctf_la_LDFLAGS): Use it.
* libctf.ver: Give every symbol not in libctf-nobfd a comment on
the same line noting as much.
Diffstat (limited to 'libctf/configure.ac')
-rw-r--r-- | libctf/configure.ac | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/libctf/configure.ac b/libctf/configure.ac index 80644b8..4e12a4f 100644 --- a/libctf/configure.ac +++ b/libctf/configure.ac @@ -219,11 +219,51 @@ fi` AM_CONDITIONAL(TCL_TRY, test "${ac_cv_libctf_tcl_try}" = yes) # Use a version script, if possible, or an -export-symbols-regex otherwise. -VERSION_FLAGS='-export-symbols-regex ctf_.*' -if $LD --help 2>&1 | grep -- --version-script >/dev/null; then - VERSION_FLAGS="-Wl,--version-script='$srcdir/libctf.ver'" +decommented_version_script= +AC_CACHE_CHECK([for linker versioning flags], [ac_cv_libctf_version_script], + [echo 'FOO { global: mai*; local: ctf_fo*; };' > conftest.ver + old_LDFLAGS="$LDFLAGS" + old_CFLAGS="$CFLAGS" + LDFLAGS="$LDFLAGS -shared -Wl,--version-script=conftest.ver" + CFLAGS="$CFLAGS -fPIC" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int ctf_foo (void) { return 0; } + int main (void) { return ctf_foo(); }]])], + [ac_cv_libctf_version_script="-Wl,--version-script='$srcdir/libctf.ver'"], + []) + LDFLAGS="$old_LDFLAGS" + + if test -z "$ac_cv_libctf_version_script"; then + LDFLAGS="$LDFLAGS -shared -Wl,-B,local -Wl,-z,gnu-version-script=conftest.ver" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int ctf_foo (void) { return 0; } + int main (void) { return ctf_foo(); }]])], + [ac_cv_libctf_version_script="-Wl,-B,local -Wl,-z,gnu-version-script" + decommented_version_script=t], + []) + LDFLAGS="$old_LDFLAGS" + fi + CFLAGS="$old_CFLAGS" + + if test -z "$ac_cv_libctf_version_script"; then + ac_cv_libctf_version_script='-export-symbols-regex ctf_.*' + fi + rm -f conftest.ver]) +if test -n "$decommented_version_script"; then + # Solaris's version scripts use shell-style comments rather than the C-style + # used by GNU ld. Use cpp to strip the comments out. (cpp exists under this + # name on all platforms that support ld -z gnu-version-script.) + # Also ensure that no symbols exist in the version script for libctf-nobfd.so + # that do not exist in the shared library itself, since some linkers add such + # symbols with type NOTYPE. + /lib/cpp < $srcdir/libctf.ver > libctf-decommented.ver + grep -v 'libctf only' $srcdir/libctf.ver | /lib/cpp > libctf-nobfd-decommented.ver + VERSION_FLAGS="$ac_cv_libctf_version_script='libctf-decommented.ver'" + VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script='libctf-nobfd-decommented.ver'" +else + VERSION_FLAGS="$ac_cv_libctf_version_script" + VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script" fi AC_SUBST(VERSION_FLAGS) +AC_SUBST(VERSION_FLAGS_NOBFD) AC_CONFIG_FILES(Makefile) AC_CONFIG_HEADERS(config.h) |