public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/8] various build-system fixes and a coredump fix
@ 2021-09-13 15:58 Nick Alcock
  2021-09-13 15:58 ` [PATCH 1/8] libctf: link against libiberty before linking in libbfd or libctf-nobfd Nick Alcock
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

The non-libctf side of this was acked for binutils back in July;
the rest is entirely inside libctf/, but I'd be very happy for
others to look it over.

The pptrtab fix needs backporting to 2.36; the installation-time fixes probably
need applying all the way back to 2.34 if the users who reported the bugs are to
get the fix.  I'll do that if the trees are actually open for commits any
more... 2.34 was some time ago!

Nick Alcock (8):
  libctf: link against libiberty before linking in libbfd or
    libctf-nobfd
  libtool.m4: augment symcode for Solaris 11
  libtool.m4: fix nm BSD flag detection
  libctf: try several possibilities for linker versioning flags
  configure: regenerate in all projects that use libtool.m4
  libctf: fix handling of CTF symtypetab sections emitted by older GCC
  libctf, testsuite: fix various warnings in tests
  libctf, lookup: fix bounds of pptrtab lookup

 bfd/configure                                 |  91 +++++-----
 binutils/configure                            |  91 +++++-----
 gas/configure                                 |  91 +++++-----
 gprof/configure                               |  91 +++++-----
 ld/configure                                  |  91 +++++-----
 libctf/Makefile.am                            |  11 +-
 libctf/Makefile.in                            |  13 +-
 libctf/configure                              | 157 ++++++++++++------
 libctf/configure.ac                           |  46 ++++-
 libctf/ctf-lookup.c                           |   4 +-
 libctf/ctf-open.c                             |   7 +-
 libctf/libctf.ver                             |  10 +-
 .../libctf-lookup/conflicting-type-syms.c     |   3 -
 libctf/testsuite/libctf-lookup/enum-symbol.c  |   3 -
 .../nonstatic-var-section-ld-r.c              |   4 +-
 .../nonstatic-var-section-ld.c                |   4 +-
 .../nonstatic-var-section-ld.lk               |   2 +-
 libctf/testsuite/libctf-regression/pptrtab.c  |   1 -
 .../type-add-unnamed-struct.c                 |   2 -
 .../pptrtab-writable-page-deep-lookup.c       |  68 ++++++++
 .../pptrtab-writable-page-deep-lookup.lk      |   2 +
 libctf/testsuite/libctf-writable/pptrtab.c    |   2 +-
 .../reserialize-strtab-corruption.c           |   1 -
 .../symtypetab-nonlinker-writeout.c           |   6 +-
 libtool.m4                                    |  90 +++++-----
 opcodes/configure                             |  91 +++++-----
 sim/configure                                 |  91 +++++-----
 zlib/configure                                |  91 +++++-----
 28 files changed, 674 insertions(+), 490 deletions(-)
 create mode 100644 libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.c
 create mode 100644 libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.lk

-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/8] libctf: link against libiberty before linking in libbfd or libctf-nobfd
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:58 ` [PATCH 2/8] libtool.m4: augment symcode for Solaris 11 Nick Alcock
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

This ensures that the CTF_LIBADD, which always contains at least this
when doing a shared link:

-L`pwd`/../libiberty/pic -liberty

appears in the link line before any requirements pulled in by libbfd.la,
which include -liberty but because it is install-time do not include the
-L`pwd`/../libiberty/pic portion (in an indirect dep like this, the path
comes from the libbfd.la file, and is an install path).  libiberty also
appears after libbfd in the link line by virtue of libctf-nobfd.la,
because libctf-nobfd has to follow libbfd in the link line, and that
needs symbols from libiberty too.

Without this, an installed liberty might well be pulled in by libbfd,
and if --enable-install-libiberty is not specified this libiberty might
be completely incompatible with what is being installed and break either
or boht of libbfd and libctf. (The specific problem observed here is
that bsearch_r was not present, but other problems might easily be
observed in future too.)

Because ld links against libctf, this has a tendency to break the system
linker at install time too, if installing with --prefix=/usr.  That's
quite unpleasant to recover from.

libctf/ChangeLog
2021-06-12  Nick Alcock  <nick.alcock@oracle.com>

	PR libctf/27360
	* Makefile.am (libctf_la_LIBADD): Link against libiberty
	before pulling in libbfd.la or pulling in libctf-nobfd.la.
	* Makefile.in: Regenerate.
---
 libctf/Makefile.am | 6 +++++-
 libctf/Makefile.in | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libctf/Makefile.am b/libctf/Makefile.am
index 76881844798..970b66dc608 100644
--- a/libctf/Makefile.am
+++ b/libctf/Makefile.am
@@ -52,7 +52,11 @@ if NEED_CTF_QSORT_R
 libctf_nobfd_la_SOURCES += ctf-qsort_r.c
 endif
 
-libctf_la_LIBADD = ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
+# @CTF_LIBADD@ appears here twice: once, to force libiberty to get searched before
+# install-time libbfd adds a -L to the install dir (possibly pointing at an
+# incompatible libiberty), and once via lictf_nobfd_la_LIBADD so that the
+# references in there get picked up.
+libctf_la_LIBADD =  @CTF_LIBADD@ ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
 libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
 libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
 libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
diff --git a/libctf/Makefile.in b/libctf/Makefile.in
index bb3b88fc109..e8a1443ba28 100644
--- a/libctf/Makefile.in
+++ b/libctf/Makefile.in
@@ -476,7 +476,12 @@ libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c \
 	ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-dedup.c \
 	ctf-link.c ctf-lookup.c ctf-open.c ctf-serialize.c ctf-sha1.c \
 	ctf-string.c ctf-subr.c ctf-types.c ctf-util.c $(am__append_1)
