diff options
author | Jakub Jelinek <jakub@redhat.com> | 2001-12-04 10:11:22 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2001-12-04 10:11:22 +0000 |
commit | cedd9a58070bd8620dfb12983a53249c776b6872 (patch) | |
tree | 2e3b1a0914acdbbe4c2f42b01049d747f3e88715 | |
parent | d126725049bcee3c863e3908d1ea51cc5e13afed (diff) | |
download | gdb-cedd9a58070bd8620dfb12983a53249c776b6872.zip gdb-cedd9a58070bd8620dfb12983a53249c776b6872.tar.gz gdb-cedd9a58070bd8620dfb12983a53249c776b6872.tar.bz2 |
* strings.c: Include config.h before bfd.h.
(file_off): New type.
(file_open): Define.
(print_strings): Use file_off instead of file_ptr. Print addresses
which don't fit into long correctly.
(get_char): Use file_off instead of file_ptr. Use getc_unlocked if
available.
(strings_file): Use file_off instead of file_ptr. Use file_open.
* configure.in: Check for getc_unlocked.
Check for fopen64 and whether _LARGEFILE64_SOURCE needs to
be defined for it.
* configure: Rebuilt.
* config.h.in: Rebuilt.
-rw-r--r-- | binutils/ChangeLog | 16 | ||||
-rw-r--r-- | binutils/config.in | 15 | ||||
-rwxr-xr-x | binutils/configure | 63 | ||||
-rw-r--r-- | binutils/configure.in | 24 | ||||
-rw-r--r-- | binutils/strings.c | 71 |
5 files changed, 174 insertions, 15 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 3bb6ea2..8548ec3 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,19 @@ +2001-12-04 Jakub Jelinek <jakub@redhat.com> + + * strings.c: Include config.h before bfd.h. + (file_off): New type. + (file_open): Define. + (print_strings): Use file_off instead of file_ptr. Print addresses + which don't fit into long correctly. + (get_char): Use file_off instead of file_ptr. Use getc_unlocked if + available. + (strings_file): Use file_off instead of file_ptr. Use file_open. + * configure.in: Check for getc_unlocked. + Check for fopen64 and whether _LARGEFILE64_SOURCE needs to + be defined for it. + * configure: Rebuilt. + * config.h.in: Rebuilt. + 2001-11-29 H.J. Lu <hjl@gnu.org> * bucomm.c (make_tempname): Revert the changes made on diff --git a/binutils/config.in b/binutils/config.in index 8a0e1c5..1e0aa93 100644 --- a/binutils/config.in +++ b/binutils/config.in @@ -58,6 +58,9 @@ /* Define if you have the dcgettext function. */ #undef HAVE_DCGETTEXT +/* Define if you have the getc_unlocked function. */ +#undef HAVE_GETC_UNLOCKED + /* Define if you have the getcwd function. */ #undef HAVE_GETCWD @@ -127,6 +130,12 @@ /* Define if you have the <sys/param.h> header file. */ #undef HAVE_SYS_PARAM_H +/* Define if you have the <sys/stat.h> header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the <sys/types.h> header file. */ +#undef HAVE_SYS_TYPES_H + /* Define if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H @@ -157,6 +166,12 @@ /* Suffix used for executables, if any. */ #undef EXECUTABLE_SUFFIX +/* Is fopen64 available? */ +#undef HAVE_FOPEN64 + +/* Enable LFS */ +#undef _LARGEFILE64_SOURCE + /* Is the type time_t defined in <time.h>? */ #undef HAVE_TIME_T_IN_TIME_H diff --git a/binutils/configure b/binutils/configure index 2268453..6868341 100755 --- a/binutils/configure +++ b/binutils/configure @@ -4899,7 +4899,7 @@ EOF fi -for ac_func in sbrk utimes setmode +for ac_func in sbrk utimes setmode getc_unlocked do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:4906: checking for $ac_func" >&5 @@ -4955,6 +4955,67 @@ fi done +# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE +# needs to be defined for it +echo $ac_n "checking for fopen64""... $ac_c" 1>&6 +echo "configure:4962: checking for fopen64" >&5 +if eval "test \"`echo '$''{'bu_cv_have_fopen64'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 4967 "configure" +#include "confdefs.h" +#include <stdio.h> +int main() { +FILE *f = fopen64 ("/tmp/foo","r"); +; return 0; } +EOF +if { (eval echo configure:4974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + bu_cv_have_fopen64=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + saved_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" + cat > conftest.$ac_ext <<EOF +#line 4984 "configure" +#include "confdefs.h" +#include <stdio.h> +int main() { +FILE *f = fopen64 ("/tmp/foo","r"); +; return 0; } +EOF +if { (eval echo configure:4991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bu_cv_have_fopen64=no +fi +rm -f conftest* +fi +rm -f conftest* +fi + CPPFLAGS=$saved_CPPFLAGS + +echo "$ac_t""$bu_cv_have_fopen64" 1>&6 +if test $bu_cv_have_fopen64 != no; then + cat >> confdefs.h <<\EOF +#define HAVE_FOPEN64 1 +EOF + + if test $bu_cv_have_fopen64 = "need -D_LARGEFILE64_SOURCE"; then + cat >> confdefs.h <<\EOF +#define _LARGEFILE64_SOURCE 1 +EOF + + fi +fi + # Some systems have frexp only in -lm, not in -lc. echo $ac_n "checking for library containing frexp""... $ac_c" 1>&6 diff --git a/binutils/configure.in b/binutils/configure.in index 23d517b..0555852 100644 --- a/binutils/configure.in +++ b/binutils/configure.in @@ -100,7 +100,29 @@ AC_SUBST(DEMANGLER_NAME) AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h) AC_HEADER_SYS_WAIT AC_FUNC_ALLOCA -AC_CHECK_FUNCS(sbrk utimes setmode) +AC_CHECK_FUNCS(sbrk utimes setmode getc_unlocked) + +# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE +# needs to be defined for it +AC_MSG_CHECKING([for fopen64]) +AC_CACHE_VAL(bu_cv_have_fopen64, +[AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");], +bu_cv_have_fopen64=yes, +[saved_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE" + AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");], +bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE", +bu_cv_have_fopen64=no) + CPPFLAGS=$saved_CPPFLAGS])]) +AC_MSG_RESULT($bu_cv_have_fopen64) +if test $bu_cv_have_fopen64 != no; then + AC_DEFINE([HAVE_FOPEN64], 1, + [Is fopen64 available?]) + if test $bu_cv_have_fopen64 = "need -D_LARGEFILE64_SOURCE"; then + AC_DEFINE([_LARGEFILE64_SOURCE], 1, + [Enable LFS]) + fi +fi # Some systems have frexp only in -lm, not in -lc. AC_SEARCH_LIBS(frexp, m) diff --git a/binutils/strings.c b/binutils/strings.c index dec77df..89e322b 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -56,6 +56,9 @@ Written by Richard Stallman <rms@gnu.ai.mit.edu> and David MacKenzie <djm@gnu.ai.mit.edu>. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "bfd.h" #include <stdio.h> #include <getopt.h> @@ -90,6 +93,14 @@ extern int errno; /* The BFD section flags that identify an initialized data section. */ #define DATA_FLAGS (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS) +#ifdef HAVE_FOPEN64 +typedef off64_t file_off; +#define file_open(s,m) fopen64(s,m) +#else +typedef off_t file_off; +#define file_open(s,m) fopen(s,m) +#endif + /* Radix for printing addresses (must be 8, 10 or 16). */ static int address_radix; @@ -133,10 +144,10 @@ static boolean strings_object_file PARAMS ((const char *)); 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, + file_off address, int stop_point, int magiccount, char *magic)); static void usage PARAMS ((FILE *stream, int status)); -static long get_char PARAMS ((FILE *stream, file_ptr *address, +static long get_char PARAMS ((FILE *stream, file_off *address, int *magiccount, char **magic)); int @@ -371,10 +382,7 @@ strings_file (file) { FILE *stream; - stream = fopen (file, "rb"); - /* Not all systems permit "rb", so try "r" if it failed. */ - if (stream == NULL) - stream = fopen (file, "r"); + stream = file_open (file, FOPEN_RB); if (stream == NULL) { fprintf (stderr, "%s: ", program_name); @@ -382,7 +390,7 @@ strings_file (file) return false; } - print_strings (file, stream, (file_ptr) 0, 0, 0, (char *) 0); + print_strings (file, stream, (file_off) 0, 0, 0, (char *) 0); if (fclose (stream) == EOF) { @@ -408,7 +416,7 @@ strings_file (file) static long get_char (stream, address, magiccount, magic) FILE *stream; - file_ptr *address; + file_off *address; int *magiccount; char **magic; { @@ -427,7 +435,11 @@ get_char (stream, address, magiccount, magic) { if (stream == NULL) return EOF; +#ifdef HAVE_GETC_UNLOCKED + c = getc_unlocked (stream); +#else c = getc (stream); +#endif if (c == EOF) return EOF; } @@ -479,7 +491,7 @@ static void print_strings (filename, stream, address, stop_point, magiccount, magic) const char *filename; FILE *stream; - file_ptr address; + file_off address; int stop_point; int magiccount; char *magic; @@ -488,7 +500,7 @@ print_strings (filename, stream, address, stop_point, magiccount, magic) while (1) { - file_ptr start; + file_off start; int i; long c; @@ -517,15 +529,48 @@ print_strings (filename, stream, address, stop_point, magiccount, magic) switch (address_radix) { case 8: - printf ("%7lo ", (unsigned long) start); +#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) + if (sizeof (start) > sizeof (long)) + printf ("%7Lo ", (unsigned long long) start); + else +#else +# if !BFD_HOST_64BIT_LONG + if (start != (unsigned long) start) + printf ("++%7lo ", (unsigned long) start); + else +# endif +#endif + printf ("%7lo ", (unsigned long) start); break; case 10: - printf ("%7ld ", (long) start); +#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) + if (sizeof (start) > sizeof (long)) + printf ("%7Ld ", (unsigned long long) start); + else +#else +# if !BFD_HOST_64BIT_LONG + if (start != (unsigned long) start) + printf ("++%7ld ", (unsigned long) start); + else +# endif +#endif + printf ("%7ld ", (long) start); break; case 16: - printf ("%7lx ", (unsigned long) start); +#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) + if (sizeof (start) > sizeof (long)) + printf ("%7Lx ", (unsigned long long) start); + else +#else +# if !BFD_HOST_64BIT_LONG + if (start != (unsigned long) start) + printf ("%lx%8.8lx ", start >> 32, start & 0xffffffff); + else +# endif +#endif + printf ("%7lx ", (unsigned long) start); break; } |