nm and objdump when no symbols

Alan Modra amodra@bigpond.net.au
Mon Aug 26 03:11:00 GMT 2002


On Sun, Aug 11, 2002 at 07:55:20AM +0100, Nick Clifton wrote:
> I am open to either interpretation however, so if you want to move the
> message to stdout, please do so.

Before I forget.  I agree with John Reiser's suggestion that nm should
print nothing to stdout when there are no symbols.

binutils/ChangeLog
	* nm.c (display_rel_file): Don't report "no symbols" as an error.
	* objdump.c (slurp_symtab): Likewise.
	(slurp_dynamic_symtab): Likewise.
	(dump_symbols): Likewise.  Do print "no symbols" to stdout.

binutils/testsuite/ChangeLog
	* binutils-all/objcopy.exp (strip_test): Adjust for "no symbols" on
	stdout.
	(strip_executable): Likewise.

ld/testsuite/ChangeLog
	* ld-mmix/b-nosym.d: Adjust for "no symbols" on stdout.

Applying mainline.

Index: binutils/nm.c
===================================================================
RCS file: /cvs/src/src/binutils/nm.c,v
retrieving revision 1.30
diff -u -p -r1.30 nm.c
--- binutils/nm.c	14 Aug 2002 15:12:07 -0000	1.30
+++ binutils/nm.c	26 Aug 2002 10:05:47 -0000
@@ -955,10 +955,7 @@ display_rel_file (abfd, archive_bfd)
   if (! dynamic)
     {
       if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
-	{
-	  non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
-	  return;
-	}
+	return;
     }
 
   symcount = bfd_read_minisymbols (abfd, dynamic, &minisyms, &size);
@@ -966,10 +963,7 @@ display_rel_file (abfd, archive_bfd)
     bfd_fatal (bfd_get_filename (abfd));
 
   if (symcount == 0)
-    {
-      non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
-      return;
-    }
+    return;
 
   /* Discard the symbols we don't want to print.
      It's OK to do this in place; we'll free the storage anyway
Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.55
diff -u -p -r1.55 objdump.c
--- binutils/objdump.c	14 Aug 2002 15:12:07 -0000	1.55
+++ binutils/objdump.c	26 Aug 2002 08:23:16 -0000
@@ -383,7 +383,6 @@ slurp_symtab (abfd)
 
   if (!(bfd_get_file_flags (abfd) & HAS_SYMS))
     {
-      non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
       symcount = 0;
       return NULL;
     }
@@ -397,8 +396,6 @@ slurp_symtab (abfd)
   symcount = bfd_canonicalize_symtab (abfd, sy);
   if (symcount < 0)
     bfd_fatal (bfd_get_filename (abfd));
-  if (symcount == 0)
-    non_fatal (_("%s: no symbols"), bfd_get_filename (abfd));
   return sy;
 }
 
@@ -429,8 +426,6 @@ slurp_dynamic_symtab (abfd)
   dynsymcount = bfd_canonicalize_dynamic_symtab (abfd, sy);
   if (dynsymcount < 0)
     bfd_fatal (bfd_get_filename (abfd));
-  if (dynsymcount == 0)
-    non_fatal (_("%s: No dynamic symbols"), bfd_get_filename (abfd));
   return sy;
 }
 
@@ -2284,18 +2279,17 @@ dump_symbols (abfd, dynamic)
     {
       current = dynsyms;
       max = dynsymcount;
-      if (max == 0)
-	return;
       printf ("DYNAMIC SYMBOL TABLE:\n");
     }
   else
     {
       current = syms;
       max = symcount;
-      if (max == 0)
-	return;
       printf ("SYMBOL TABLE:\n");
     }
+
+  if (max == 0)
+    printf (_("no symbols\n"));
 
   for (count = 0; count < max; count++)
     {
Index: binutils/testsuite/binutils-all/objcopy.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/objcopy.exp,v
retrieving revision 1.16
diff -u -p -r1.16 objcopy.exp
--- binutils/testsuite/binutils-all/objcopy.exp	15 Aug 2002 23:41:18 -0000	1.16
+++ binutils/testsuite/binutils-all/objcopy.exp	26 Aug 2002 08:23:17 -0000
@@ -371,7 +371,7 @@ proc strip_test { } {
     }
 
     set exec_output [binutils_run $NM "-a $NMFLAGS $objfile"]
-    if ![string match "*: no symbols*" $exec_output] {
+    if ![string match "" $exec_output] {
 	fail $test
 	return
     }
@@ -558,7 +558,7 @@ proc strip_executable { prog flags test 
     }
 
     set exec_output [binutils_run $NM "$NMFLAGS ${copyfile}"]
-    if ![string match "*: no symbols*" $exec_output] {
+    if ![string match "" $exec_output] {
 	fail $test
 	return
     }
Index: ld/testsuite/ld-mmix/b-nosym.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mmix/b-nosym.d,v
retrieving revision 1.3
diff -u -p -r1.3 b-nosym.d
--- ld/testsuite/ld-mmix/b-nosym.d	17 Feb 2002 21:22:24 -0000	1.3
+++ ld/testsuite/ld-mmix/b-nosym.d	26 Aug 2002 08:25:43 -0000
@@ -3,13 +3,13 @@
 #source: b-nosym.s
 #ld: --oformat binary
 #objcopy_linked_file:
-#objdump: -st 2>/dev/null
-
-# Note that we have to redirect stderr when objdumping to get rid of the
-# "no symbols" message that would otherwise cause a spurious failure and
-# which we seemingly can't identify or prune in another way.
+#objdump: -st
 
 .*:     file format mmo
+
+SYMBOL TABLE:
+no symbols
+
 
 Contents of section \.text:
  0000 e3fd0001 e3fd0004                    .*


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list