-libctf_la_LIBADD = ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
+
+# @CTF_LIBADD@ appears here twice: once, to force libiberty to get searched before
+# install-time libbfd adds a -L to the install dir (possibly pointing at an
+# incompatible libiberty), and once via lictf_nobfd_la_LIBADD so that the
+# references in there get picked up.
+libctf_la_LIBADD = @CTF_LIBADD@ ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
 libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
 libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
 libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/8] libtool.m4: augment symcode for Solaris 11
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
  2021-09-13 15:58 ` [PATCH 1/8] libctf: link against libiberty before linking in libbfd or libctf-nobfd Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:58 ` [PATCH 3/8] libtool.m4: fix nm BSD flag detection Nick Alcock
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

This reports common symbols like GNU nm, via a type code of 'C'.

ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	PR libctf/27967
	* libtool.m4 (lt_cv_sys_global_symbol_pipe): Augment symcode for
	Solaris 11.
---
 libtool.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libtool.m4 b/libtool.m4
index f69fc99f691..7a711249304 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -3395,7 +3395,7 @@ osf*)
   symcode='[[BCDEGQRST]]'
   ;;
 solaris*)
-  symcode='[[BDRT]]'
+  symcode='[[BCDRT]]'
   ;;
 sco3.2v5*)
   symcode='[[DT]]'
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/8] libtool.m4: fix nm BSD flag detection
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
  2021-09-13 15:58 ` [PATCH 1/8] libctf: link against libiberty before linking in libbfd or libctf-nobfd Nick Alcock
  2021-09-13 15:58 ` [PATCH 2/8] libtool.m4: augment symcode for Solaris 11 Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:58 ` [PATCH 4/8] libctf: try several possibilities for linker versioning flags Nick Alcock
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

Libtool needs to get BSD-format (or MS-format) output out of the system
nm, so that it can scan generated object files for symbol names for
-export-symbols-regex support.  Some nms need specific flags to turn on
BSD-formatted output, so libtool checks for this in its AC_PATH_NM.
Unfortunately the code to do this has a pair of interlocking flaws:

 - it runs the test by doing an nm of /dev/null.  Some platforms
   reasonably refuse to do an nm on a device file, but before now this
   has only been worked around by assuming that the error message has a
   specific textual form emitted by Tru64 nm, and that getting this
   error means this is Tru64 nm and that nm -B would work to produce
   BSD-format output, even though the test never actually got anything
   but an error message out of nm -B.  This is fixable by nm'ing *nm
   itself* (since we necessarily have a path to it).

 - the test is entirely skipped if NM is set in the environment, on the
   grounds that the user has overridden the test: but the user cannot
   reasonably be expected to know that libtool wants not only nm but
   also flags forcing BSD-format output.  Worse yet, one such "user" is
   the top-level Cygnus configure script, which neither tests for
   nor specifies any BSD-format flags.  So platforms needing BSD-format
   flags always fail to set them when run in a Cygnus tree, breaking
   -export-symbols-regex on such platforms.  Libtool also needs to
   augment $LD on some platforms, but this is done unconditionally,
   augmenting whatever the user specified: the nm check should do the
   same.

   One wrinkle: if the user has overridden $NM, a path might have been
   provided: so we use the user-specified path if there was one, and
   otherwise do the path search as usual.  (If the nm specified doesn't
   work, this might lead to a few extra pointless path searches -- but
   the test is going to fail anyway, so that's not a problem.)

(Tested with NM unset, and set to nm, /usr/bin/nm, my-nm where my-nm is a
symlink to /usr/bin/nm on the PATH, and /not-on-the-path/my-nm where
*that* is a symlink to /usr/bin/nm.)

ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	PR libctf/27967
	* libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
	NM, if there is one.  Run nm on itself, not on /dev/null, to avoid
	errors from nms that refuse to work on non-regular files.  Remove
	other workarounds for this problem.  Strip out blank lines from the
	nm output.
---
 libtool.m4 | 88 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 45 insertions(+), 43 deletions(-)

diff --git a/libtool.m4 b/libtool.m4
index 7a711249304..a216bb14e99 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -3200,53 +3200,55 @@ _LT_DECL([], [file_magic_cmd], [1],
 
 # LT_PATH_NM
 # ----------
-# find the pathname to a BSD- or MS-compatible name lister
+# find the pathname to a BSD- or MS-compatible name lister, and any flags
+# needed to make it compatible
 AC_DEFUN([LT_PATH_NM],
 [AC_REQUIRE([AC_PROG_CC])dnl
 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
 [if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi])
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}])
 if test "$lt_cv_path_NM" != "no"; then
   NM="$lt_cv_path_NM"
 else
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/8] libctf: try several possibilities for linker versioning flags
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
                   ` (2 preceding siblings ...)
  2021-09-13 15:58 ` [PATCH 3/8] libtool.m4: fix nm BSD flag detection Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:58 ` [PATCH 5/8] configure: regenerate in all projects that use libtool.m4 Nick Alcock
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

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-06-22  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.
---
 libctf/Makefile.am  |  5 +++--
 libctf/configure.ac | 46 ++++++++++++++++++++++++++++++++++++++++++---
 libctf/libctf.ver   | 10 ++++------
 3 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/libctf/Makefile.am b/libctf/Makefile.am
index 970b66dc608..31fcb5d320a 100644
--- a/libctf/Makefile.am
+++ b/libctf/Makefile.am
@@ -42,7 +42,8 @@ noinst_LTLIBRARIES = libctf.la libctf-nobfd.la
 endif
 
 libctf_nobfd_la_LIBADD = @CTF_LIBADD@ $(ZLIB)
-libctf_nobfd_la_LDFLAGS = -version-info 0:0:0 @SHARED_LDFLAGS@ @VERSION_FLAGS@
+libctf_ldflags_nover = -version-info 0:0:0 @SHARED_LDFLAGS@
+libctf_nobfd_la_LDFLAGS = $(libctf_ldflags_nover) @VERSION_FLAGS_NOBFD@
 libctf_nobfd_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=1
 libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c ctf-decl.c ctf-error.c \
 			  ctf-hash.c ctf-labels.c ctf-dedup.c ctf-link.c ctf-lookup.c \
