public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4 REVIEW] libtool and libctf fixes for Solaris 11
@ 2021-06-25 16:13 Nick Alcock
  2021-06-25 16:13 ` [PATCH 1/4] libtool.m4: augment symcode " Nick Alcock
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Nick Alcock @ 2021-06-25 16:13 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches

There are three intertwined bugs here, two in libtool.m4, one in libctf.
The underlying "problem" is that libctf tries to version its symbols: if
it can't use a GNU version script it tries to hide unnecessary symbols
using Libtool's --export-symbols-regex flag... and that flag has kinda
rusted.

Firstly, it relies on running nm and knowing what the symbol type codes
it emits (in BSD mode) mean: Solaris 11 has gained 'C' for common
symbols, like GNU nm, but libtool.m4 was never updated to know about
that, so the test failed.

Secondly, it relies on knowing how to switch nm into BSD mode, which it
does by nm'ing a bunch of candidate nms with various flags: but it nms
/dev/null and has not-very-good handling of nms that emit errors if you
do that.

Thirdly, libtool's nm option scanning is entirely suppressed if NM is
set in the environment, on the grounds that the user must have set it --
but libtool already augments other things set in the environment with
extra flags if needed, and the user can hardly be expected to know that
Libtool needs 'nm -p' on Solaris, not just nm. Worse yet, Cygnus
configure sets NM unconditionally, stopping the test dead.  Fixed by
checking flags even if the user overrides nm, but checking the specific
nm they requested.

The first two patches in this series need review because, well, libtool
upstream is dead enough that I don't know if I can even submit it there,
but it should probably go to GCC and binutils-gdb. I have tested it on
Solaris 11.3, Solaris 11.4, FreeBSD, (x86-64 and SPARC) Linux, and
Cygwin, which should be enough coverage, I hope.  libtool upstream has
diverged in this area and the patch would need redoing in any case
(though the conflicts look quite minor, I don't have time right now and
doing that wouldn't help fix any of the reporter's problems in any case).

(The latter two patches, sent to binutils@ alone, enable symbol
versioning on Solaris 11.4, which provides a --version-script flag
almost but not quite compatible with GNU ld's, and regenerate most
relevant configure scripts, skipping only sim/ because it's in a ferment
of change right now.)

Cc: gcc-patches@gcc.gnu.org

Nick Alcock (4):
  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

 bfd/configure       |  91 ++++++++++++-------------
 binutils/configure  |  91 ++++++++++++-------------
 gas/configure       |  91 ++++++++++++-------------
 gprof/configure     |  91 ++++++++++++-------------
 ld/configure        |  91 ++++++++++++-------------
 libctf/Makefile.am  |   5 +-
 libctf/Makefile.in  |   6 +-
 libctf/configure    | 157 ++++++++++++++++++++++++++++++--------------
 libctf/configure.ac |  46 ++++++++++++-
 libctf/libctf.ver   |  10 ++-
 libtool.m4          |  90 ++++++++++++-------------
 opcodes/configure   |  91 ++++++++++++-------------
 zlib/configure      |  91 ++++++++++++-------------
 13 files changed, 531 insertions(+), 420 deletions(-)

-- 
2.32.0.255.gd9b1d14a2a


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

* [PATCH 1/4] libtool.m4: augment symcode for Solaris 11
  2021-06-25 16:13 [PATCH 0/4 REVIEW] libtool and libctf fixes for Solaris 11 Nick Alcock
@ 2021-06-25 16:13 ` Nick Alcock
  2021-06-25 16:13 ` [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection Nick Alcock
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Nick Alcock @ 2021-06-25 16:13 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches

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

Cc: gcc-patches@gcc.gnu.org

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 9a13f3b117a..b0a56917497 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -3395,7 +3395,7 @@ osf*)
   symcode='[[BCDEGQRST]]'
   ;;
 solaris*)
-  symcode='[[BDRT]]'
+  symcode='[[BCDRT]]'
   ;;
 sco3.2v5*)
   symcode='[[DT]]'
-- 
2.32.0.255.gd9b1d14a2a


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

* [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection
  2021-06-25 16:13 [PATCH 0/4 REVIEW] libtool and libctf fixes for Solaris 11 Nick Alcock
  2021-06-25 16:13 ` [PATCH 1/4] libtool.m4: augment symcode " Nick Alcock
@ 2021-06-25 16:13 ` Nick Alcock
  2021-07-06 19:37   ` Nick Alcock
  2021-06-25 16:13 ` [PATCH 3/4] libctf: try several possibilities for linker versioning flags Nick Alcock
  2021-06-25 16:13 ` [PATCH 4/4] configure: regenerate in all projects that use libtool.m4 Nick Alcock
  3 siblings, 1 reply; 10+ messages in thread
