aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2024-04-17 19:06:17 +0100
committerNick Alcock <nick.alcock@oracle.com>2024-04-19 16:14:48 +0100
commitedc27e2d90a2af3afddd68e7a534afcc428719e5 (patch)
treea73199add56dd75a88d30317f24f109b41c9b16a
parentd8e1bca7ebc357ebd9b7a338a53d2767cf0564b6 (diff)
downloadgdb-edc27e2d90a2af3afddd68e7a534afcc428719e5.zip
gdb-edc27e2d90a2af3afddd68e7a534afcc428719e5.tar.gz
gdb-edc27e2d90a2af3afddd68e7a534afcc428719e5.tar.bz2
libctf: do not include undefined functions in libctf.ver
libctf's version script is applied to two libraries: libctf.so, and libctf-nobfd.so. The latter library is a subset of the former which does not link to libbfd and does not include a few public entry points that use it (found in libctf-open-bfd.c). This means that some of the symbols in this version script only exist in one of the libraries it's applied to. A number of linkers dislike this: before now, only Solaris's linker caused serious problems, introducing NOTYPE-typed symbols when such things were found, but now LLD has started to complain as well: ld: error: version script assignment of 'LIBCTF_1.0' to symbol 'ctf_arc_open' failed: symbol not defined ld: error: version script assignment of 'LIBCTF_1.0' to symbol 'ctf_fdopen' failed: symbol not defined ld: error: version script assignment of 'LIBCTF_1.0' to symbol 'ctf_open' failed: symbol not defined ld: error: version script assignment of 'LIBCTF_1.0' to symbol 'ctf_bfdopen' failed: symbol not defined ld: error: version script assignment of 'LIBCTF_1.0' to symbol 'ctf_bfdopen_ctfsect' failed: symbol not defined Rather than adding more and more whack-a-mole fixes for every linker we encounter that does this, simply exclude such symbols unconditionally, using the same trick we used to use for Solaris. (Well, unconditionally if we can use version scripts with this linker at all, which is not always the case.) Thanks to Nicholas Vinson for the original report and a fix very similar to this one (but not quite identical). libctf/ * configure.ac: Always exclude libctf symbols from libctf-nobfd's version script. * configure: Regenerated.
-rwxr-xr-xlibctf/configure21
-rw-r--r--libctf/configure.ac21
2 files changed, 32 insertions, 10 deletions
diff --git a/libctf/configure b/libctf/configure
index 778c141..1faadef 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -16952,7 +16952,10 @@ fi
# Use a version script, if possible, or an -export-symbols-regex otherwise.
+# First figure out the version script flag: then massage the script, if
+# needed.
decommented_version_script=
+no_version_script=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for linker versioning flags" >&5
$as_echo_n "checking for linker versioning flags... " >&6; }
if ${ac_cv_libctf_version_script+:} false; then :
@@ -16969,7 +16972,7 @@ int ctf_foo (void) { return 0; }
int main (void) { return ctf_foo(); }
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_libctf_version_script="-Wl,--version-script='$srcdir/libctf.ver'"
+ ac_cv_libctf_version_script="-Wl,--version-script"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
@@ -16994,22 +16997,30 @@ rm -f core conftest.err conftest.$ac_objext \
if test -z "$ac_cv_libctf_version_script"; then
ac_cv_libctf_version_script='-export-symbols-regex ctf_.*'
+ no_version_script=t
fi
rm -f conftest.ver
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libctf_version_script" >&5
$as_echo "$ac_cv_libctf_version_script" >&6; }
+
+# 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 (Solaris)
+# add such symbols with type NOTYPE, and others (LLVM) complain loudly
+# and fail to link.
+grep -v 'libctf only' $srcdir/libctf.ver > libctf-nobfd.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
+ /lib/cpp < $srcdir/libctf-nobfd.ver > 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'"
+elif test -z "$no_version_script"; then
+ VERSION_FLAGS="$ac_cv_libctf_version_script='$srcdir/libctf.ver'"
+ VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script='libctf-nobfd.ver'"
else
VERSION_FLAGS="$ac_cv_libctf_version_script"
VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script"
diff --git a/libctf/configure.ac b/libctf/configure.ac
index f327d48..ced1aeb 100644
--- a/libctf/configure.ac
+++ b/libctf/configure.ac
@@ -249,7 +249,10 @@ fi
AC_SUBST(HAVE_TCL_TRY)
# Use a version script, if possible, or an -export-symbols-regex otherwise.
+# First figure out the version script flag: then massage the script, if
+# needed.
decommented_version_script=
+no_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"
@@ -258,7 +261,7 @@ AC_CACHE_CHECK([for linker versioning flags], [ac_cv_libctf_version_script],
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'"],
+ [ac_cv_libctf_version_script="-Wl,--version-script"],
[])
LDFLAGS="$old_LDFLAGS"
@@ -275,19 +278,27 @@ AC_CACHE_CHECK([for linker versioning flags], [ac_cv_libctf_version_script],
if test -z "$ac_cv_libctf_version_script"; then
ac_cv_libctf_version_script='-export-symbols-regex ctf_.*'
+ no_version_script=t
fi
rm -f conftest.ver])
+
+# 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 (Solaris)
+# add such symbols with type NOTYPE, and others (LLVM) complain loudly
+# and fail to link.
+grep -v 'libctf only' $srcdir/libctf.ver > libctf-nobfd.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
+ /lib/cpp < $srcdir/libctf-nobfd.ver > 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'"
+elif test -z "$no_version_script"; then
+ VERSION_FLAGS="$ac_cv_libctf_version_script='$srcdir/libctf.ver'"
+ VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script='libctf-nobfd.ver'"
else
VERSION_FLAGS="$ac_cv_libctf_version_script"
VERSION_FLAGS_NOBFD="$ac_cv_libctf_version_script"