@@ -58,7 +59,7 @@ endif
 # references in there get picked up.
 libctf_la_LIBADD =  @CTF_LIBADD@ ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
 libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
-libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
+libctf_la_LDFLAGS = $(libctf_ldflags_nover) @VERSION_FLAGS@
 libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
 
 # Setup the testing framework, if you have one
diff --git a/libctf/configure.ac b/libctf/configure.ac
index 80644b89d67..4e12a4fa8f6 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)
diff --git a/libctf/libctf.ver b/libctf/libctf.ver
index 0b182f37228..602c13fba17 100644
--- a/libctf/libctf.ver
+++ b/libctf/libctf.ver
@@ -165,12 +165,10 @@ LIBCTF_1.0 {
 	ctf_link_shuffle_syms;
 	ctf_link_write;
 
-	/* In libctf alone.  */
-
-	ctf_fdopen;
-	ctf_open;
-	ctf_bfdopen;
-	ctf_bfdopen_ctfsect;
+	ctf_fdopen;                             /* libctf only.  */
+	ctf_open;                               /* libctf only.  */
+	ctf_bfdopen;                            /* libctf only.  */
+	ctf_bfdopen_ctfsect;                    /* libctf only.  */
     local:
 	*;
 };
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 5/8] configure: regenerate in all projects that use libtool.m4
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
                   ` (3 preceding siblings ...)
  2021-09-13 15:58 ` [PATCH 4/8] libctf: try several possibilities for linker versioning flags Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:58 ` [PATCH 6/8] libctf: fix handling of CTF symtypetab sections emitted by older GCC Nick Alcock
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

(including sim/, which has no changelog.)

bfd/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

binutils/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gas/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gprof/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

ld/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

libctf/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
	* Makefile.in: Regenerate.

opcodes/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

zlib/ChangeLog
2021-06-22  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
---
 bfd/configure      |  91 +++++++++++++-------------
 binutils/configure |  91 +++++++++++++-------------
 gas/configure      |  91 +++++++++++++-------------
 gprof/configure    |  91 +++++++++++++-------------
 ld/configure       |  91 +++++++++++++-------------
 libctf/Makefile.in |   6 +-
 libctf/configure   | 157 +++++++++++++++++++++++++++++++--------------
 opcodes/configure  |  91 +++++++++++++-------------
 sim/configure      |  91 +++++++++++++-------------
 zlib/configure     |  91 +++++++++++++-------------
 10 files changed, 481 insertions(+), 410 deletions(-)

diff --git a/bfd/configure b/bfd/configure
index cae69d413d4..2d89d9c9987 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -5360,48 +5360,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6560,7 +6561,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -11044,7 +11045,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11047 "configure"
+#line 11048 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11150,7 +11151,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11153 "configure"
+#line 11154 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/binutils/configure b/binutils/configure
index 29201153aeb..2cdaeae4e69 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -5216,48 +5216,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6416,7 +6417,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -10931,7 +10932,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10934 "configure"
+#line 10935 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11037,7 +11038,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11040 "configure"
+#line 11041 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gas/configure b/gas/configure
index a63c6ff0e39..bace2b2f39b 100755
--- a/gas/configure
+++ b/gas/configure
@@ -4941,48 +4941,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6141,7 +6142,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -10656,7 +10657,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10659 "configure"
+#line 10660 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10762,7 +10763,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10765 "configure"
+#line 10766 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gprof/configure b/gprof/configure
index f88c0ea48c3..a27f5111144 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -4843,48 +4843,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6043,7 +6044,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -10558,7 +10559,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10561 "configure"
+#line 10562 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10664,7 +10665,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10667 "configure"
+#line 10668 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/ld/configure b/ld/configure
index 6ea123b2a9e..a30f5155c4a 100755
--- a/ld/configure
+++ b/ld/configure
@@ -5696,48 +5696,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6896,7 +6897,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -11412,7 +11413,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11415 "configure"
+#line 11416 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11518,7 +11519,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11521 "configure"
+#line 11522 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libctf/Makefile.in b/libctf/Makefile.in
index e8a1443ba28..6d2d5360ed8 100644
--- a/libctf/Makefile.in
+++ b/libctf/Makefile.in
@@ -386,6 +386,7 @@ STRIP = @STRIP@
 USE_NLS = @USE_NLS@
 VERSION = @VERSION@
 VERSION_FLAGS = @VERSION_FLAGS@
+VERSION_FLAGS_NOBFD = @VERSION_FLAGS_NOBFD@
 WARN_PEDANTIC = @WARN_PEDANTIC@
 WERROR = @WERROR@
 XGETTEXT = @XGETTEXT@
@@ -470,7 +471,8 @@ AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @
 @INSTALL_LIBBFD_TRUE@include_HEADERS = $(INCDIR)/ctf.h $(INCDIR)/ctf-api.h
 @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libctf.la libctf-nobfd.la
 libctf_nobfd_la_LIBADD = @CTF_LIBADD@ $(ZLIB)
-libctf_nobfd_la_LDFLAGS = -version-info 0:0:0 @SHARED_LDFLAGS@ @VERSION_FLAGS@
+libctf_ldflags_nover = -version-info 0:0:0 @SHARED_LDFLAGS@
+libctf_nobfd_la_LDFLAGS = $(libctf_ldflags_nover) @VERSION_FLAGS_NOBFD@
 libctf_nobfd_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=1
 libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c \
 	ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-dedup.c \
@@ -483,7 +485,7 @@ libctf_nobfd_la_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c \
 # references in there get picked up.
 libctf_la_LIBADD = @CTF_LIBADD@ ../bfd/libbfd.la $(libctf_nobfd_la_LIBADD)
 libctf_la_CPPFLAGS = $(AM_CPPFLAGS) -DNOBFD=0
-libctf_la_LDFLAGS = $(libctf_nobfd_la_LDFLAGS)
+libctf_la_LDFLAGS = $(libctf_ldflags_nover) @VERSION_FLAGS@
 libctf_la_SOURCES = $(libctf_nobfd_la_SOURCES) ctf-open-bfd.c
 RUNTEST = runtest
 RUNTESTFLAGS = 
diff --git a/libctf/configure b/libctf/configure
index 38855e1172c..1bed5e178d9 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -635,6 +635,7 @@ ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+VERSION_FLAGS_NOBFD
 VERSION_FLAGS
 TCL_TRY_FALSE
 TCL_TRY_TRUE
@@ -5901,48 +5902,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -7101,7 +7103,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -11586,7 +11588,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11589 "configure"
+#line 11591 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11692,7 +11694,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11695 "configure"
+#line 11697 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13502,10 +13504,69 @@ fi
 
 
 # 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=
+{ $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 :
+  $as_echo_n "(cached) " >&6
+else
+  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"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+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'"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+   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"
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+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,-B,local -Wl,-z,gnu-version-script"
+		     decommented_version_script=t
 fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     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
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libctf_version_script" >&5
+$as_echo "$ac_cv_libctf_version_script" >&6; }
+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_config_files="$ac_config_files Makefile"
diff --git a/opcodes/configure b/opcodes/configure
index 9687cef4670..62d479fb499 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -5123,48 +5123,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6323,7 +6324,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -10808,7 +10809,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10811 "configure"
+#line 10812 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10914,7 +10915,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10917 "configure"
+#line 10918 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/sim/configure b/sim/configure
index 8a38f2e980a..dd4e4ee8141 100755
--- a/sim/configure
+++ b/sim/configure
@@ -5554,48 +5554,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -6796,7 +6797,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -12182,7 +12183,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12185 "configure"
+#line 12186 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12288,7 +12289,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12291 "configure"
+#line 12292 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/zlib/configure b/zlib/configure
index fb392d52365..0e7504e1a8b 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -4649,48 +4649,49 @@ if ${lt_cv_path_NM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
+   # Let the user override the nm to test.
+   lt_nm_to_check="$NM"
+ else
+   lt_nm_to_check="${ac_tool_prefix}nm"
+   if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+     lt_nm_to_check="$lt_nm_to_check nm"
+   fi
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+   lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+   for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+     IFS="$lt_save_ifs"
+     test -z "$ac_dir" && ac_dir=.
+     case "$lt_tmp_nm" in
+     */*|*\\*) tmp_nm="$lt_tmp_nm";;
+     *) tmp_nm="$ac_dir/$lt_tmp_nm";;
+     esac
+     if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+       # Check to see if the nm accepts a BSD-compat flag.
+       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+       #   nm: unknown option "B" ignored
+       case `"$tmp_nm" -B "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+       *$tmp_nm*) lt_cv_path_NM="$tmp_nm -B"
+	 break
+	 ;;
+       *)
+	 case `"$tmp_nm" -p "$tmp_nm" 2>&1 | grep -v '^ *$' | sed '1q'` in
+	 *$tmp_nm*)
+	   lt_cv_path_NM="$tmp_nm -p"
+	   break
+	   ;;
+	 *)
+	   lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	   continue # so that we can try to find one that supports BSD flags
+	   ;;
+	 esac
+	 ;;
+       esac
+     fi
+   done
+   IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
 $as_echo "$lt_cv_path_NM" >&6; }