From: Nick Alcock @ 2021-06-25 16:13 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches

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

Cc: gcc-patches@gcc.gnu.org

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

	PR libctf/27482
	* 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 b0a56917497..29dce1f8239 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.32.0.255.gd9b1d14a2a


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

* [PATCH 3/4] libctf: try several possibilities for linker versioning flags
  2021-06-25 16:13 [PATCH 0/4 REVIEW] libtool and libctf fixes for Solaris 11 Nick Alcock
  2021-06-25 16:13 ` [PATCH 1/4] libtool.m4: augment symcode " Nick Alcock
  2021-06-25 16:13 ` [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection Nick Alcock
@ 2021-06-25 16:13 ` Nick Alcock
  2021-06-25 16:13 ` [PATCH 4/4] configure: regenerate in all projects that use libtool.m4 Nick Alcock
  3 siblings, 0 replies; 10+ messages in thread
From: Nick Alcock @ 2021-06-25 16:13 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/27482
	* 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 308daa9a03c..38d86bc4f9d 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.32.0.255.gd9b1d14a2a


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

* [PATCH 4/4] configure: regenerate in all projects that use libtool.m4
  2021-06-25 16:13 [PATCH 0/4 REVIEW] libtool and libctf fixes for Solaris 11 Nick Alcock
                   ` (2 preceding siblings ...)
  2021-06-25 16:13 ` [PATCH 3/4] libctf: try several possibilities for linker versioning flags Nick Alcock
@ 2021-06-25 16:13 ` Nick Alcock
  3 siblings, 0 replies; 10+ messages in thread
From: Nick Alcock @ 2021-06-25 16:13 UTC (permalink / raw)
  To: binutils

sim/ is skipped because of the ongoing sim-unification: it's sure to get
reautoconfed soon anyway.

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 +++++++++++++-------------
 zlib/configure     |  91 +++++++++++++-------------
 9 files changed, 435 insertions(+), 365 deletions(-)

diff --git a/bfd/configure b/bfd/configure
index d98e330df8b..a2fc50fd61f 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 1f855268c6f..75291f5f21a 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 7a67ce8bd6b..217156c6e55 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 7f39d609287..35786629f28 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 d8f8b2de18e..d58915928e3 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 b594a3e1362..c97e641b437 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 82bcf13a606..cb55fab9900 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 470231ebc80..2e861c9246f 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/zlib/configure b/zlib/configure
index 695819cd54b..f3f1bc887b2 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.32.0.255.gd9b1d14a2a


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

* Re: [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection
  2021-06-25 16:13 ` [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection Nick Alcock
@ 2021-07-06 19:37   ` Nick Alcock
  2021-07-07 14:39     ` Nick Clifton
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Alcock @ 2021-07-06 19:37 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches

Ping?

On 25 Jun 2021, Nick Alcock via Binutils said this:

> 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.)
>
> Cc: gcc-patches@gcc.gnu.org
>
> ChangeLog
> 2021-06-22  Nick Alcock  <nick.alcock@oracle.com>
>
> 	PR libctf/27482
> 	* 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 b0a56917497..29dce1f8239 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

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

* Re: [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection
  2021-07-06 19:37   ` Nick Alcock
@ 2021-07-07 14:39     ` Nick Clifton
  2021-07-07 19:03       ` Nick Alcock
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Clifton @ 2021-07-07 14:39 UTC (permalink / raw)
  To: Nick Alcock, binutils; +Cc: gcc-patches

Hi Nick,

> Ping?

Oops.

>> 	PR libctf/27482
>> 	* libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided

Changes to libtool need to be posted to the libtool project:

   https://www.gnu.org/software/libtool/

They have mailing lists for bug reports and patch submissions.

Once the patch has been accepted there it can be backported to the gcc and
gdb/binutils repositories...

Cheers
   Nick


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

* Re: [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection
  2021-07-07 14:39     ` Nick Clifton
@ 2021-07-07 19:03       ` Nick Alcock
  2021-07-21  8:22         ` Alan Modra
  0 siblings, 1 reply; 10+ messages in thread
From: Nick Alcock @ 2021-07-07 19:03 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils, gcc-patches

On 7 Jul 2021, Nick Clifton told this:

> Hi Nick,
>
>> Ping?
>
> Oops.

I sent a bunch of pings out at the same time, to a bunch of different
projects. You are the only person to respond, so thank you!

>>> 	PR libctf/27482
>>> 	* libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
>
> Changes to libtool need to be posted to the libtool project:
>
>   https://www.gnu.org/software/libtool/

I considered this, but there is *serious* divergence between the
libtool.m4 in our tree and upstream. Fixing this divergence looks to be
a fairly major project in and of itself :( the last real sync looked
like being all the way back in 2008.

> They have mailing lists for bug reports and patch submissions.
>
> Once the patch has been accepted there it can be backported to the gcc and
> gdb/binutils repositories...

AIUI, libtool has no maintainer currently, and the divergence is such
that the patch might need a near-complete rewrite anyway :( (there were
changes to this function upstream in 2012 and 2013, long after our last
sync.)

(However, I'm going to try in any case. I may have found a sucker, er, I
mean coworker willing to take this on.)

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

* Re: [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection
  2021-07-07 19:03       ` Nick Alcock
@ 2021-07-21  8:22         ` Alan Modra
  2021-09-09 12:39           ` Nick Alcock
  0 siblings, 1 reply; 10+ messages in thread
From: Alan Modra @ 2021-07-21  8:22 UTC (permalink / raw)
  To: Nick Alcock; +Cc: Nick Clifton, gcc-patches, binutils

On Wed, Jul 07, 2021 at 08:03:45PM +0100, Nick Alcock via Gcc-patches wrote:
> On 7 Jul 2021, Nick Clifton told this:
> 
> > Hi Nick,
> >
> >> Ping?
> >
> > Oops.
> 
> I sent a bunch of pings out at the same time, to a bunch of different
> projects. You are the only person to respond, so thank you!
> 
> >>> 	PR libctf/27482
> >>> 	* libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
> >
> > Changes to libtool need to be posted to the libtool project:
> >
> >   https://www.gnu.org/software/libtool/
> 
> I considered this, but there is *serious* divergence between the
> libtool.m4 in our tree and upstream. Fixing this divergence looks to be
> a fairly major project in and of itself :( the last real sync looked
> like being all the way back in 2008.

Yes, I looked at doing a sync myself a few years ago..
I'll OK the two libtool changes for binutils.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection
  2021-07-21  8:22         ` Alan Modra
@ 2021-09-09 12:39           ` Nick Alcock
  0 siblings, 0 replies; 10+ messages in thread
From: Nick Alcock @ 2021-09-09 12:39 UTC (permalink / raw)
  To: Alan Modra; +Cc: Nick Clifton, gcc-patches, binutils

On 21 Jul 2021, Alan Modra uttered the following:
> On Wed, Jul 07, 2021 at 08:03:45PM +0100, Nick Alcock via Gcc-patches wrote:
>> >>> 	PR libctf/27482
>> >>> 	* libtool.m4 (LT_PATH_NM): Try BSDization flags with a user-provided
>> >
>> > Changes to libtool need to be posted to the libtool project:
>> >
>> >   https://www.gnu.org/software/libtool/
>> 
>> I considered this, but there is *serious* divergence between the
>> libtool.m4 in our tree and upstream. Fixing this divergence looks to be
>> a fairly major project in and of itself :( the last real sync looked
>> like being all the way back in 2008.
>
> Yes, I looked at doing a sync myself a few years ago..
> I'll OK the two libtool changes for binutils.

Finally getting back to this -- sorry for the delay! (July and August
were fairly fraught for me).  I'll bring them up to date (mostly
affecting the sim/ regenerations as far as I can see) then retest.

I'm happy to backport this stuff as far back as people have reported
problems, insofar as those branches are even open (that would be back to
2.34 for all the PR27967 stuff, some of which I mislabelled in the
changelog as 27482: will fix). Is that OK? (It doesn't look like any of
the release branches are currently frozen.)

I'll repost the lot (including one new patch which is just under libctf/
and has a testcase, so is probably uncontroversial) and wait a bit
before pushing, because it's been so long.

(I've got a forward-port to libtool trunk too: I'll repost that as well,
and chase up for reviews.)

-- 
NULL && (void)

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

end of thread, other threads:[~2021-09-09 12:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25 16:13 [PATCH 0/4 REVIEW] libtool and libctf fixes for Solaris 11 Nick Alcock
2021-06-25 16:13 ` [PATCH 1/4] libtool.m4: augment symcode " Nick Alcock
2021-06-25 16:13 ` [PATCH 2/4 REVIEW] libtool.m4: fix nm BSD flag detection Nick Alcock
2021-07-06 19:37   ` Nick Alcock
2021-07-07 14:39     ` Nick Clifton
2021-07-07 19:03       ` Nick Alcock
2021-07-21  8:22         ` Alan Modra
2021-09-09 12:39           ` Nick Alcock
2021-06-25 16:13 ` [PATCH 3/4] libctf: try several possibilities for linker versioning flags Nick Alcock
2021-06-25 16:13 ` [PATCH 4/4] configure: regenerate in all projects that use libtool.m4 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).