Bug 75 - strings --radix option gives all zeros
Summary: strings --radix option gives all zeros
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: pre-2.15
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-15 17:44 UTC by Chris Hamilton
Modified: 2022-06-22 06:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Script used to build binutils-2.14 (shows configuration options) (544 bytes, text/plain)
2004-04-07 16:23 UTC, Chris Hamilton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Hamilton 2004-03-15 17:44:28 UTC
The --radix option of 'strings' no longer works in versions 2.12.x and 2.13.x 
of binutils.  The option is accepted, but 'strings' emits "0" as the offset for 
every string, rather than the true offset.  Below, I've run the same command on 
the same file using version 2.9.1 of binutils (which works correctly), and 
version 2.13.2.1 of binutils (which fails).

[ARMADA sparc64-sun-solaris2.8 (spinach)]$ /_TOOLS_/dist/gnu-binutils-
2.9.1/sparc-sun-solaris2.5.1/bin/strings --version
GNU strings 2.9.1
Copyright 1997 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ /_TOOLS_/dist/gnu-binutils-
2.9.1/sparc-sun-solaris2.5.1/bin/strings arcs.o --radix=x
  1aa70 bad_alloc
  1aa88 This shadow container cannot be swapped!
  1aab8 out of memory
  1aac8 Q25tapir12ArcsIterImpl
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ /_TOOLS_/dist/gnu-binutils-
2.13.2.1/sparc-sun-solaris2.8/bin/strings --version
GNU strings 2.13.2.1
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ /_TOOLS_/dist/gnu-binutils-
2.13.2.1/sparc-sun-solaris2.8/bin/strings arcs.o --radix=x
      0 bad_alloc
      0 This shadow container cannot be swapped!
      0 out of memory
      0 Q25tapir12ArcsIterImpl
Comment 1 Alan Modra 2004-04-07 05:21:18 UTC
Seems to work with current binutils
$ strings --radix=x /bin/ls
    114 /lib/ld-linux.so.2
    b09 librt.so.1
    b14 clock_gettime
    b22 _Jv_RegisterClasses
[snip]
Would you please check that the bug is fixed for your particular target with
current sources?
Comment 2 Chris Hamilton 2004-04-07 15:28:58 UTC
2.13.2.1 is most current version I have available.  Will download and build new 
version 2.14 as soon as time permits.

Was the bug explicitly fixed since 2.13.2.1?  Release notes don't indicate any 
changes/fixes related to the --radix option.

Comment 3 Chris Hamilton 2004-04-07 16:20:38 UTC
Current version (2.14) has same bug on Solaris 5.8.  (Have not tried other 
platforms.)

Built 2.14 using a script 'build.sh'.  Will attach script to show configuration 
options used.  After building, ran the following commands:

[ARMADA sparc64-sun-solaris2.8 (spinach)]$ ls -al bin/strings 
-rwxr-xr-x    1 cham     tools     1479873 Apr  7 11:02 bin/strings
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ bin/strings --version
GNU strings 2.14 20030612
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ 
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ bin/strings --radix=x bin/strings | 
head
      0 /usr/lib/ld.so.1
      0 __deregister_frame_info
      0 __register_frame_info
      0 _Jv_RegisterClasses
      0 libc.so.1
      0 getopt
      0 calloc
      0 atoi
      0 strtol
      0 fread
[ARMADA sparc64-sun-solaris2.8 (spinach)]$ 
Comment 4 Chris Hamilton 2004-04-07 16:23:26 UTC
Created attachment 47 [details]
Script used to build binutils-2.14 (shows configuration options)
Comment 5 Alan Modra 2004-04-14 05:43:55 UTC
I guess I should have been more explicit on what I meant by "current" sources.
I meant current CVS, either head or 2.15 branch.

However, I configured a sparc-sun-solaris2.8 cross-binutils, both from
i686-linux and powerpc64-linux (to test whether a 64 bit host affected the
problem), and found that strings --radix=x works fine for me using 2.14 source.
 Now, strings.c:print_strings contains a bunch of #ifdef code, so it's likely
I'm compiling different code than you are on a native solaris box.

I think the most likely reason is that your C library printf doesn't understand
%Lx on long long values.  Would you check that with a little test program, please?

When looking at the source, I found a bug fixed with the following patch, but
this one can hardly affect you as it won't trigger unless strings is looking at
files over 4G in size.

Index: binutils/strings.c
===================================================================
RCS file: /cvs/src/src/binutils/strings.c,v
retrieving revision 1.21
diff -u -p -r1.21 strings.c
--- binutils/strings.c	7 Nov 2003 12:19:34 -0000	1.21
+++ binutils/strings.c	14 Apr 2004 05:38:24 -0000
@@ -557,7 +557,8 @@ print_strings (const char *filename, FIL
 #else
 # if !BFD_HOST_64BIT_LONG
 	    if (start != (unsigned long) start)
-	      printf ("%lx%8.8lx ", start >> 32, start & 0xffffffff);
+	      printf ("%lx%8.8lx ", (unsigned long) (start >> 32),
+		      (unsigned long) (start & 0xffffffff));
 	    else
 # endif
 #endif
Comment 6 Alan Modra 2004-10-02 05:42:04 UTC
Closing as has been in waiting for nearly 6 months.