@@ -5849,7 +5850,7 @@ osf*)
   symcode='[BCDEGQRST]'
   ;;
 solaris*)
-  symcode='[BDRT]'
+  symcode='[BCDRT]'
   ;;
 sco3.2v5*)
   symcode='[DT]'
@@ -10665,7 +10666,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10668 "configure"
+#line 10669 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10771,7 +10772,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10774 "configure"
+#line 10775 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 6/8] libctf: fix handling of CTF symtypetab sections emitted by older GCC
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
                   ` (4 preceding siblings ...)
  2021-09-13 15:58 ` [PATCH 5/8] configure: regenerate in all projects that use libtool.m4 Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:58 ` [PATCH 7/8] libctf, testsuite: fix various warnings in tests Nick Alcock
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

Older (pre-upstreaming) GCC emits a function symtypetab section of a
format never read by any extant libctf.  We can detect such CTF dicts by
the lack of the CTF_F_NEWFUNCINFO flag in their header, and we do so
when reading in the symtypetab section -- but if the set of symbols with
types is sufficiently sparse, even an older GCC will emit a function
index section.

In NEWFUNCINFO-capable compilers, this section will always be the exact
same length as the corresponding function section (each is an array of
uint32_t, associated 1:1 with each other). But this is not true for the
older compiler, for which the sections are different lengths.  We check
to see if the function symtypetab section and its index are the same
length, but we fail to skip this check when this is not a NEWFUNCINFO
dict, and emit a spurious corruption error for a CTF dict we could
have perfectly well opened and used.

Fix trivial: check the flag (and fix the terrible grammar of the error
message at the same time).

libctf/ChangeLog
2021-06-16  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-open.c (ctf_bufopen_internal): Don't complain about corrupt
	function index symtypetab sections if this is an old-format
	function symtypetab section (which should be ignored in any case).
	Fix bad grammar.
---
 libctf/ctf-open.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 9e2c57051af..caeff06425a 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -1449,7 +1449,7 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
        != hp->cth_funcoff - hp->cth_objtoff))
     {
       ctf_err_warn (NULL, 0, ECTF_CORRUPT,
-		    _("Object index section exists is neither empty nor the "
+		    _("Object index section is neither empty nor the "
 		      "same length as the object section: %u versus %u "
 		      "bytes"), hp->cth_funcoff - hp->cth_objtoff,
 		    hp->cth_funcidxoff - hp->cth_objtidxoff);
@@ -1458,10 +1458,11 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
 
   if ((hp->cth_varoff - hp->cth_funcidxoff != 0) &&
       (hp->cth_varoff - hp->cth_funcidxoff
-       != hp->cth_objtidxoff - hp->cth_funcoff))
+       != hp->cth_objtidxoff - hp->cth_funcoff) &&
+      (hp->cth_flags & CTF_F_NEWFUNCINFO))
     {
       ctf_err_warn (NULL, 0, ECTF_CORRUPT,
-		    _("Function index section exists is neither empty nor the "
+		    _("Function index section is neither empty nor the "
 		      "same length as the function section: %u versus %u "
 		      "bytes"), hp->cth_objtidxoff - hp->cth_funcoff,
 		    hp->cth_varoff - hp->cth_funcidxoff);
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 7/8] libctf, testsuite: fix various warnings in tests
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
                   ` (5 preceding siblings ...)
  2021-09-13 15:58 ` [PATCH 6/8] libctf: fix handling of CTF symtypetab sections emitted by older GCC Nick Alcock
@ 2021-09-13 15:58 ` Nick Alcock
  2021-09-13 15:59 ` [PATCH 8/8] libctf, lookup: fix bounds of pptrtab lookup Nick Alcock
  2021-09-15  2:20 ` [PATCH 0/8] various build-system fixes and a coredump fix Alan Modra
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:58 UTC (permalink / raw)
  To: binutils

