strings and offsets >2G

Michal Svec rebel@atrey.karlin.mff.cuni.cz
Tue Oct 23 02:19:00 GMT 2001


Hi!

Due to the limitation of file_ptr to long, the current implementation of
strings doesn't support offsets larger than 2GB.

It can be somehow easily fixed at least for the simple case when scanning
the whole file by replacing "file_ptr" type (long) with "long long" (see
attached patch).

I know it's not very portable and someone may surely find a better (and
complete) solution, but a partial fix is better then nothing.

Regards
Michal

--- binutils-2.11.90.0.31/binutils/strings.c.orig       Tue Oct 23
11:10:35 2001
+++ binutils-2.11.90.0.31/binutils/strings.c    Tue Oct 23 11:12:30 2001
@@ -130,7 +130,7 @@
 static boolean strings_file PARAMS ((char *file));
 static int integer_arg PARAMS ((char *s));
 static void print_strings PARAMS ((const char *filename, FILE *stream,
-                                 file_ptr address, int stop_point,
+                                 long long address, int stop_point,
                                  int magiccount, char *magic));
 static void usage PARAMS ((FILE *stream, int status));
 ^L
@@ -382,7 +382,7 @@
 print_strings (filename, stream, address, stop_point, magiccount, magic)
      const char *filename;
      FILE *stream;
-     file_ptr address;
+     long long address;
      int stop_point;
      int magiccount;
      char *magic;
@@ -431,15 +431,15 @@
        switch (address_radix)
          {
          case 8:
-           printf ("%7lo ", (unsigned long) start);
+           printf ("%7Lo ", (unsigned long long) start);
            break;

          case 10:
-           printf ("%7ld ", (long) start);
+           printf ("%7Ld ", (long long) start);
            break;

          case 16:
-           printf ("%7lx ", (unsigned long) start);
+           printf ("%7Lx ", (unsigned long long) start);
            break;
          }




More information about the Binutils mailing list