2010-02-26 Doug Kwan <dougkwan@google.com>
[binutils-gdb.git] / gold / descriptors.cc
index 3d059e2c222ed79a02157d282d9a2d70d4ddce55..f4a02d03296caaf2cc1b6eeaf12204785b31ac12 100644 (file)
@@ -23,6 +23,7 @@
 #include "gold.h"
 
 #include <cerrno>
+#include <cstdio>
 #include <cstring>
 #include <fcntl.h>
 #include <unistd.h>
@@ -31,6 +32,7 @@
 #include "options.h"
 #include "gold-threads.h"
 #include "descriptors.h"
+#include "binary-io.h"
 
 // Very old systems may not define FD_CLOEXEC.
 #ifndef FD_CLOEXEC
@@ -98,6 +100,9 @@ Descriptors::open(int descriptor, const char* name, int flags, int mode)
       // require callers to pass it.
       flags |= O_CLOEXEC;
 
+      // Always open the file as a binary file.
+      flags |= O_BINARY;
+
       int new_descriptor = ::open(name, flags, mode);
       if (new_descriptor < 0
          && errno != ENFILE