These warnings are all off by default, but if they do fire you get
spurious ERRORs when running make check-libctf.

libctf/ChangeLog
2021-06-16  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/libctf-lookup/enum-symbol.c: Remove unused label.
	* testsuite/libctf-lookup/conflicting-type-syms.c: Remove unused
	variables.
	* testsuite/libctf-regression/pptrtab.c: Likewise.
	* testsuite/libctf-regression/type-add-unnamed-struct.c: Likewise.
	* testsuite/libctf-writable/pptrtab.c: Likewise.
	* testsuite/libctf-writable/reserialize-strtab-corruption.c:
	Likewise.
	* testsuite/libctf-regression/nonstatic-var-section-ld-r.c: Fix
	format string.
	* testsuite/libctf-regression/nonstatic-var-section-ld.c:
	Likewise.
	* testsuite/libctf-regression/nonstatic-var-section-ld.lk: Adjust.
	* testsuite/libctf-writable/symtypetab-nonlinker-writeout.c: Fix
	initializer.
---
 libctf/testsuite/libctf-lookup/conflicting-type-syms.c      | 3 ---
 libctf/testsuite/libctf-lookup/enum-symbol.c                | 3 ---
 .../libctf-regression/nonstatic-var-section-ld-r.c          | 4 ++--
 .../testsuite/libctf-regression/nonstatic-var-section-ld.c  | 4 ++--
 .../testsuite/libctf-regression/nonstatic-var-section-ld.lk | 2 +-
 libctf/testsuite/libctf-regression/pptrtab.c                | 1 -
 .../testsuite/libctf-regression/type-add-unnamed-struct.c   | 2 --
 libctf/testsuite/libctf-writable/pptrtab.c                  | 2 +-
 .../libctf-writable/reserialize-strtab-corruption.c         | 1 -
 .../libctf-writable/symtypetab-nonlinker-writeout.c         | 6 ++++--
 10 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/libctf/testsuite/libctf-lookup/conflicting-type-syms.c b/libctf/testsuite/libctf-lookup/conflicting-type-syms.c
index ffe6983e250..239b8775964 100644
--- a/libctf/testsuite/libctf-lookup/conflicting-type-syms.c
+++ b/libctf/testsuite/libctf-lookup/conflicting-type-syms.c
@@ -12,9 +12,6 @@ main (int argc, char *argv[])
   int err;
   ctf_id_t a, b, ignore1, ignore2, tmp;
   char *foo;
