From 417ed8af836c10ff5c0cbcdc4c011f5024a7269b Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 28 Apr 2008 08:30:23 +0000 Subject: [PATCH] PR binutils/6449 * objdump.c (slurp_file): Open the file in binary mode. * ar.c: Remove conditional definition of O_BINARY. * bin2.c: Likewise. * rename.c: Likewise. * strings.c: Likewise. * sysdep.h: Add conditional definition of O_BINARY. --- binutils/ChangeLog | 11 +++++++++++ binutils/ar.c | 6 ------ binutils/bin2c.c | 5 ++--- binutils/objdump.c | 4 ++-- binutils/rename.c | 6 ------ binutils/strings.c | 7 +------ binutils/sysdep.h | 8 ++++++++ 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 6ef5a355708..b3caac3dba8 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,14 @@ +2008-04-28 M Thomas + Nick Clifton + + PR binutils/6449 + * objdump.c (slurp_file): Open the file in binary mode. + * ar.c: Remove conditional definition of O_BINARY. + * bin2.c: Likewise. + * rename.c: Likewise. + * strings.c: Likewise. + * sysdep.h: Add conditional definition of O_BINARY. + 2008-04-23 Paolo Bonzini * aclocal.m4: Regenerate. diff --git a/binutils/ar.c b/binutils/ar.c index 71f4d734612..f4932219b7a 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -45,12 +45,6 @@ #define EXT_NAME_LEN 6 /* Ditto for *NIX. */ #endif -/* We need to open files in binary modes on system where that makes a - difference. */ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - /* Kludge declaration from BFD! This is ugly! FIXME! XXX */ struct ar_hdr * diff --git a/binutils/bin2c.c b/binutils/bin2c.c index 0eeff350aad..b3138e1f741 100644 --- a/binutils/bin2c.c +++ b/binutils/bin2c.c @@ -1,5 +1,5 @@ /* bin2c.c -- dump binary file in hex format - Copyright 2007 Free Software Foundation, Inc. + Copyright 2007, 2008 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -22,9 +22,8 @@ #include "bfd.h" #include "bucomm.h" -#if !defined O_BINARY && defined _O_BINARY +#if !defined O_TEXT && defined _O_TEXT /* For MSC-compatible compilers. */ -# define O_BINARY _O_BINARY # define O_TEXT _O_TEXT #endif diff --git a/binutils/objdump.c b/binutils/objdump.c index b348025024d..5a862506c86 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -964,7 +964,7 @@ static struct print_file_list *print_files; #define SHOW_PRECEDING_CONTEXT_LINES (5) -/* Read a complete file into memory. */ +/* Read a complete file into memory. */ static const char * slurp_file (const char *fn, size_t *size) @@ -975,7 +975,7 @@ slurp_file (const char *fn, size_t *size) #endif const char *map; struct stat st; - int fd = open (fn, O_RDONLY); + int fd = open (fn, O_RDONLY | O_BINARY); if (fd < 0) return NULL; diff --git a/binutils/rename.c b/binutils/rename.c index 6ae4d29c746..367ed1f02da 100644 --- a/binutils/rename.c +++ b/binutils/rename.c @@ -32,12 +32,6 @@ #endif /* HAVE_UTIMES */ #endif /* ! HAVE_GOOD_UTIME_H */ -/* We need to open the file in binary modes on system where that makes - a difference. */ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - #if ! defined (_WIN32) || defined (__CYGWIN32__) static int simple_copy (const char *, const char *); diff --git a/binutils/strings.c b/binutils/strings.c index 40b53b8fed5..973045e17c9 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -69,17 +69,12 @@ /* Some platforms need to put stdin into binary mode, to read binary files. */ #ifdef HAVE_SETMODE -#ifndef O_BINARY #ifdef _O_BINARY -#define O_BINARY _O_BINARY #define setmode _setmode -#else -#define O_BINARY 0 -#endif #endif #if O_BINARY #include -#define SET_BINARY(f) do { if (!isatty (f)) setmode (f,O_BINARY); } while (0) +#define SET_BINARY(f) do { if (!isatty (f)) setmode (f, O_BINARY); } while (0) #endif #endif diff --git a/binutils/sysdep.h b/binutils/sysdep.h index 0d7e2501106..e6a89a49d3c 100644 --- a/binutils/sysdep.h +++ b/binutils/sysdep.h @@ -36,6 +36,14 @@ #include "fopen-same.h" #endif +#ifndef O_BINARY +#ifdef _O_BINARY +#define O_BINARY _O_BINARY +#else +#define O_BINARY 0 +#endif +#endif + #include #ifndef errno extern int errno; -- 2.30.2