summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2008-04-28 08:30:23 +0000
committerNick Clifton <nickc@redhat.com>2008-04-28 08:30:23 +0000
commitc3372e5344a641ba9409547d11e3e8651f0e8eeb (patch)
tree0a1dc7fd1f13c97d38ed1f24be2e4341965ee358
parent9dda65711aaffead78e9d68a9f7893152b375a67 (diff)
downloadbinutils-redhat-c3372e5344a641ba9409547d11e3e8651f0e8eeb.tar.gz
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.
-rw-r--r--binutils/ChangeLog11
-rw-r--r--binutils/ar.c6
-rw-r--r--binutils/bin2c.c5
-rw-r--r--binutils/objdump.c4
-rw-r--r--binutils/rename.c6
-rw-r--r--binutils/strings.c7
-rw-r--r--binutils/sysdep.h8
7 files changed, 24 insertions, 23 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6ef5a35570..b3caac3dba 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
+2008-04-28 M Thomas <mthomas@rhrk.uni-kl.de>
+ Nick Clifton <nickc@redhat.com>
+
+ 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 <bonzini@gnu.org>
* aclocal.m4: Regenerate.
diff --git a/binutils/ar.c b/binutils/ar.c
index 71f4d73461..f4932219b7 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 0eeff350aa..b3138e1f74 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 b348025024..5a862506c8 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 6ae4d29c74..367ed1f02d 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 40b53b8fed..973045e17c 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 <io.h>
-#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 0d7e250110..e6a89a49d3 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 <errno.h>
#ifndef errno
extern int errno;