-  ctf_next_t *i = NULL;
-  const char *name;
-  int val;
 
   if (argc != 2)
     {
diff --git a/libctf/testsuite/libctf-lookup/enum-symbol.c b/libctf/testsuite/libctf-lookup/enum-symbol.c
index c67478fe780..1244c900434 100644
--- a/libctf/testsuite/libctf-lookup/enum-symbol.c
+++ b/libctf/testsuite/libctf-lookup/enum-symbol.c
@@ -57,9 +57,6 @@ main (int argc, char *argv[])
   fprintf (stderr, "%s: Symbol re-lookup error (caching bug): %s\n", argv[0],
 	   ctf_errmsg (err));
   return 1;
- err:
-  fprintf (stderr, "Lookup failed: %s\n", ctf_errmsg (ctf_errno (fp)));
-  return 1;
  nerr:
   fprintf (stderr, "iteration failed: %s\n", ctf_errmsg (ctf_errno (fp)));
   return 1;
diff --git a/libctf/testsuite/libctf-regression/nonstatic-var-section-ld-r.c b/libctf/testsuite/libctf-regression/nonstatic-var-section-ld-r.c
index 2fa761a1d03..6ae2ea53042 100644
--- a/libctf/testsuite/libctf-regression/nonstatic-var-section-ld-r.c
+++ b/libctf/testsuite/libctf-regression/nonstatic-var-section-ld-r.c
@@ -31,12 +31,12 @@ main (int argc, char *argv[])
      ld -r link.  */
 
   if ((foo_type = ctf_lookup_variable (fp, "foo")) == CTF_ERR)
-    printf ("Cannot look up foo\n", ctf_errmsg (ctf_errno (fp)));
+    printf ("Cannot look up foo: %s\n", ctf_errmsg (ctf_errno (fp)));
   else
     printf ("foo is of type %lx\n", foo_type);
 
   if ((bar_type = ctf_lookup_variable (fp, "bar")) == CTF_ERR)
-    printf ("Cannot look up bar\n", ctf_errmsg (ctf_errno (fp)));
+    printf ("Cannot look up bar: %s\n", ctf_errmsg (ctf_errno (fp)));
   else
     printf ("bar is of type %lx\n", bar_type);
 
diff --git a/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.c b/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.c
index 4e3a74842b2..93988eb1e8d 100644
--- a/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.c
+++ b/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.c
@@ -30,12 +30,12 @@ main (int argc, char *argv[])
      should have been erased.  */
 
   if ((foo_type = ctf_lookup_variable (fp, "foo")) == CTF_ERR)
-    printf ("Cannot look up foo\n", ctf_errmsg (ctf_errno (fp)));
+    printf ("Cannot look up foo: %s\n", ctf_errmsg (ctf_errno (fp)));
   else
     printf ("foo is of type %lx\n", foo_type);
 
   if ((bar_type = ctf_lookup_variable (fp, "bar")) == CTF_ERR)
-    printf ("Cannot look up bar\n", ctf_errmsg (ctf_errno (fp)));
+    printf ("Cannot look up bar: %s\n", ctf_errmsg (ctf_errno (fp)));
   else
     printf ("bar is of type %lx\n", bar_type);
 
diff --git a/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.lk b/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.lk
index edb397a333a..2ea4d323bfc 100644
--- a/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.lk
+++ b/libctf/testsuite/libctf-regression/nonstatic-var-section-ld.lk
@@ -2,5 +2,5 @@
 # link: on
 # link_flags: -Wl,--ctf-variables
 foo is of type [0-9a-f]*
-Cannot look up bar
+Cannot look up bar: No type information available for symbol.
 foo missing from the data object section
diff --git a/libctf/testsuite/libctf-regression/pptrtab.c b/libctf/testsuite/libctf-regression/pptrtab.c
index fe1b8fe2b43..2ef5f9c5cc0 100644
--- a/libctf/testsuite/libctf-regression/pptrtab.c
+++ b/libctf/testsuite/libctf-regression/pptrtab.c
@@ -10,7 +10,6 @@ main (int argc, char *argv[])
   ctf_next_t *i = NULL;
   ctf_id_t type;
   const char *arcname;
-  char *type_name;
   int err;
 
   if (argc != 2)
diff --git a/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c b/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c
index 16ff0948b17..cf10804814c 100644
--- a/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c
+++ b/libctf/testsuite/libctf-regression/type-add-unnamed-struct.c
@@ -8,10 +8,8 @@ main (int argc, char *argv[])
   ctf_dict_t *fp;
   ctf_archive_t *ctf;
   ctf_dict_t *dyn;
-  ctf_next_t *i = NULL;
   ctf_id_t type;
   ctf_id_t newtype;
-  const char *memb;
   ctf_membinfo_t mi;
   const char *membs[] = { "bar", "baz", "foo", NULL };
   const char **walk;
diff --git a/libctf/testsuite/libctf-writable/pptrtab.c b/libctf/testsuite/libctf-writable/pptrtab.c
index 68c356352d7..b8d1e63b997 100644
--- a/libctf/testsuite/libctf-writable/pptrtab.c
+++ b/libctf/testsuite/libctf-writable/pptrtab.c
@@ -7,7 +7,7 @@ main (int argc, char *argv[])
 {
   ctf_dict_t *pfp;
   ctf_dict_t *cfp;
-  ctf_id_t base, base2, ptr, ptr2, type, last_type;
+  ctf_id_t base, base2, ptr, type, last_type;
   ctf_encoding_t encoding = { CTF_INT_SIGNED, 0, sizeof (int) };
   ctf_encoding_t encoding2 = { CTF_INT_SIGNED, 0, sizeof (long) };
   char *type_name;
diff --git a/libctf/testsuite/libctf-writable/reserialize-strtab-corruption.c b/libctf/testsuite/libctf-writable/reserialize-strtab-corruption.c
index 1593325da77..2c9ec8d9ed2 100644
--- a/libctf/testsuite/libctf-writable/reserialize-strtab-corruption.c
+++ b/libctf/testsuite/libctf-writable/reserialize-strtab-corruption.c
@@ -13,7 +13,6 @@ main (int argc, char *argv[])
   ctf_snapshot_id_t snap;
   unsigned char *foo;
   size_t foo_size;
-  const char *bar;
   int err;
   char name[64];
 
diff --git a/libctf/testsuite/libctf-writable/symtypetab-nonlinker-writeout.c b/libctf/testsuite/libctf-writable/symtypetab-nonlinker-writeout.c
index bdc3faa944c..7a2b88d6dfa 100644
--- a/libctf/testsuite/libctf-writable/symtypetab-nonlinker-writeout.c
+++ b/libctf/testsuite/libctf-writable/symtypetab-nonlinker-writeout.c
@@ -174,10 +174,12 @@ try_maybe_reporting (int report)
   } *expected;
   struct ctf_symtype_expected expected_obj[] = { { "data_a", base2 },
 						 { "data_b", base3 },
-						 { "data_c", base }, NULL };
+						 { "data_c", base },
+						 { NULL, 0 } };
   struct ctf_symtype_expected expected_func[] = { { "func_a", func2 },
 						  { "func_b", func3 },
-						  { "func_c", func }, NULL };
+						  { "func_c", func },
+						  { NULL, 0 } };
   expected = expected_obj;
 
   while ((symtype = ctf_symbol_next (fp, &i, &symname, 0)) != CTF_ERR)
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 8/8] libctf, lookup: fix bounds of pptrtab lookup
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
                   ` (6 preceding siblings ...)
  2021-09-13 15:58 ` [PATCH 7/8] libctf, testsuite: fix various warnings in tests Nick Alcock
@ 2021-09-13 15:59 ` Nick Alcock
  2021-09-15  2:20 ` [PATCH 0/8] various build-system fixes and a coredump fix Alan Modra
  8 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-13 15:59 UTC (permalink / raw)
  To: binutils

An off-by-one bug in the check for pptrtab lookup meant that we could
access the pptrtab past its bounds (*well* past its bounds),
particularly if we called ctf_lookup_by_name in a child dict with "*foo"
where "foo" is a type that exists in the parent but not the child and no
previous lookups by name have been carried out.  (Note that "*foo" is
not even a valid thing to call ctf_lookup_by_name with: foo * is.
Nonetheless, users sometimes do call ctf_lookup_by_name with invalid
content, and it should return ECTF_NOTYPE, not crash.)

ctf_pptrtab_len, as its name suggests (and as other tests of it in
ctf-lookup.c confirm), is one higher than the maximum valid permissible
index, so the comparison is wrong.

(Test added, which should fail pretty reliably in the presence of this
bug on any machine with 4KiB pages.)

libctf/ChangeLog
2021-09-08  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-lookup.c (ctf_lookup_by_name_internal): Fix pptrtab bounds.
	* testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.*:
	New test.
---
 libctf/ctf-lookup.c                           |  4 +-
 .../pptrtab-writable-page-deep-lookup.c       | 68 +++++++++++++++++++
 .../pptrtab-writable-page-deep-lookup.lk      |  2 +
 3 files changed, 72 insertions(+), 2 deletions(-)
 create mode 100644 libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.c
 create mode 100644 libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.lk

diff --git a/libctf/ctf-lookup.c b/libctf/ctf-lookup.c
index fe66bc4c00c..d1828f8e15a 100644
--- a/libctf/ctf-lookup.c
+++ b/libctf/ctf-lookup.c
@@ -176,7 +176,7 @@ ctf_lookup_by_name_internal (ctf_dict_t *fp, ctf_dict_t *child,
 	  int in_child = 0;
 
 	  ntype = CTF_ERR;
-	  if (child && idx <= child->ctf_pptrtab_len)
+	  if (child && idx < child->ctf_pptrtab_len)
 	    {
 	      ntype = child->ctf_pptrtab[idx];
 	      if (ntype)
@@ -206,7 +206,7 @@ ctf_lookup_by_name_internal (ctf_dict_t *fp, ctf_dict_t *child,
 	      idx = LCTF_TYPE_TO_INDEX (fp, ntype);
 
 	      ntype = CTF_ERR;
-	      if (child && idx <= child->ctf_pptrtab_len)
+	      if (child && idx < child->ctf_pptrtab_len)
 		{
 		  ntype = child->ctf_pptrtab[idx];
 		  if (ntype)
diff --git a/libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.c b/libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.c
new file mode 100644
index 00000000000..ca42065a872
--- /dev/null
+++ b/libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.c
@@ -0,0 +1,68 @@
+/* Make sure we can look up a pointer-to-type where the type is more than a page
+   into the parent and the child has never had a lookup before.  */
+
+#include <ctf-api.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (void)
+{
+  ctf_dict_t *pfp, *cfp;
+  ctf_encoding_t e = { CTF_INT_SIGNED, 0, sizeof (long) };
+  ctf_id_t ptype, ptrtype, type, foo;
+  size_t i;
+  int err;
+
+  if ((pfp = ctf_create (&err)) == NULL)
+    goto create_err;
+
+  if ((ptype = ctf_add_integer (pfp, CTF_ADD_NONROOT, "blah", &e)) == CTF_ERR)
+    goto create_parent;
+
+  for (i = 0; i < 4096; i++)
+    if ((foo = ctf_add_pointer (pfp, CTF_ADD_NONROOT, ptype)) == CTF_ERR)
+      goto create_parent;
+
+  if ((cfp = ctf_create (&err)) == NULL)
+    goto create_err;
+
+  if (ctf_import (cfp, pfp) < 0)
+    goto create_child;
+
+  if ((ptype = ctf_add_integer (pfp, CTF_ADD_ROOT, "foo", &e)) == CTF_ERR)
+    goto create_parent;
+
+  if ((ptrtype = ctf_add_pointer (pfp, CTF_ADD_ROOT, ptype)) == CTF_ERR)
+    goto create_parent;
+
+  if ((type = ctf_lookup_by_name (cfp, "*foo")) != CTF_ERR)
+    {
+      fprintf (stderr, "Type lookup unexpectedly succeeded: %s\n", ctf_errmsg (ctf_errno (cfp)));
+      exit (1);
+    }
+
+  if ((type = ctf_lookup_by_name (cfp, "foo *")) == CTF_ERR)
+    {
+      fprintf (stderr, "Type lookup error: %s\n", ctf_errmsg (ctf_errno (cfp)));
+      exit (1);
+    }
+
+  ctf_dict_close (cfp);
+  ctf_dict_close (pfp);
+
+  printf ("Type lookup succeeded.\n");
+
+  return 0;
+
+ create_err:
+  fprintf (stderr, "Creation failed: %s\n", ctf_errmsg (err));
+  exit (1);
+ create_parent:
+  fprintf (stderr, "Cannot create parent type: %s\n", ctf_errmsg (ctf_errno (pfp)));
+  exit (1);
+ create_child:
+  fprintf (stderr, "Cannot create child type: %s\n", ctf_errmsg (ctf_errno (cfp)));
+  exit (1);
+}
diff --git a/libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.lk b/libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.lk
new file mode 100644
index 00000000000..4f23d14d63e
--- /dev/null
+++ b/libctf/testsuite/libctf-writable/pptrtab-writable-page-deep-lookup.lk
@@ -0,0 +1,2 @@
+Type lookup succeeded.
+
-- 
2.33.0.256.gb827f06fa9


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] various build-system fixes and a coredump fix
  2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
                   ` (7 preceding siblings ...)
  2021-09-13 15:59 ` [PATCH 8/8] libctf, lookup: fix bounds of pptrtab lookup Nick Alcock
@ 2021-09-15  2:20 ` Alan Modra
  2021-09-15 22:13   ` Nick Alcock
  8 siblings, 1 reply; 13+ messages in thread
From: Alan Modra @ 2021-09-15  2:20 UTC (permalink / raw)
  To: Nick Alcock; +Cc: binutils

On Mon, Sep 13, 2021 at 04:58:52PM +0100, Nick Alcock via Binutils wrote:
> The pptrtab fix needs backporting to 2.36; the installation-time fixes probably
> need applying all the way back to 2.34 if the users who reported the bugs are to
> get the fix.  I'll do that if the trees are actually open for commits any
> more... 2.34 was some time ago!

They are open, but don't feel that you need to backport that far just
because a user reported a problem on an old release.  It is probably
better for the project as a whole to encourage people to update to a
newer release.  (I'm not saying don't backport to 2.34, that's
entirely up to you.)

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] various build-system fixes and a coredump fix
  2021-09-15  2:20 ` [PATCH 0/8] various build-system fixes and a coredump fix Alan Modra
@ 2021-09-15 22:13   ` Nick Alcock
  2021-09-27  9:52     ` Nick Alcock
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Alcock @ 2021-09-15 22:13 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On 15 Sep 2021, Alan Modra uttered the following:

> On Mon, Sep 13, 2021 at 04:58:52PM +0100, Nick Alcock via Binutils wrote:
>> The pptrtab fix needs backporting to 2.36; the installation-time fixes probably
>> need applying all the way back to 2.34 if the users who reported the bugs are to
>> get the fix.  I'll do that if the trees are actually open for commits any
>> more... 2.34 was some time ago!
>
> They are open, but don't feel that you need to backport that far just
> because a user reported a problem on an old release.  It is probably
> better for the project as a whole to encourage people to update to a
> newer release.  (I'm not saying don't backport to 2.34, that's
> entirely up to you.)

I'll see how much work it is. Running tests is cheap!

(... slight delay pushing because it's possible my pptrtab fix is
possibly incomplete after all: the coredumps it was meant to fix have
come back, so maybe there is another cause of a coredump in there,
hiding behind the first one. Really ctf_lookup_by_name is and always was
an underspecified and tangled mess, with something like three nasty bugs
so far as a direct result. I've added rewriting it to my todo list.)

-- 
NULL && (void)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] various build-system fixes and a coredump fix
  2021-09-15 22:13   ` Nick Alcock
@ 2021-09-27  9:52     ` Nick Alcock
  2021-09-27 19:35       ` Nick Alcock
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Alcock @ 2021-09-27  9:52 UTC (permalink / raw)
  To: binutils

On 15 Sep 2021, Nick Alcock via Binutils verbalised:
> (... slight delay pushing because it's possible my pptrtab fix is
> possibly incomplete after all: the coredumps it was meant to fix have
> come back, so maybe there is another cause of a coredump in there,

Nope. This is just me failing to do a make install before running the
$other_program tests that were still coredumping, and then doing a make
install and failing to rerun ldconfig, and then doing that and failing
to make sure there weren't older libctf.so's earlier on the linker
search path. i.e. every rookie error you could imagine.

Will do a bunch of retesting, since it *has* been a week, then push
later today and look into getting those libtool fixes upstream too.

-- 
NULL && (void)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] various build-system fixes and a coredump fix
  2021-09-27  9:52     ` Nick Alcock
@ 2021-09-27 19:35       ` Nick Alcock
  0 siblings, 0 replies; 13+ messages in thread
From: Nick Alcock @ 2021-09-27 19:35 UTC (permalink / raw)
  To: binutils

On 27 Sep 2021, Nick Alcock via Binutils spake thusly:
> Will do a bunch of retesting, since it *has* been a week, then push
> later today and look into getting those libtool fixes upstream too.

This is now pushed to master after testing everywhere I could think of,
including Solaris 11.4, 11.3 and SPARC-based Linux boxes as well as
FreeBSD and the rest of my usual usual test matrix. Anyone experiencing
problems, particularly with libtool etc, please do let me know. If
nobody is too unhappy with it I'll push it back at least to the 2.37
branch.

(well, pushed after a boo-boo in which, for the first time ever, I got
local and remote branch names backwards in git push. Sigh. A branch
"oracle/ctf-next" very briefly appeared in the repo as a result.
Apologies.)

-- 
NULL && (void)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-09-27 19:35 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 15:58 [PATCH 0/8] various build-system fixes and a coredump fix Nick Alcock
2021-09-13 15:58 ` [PATCH 1/8] libctf: link against libiberty before linking in libbfd or libctf-nobfd Nick Alcock
2021-09-13 15:58 ` [PATCH 2/8] libtool.m4: augment symcode for Solaris 11 Nick Alcock
2021-09-13 15:58 ` [PATCH 3/8] libtool.m4: fix nm BSD flag detection Nick Alcock
2021-09-13 15:58 ` [PATCH 4/8] libctf: try several possibilities for linker versioning flags Nick Alcock
2021-09-13 15:58 ` [PATCH 5/8] configure: regenerate in all projects that use libtool.m4 Nick Alcock
2021-09-13 15:58 ` [PATCH 6/8] libctf: fix handling of CTF symtypetab sections emitted by older GCC Nick Alcock
2021-09-13 15:58 ` [PATCH 7/8] libctf, testsuite: fix various warnings in tests Nick Alcock
2021-09-13 15:59 ` [PATCH 8/8] libctf, lookup: fix bounds of pptrtab lookup Nick Alcock
2021-09-15  2:20 ` [PATCH 0/8] various build-system fixes and a coredump fix Alan Modra
2021-09-15 22:13   ` Nick Alcock
2021-09-27  9:52     ` Nick Alcock
2021-09-27 19:35       ` Nick Alcock

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).