+2010-01-11 Andy Hutchinson <hutchinsonandy@gcc.gnu.org>
+
+ * lto.c (O_BINARY): Define.
+ (lto_read_section_data): Open file in binary mode.
+ * lto-elf.c (O_BINARY): Define.
+ (lto_elf_file_open): Open file in binary mode.
+
2010-01-08 Richard Guenther <rguenther@suse.de>
PR lto/42528
#include "ggc.h"
#include "lto-streamer.h"
+/* Handle opening elf files on hosts, such as Windows, that may use
+ text file handling that will break binary access. */
+
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
/* Initialize FILE, an LTO file object for FILENAME. */
static void
elf_file->fd = -1;
/* Open the file. */
- elf_file->fd = open (fname, writable ? O_WRONLY|O_CREAT : O_RDONLY, 0666);
+ elf_file->fd = open (fname, writable ? O_WRONLY|O_CREAT|O_BINARY
+ : O_RDONLY|O_BINARY, 0666);
if (elf_file->fd == -1)
{
error ("could not open file %s", fname);
#include <sys/mman.h>
#endif
+/* Handle opening elf files on hosts, such as Windows, that may use
+ text file handling that will break binary access. */
+
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
+
DEF_VEC_P(bitmap);
DEF_VEC_ALLOC_P(bitmap,heap);
if (fd == -1)
{
fd_name = xstrdup (file_data->file_name);
- fd = open (file_data->file_name, O_RDONLY);
+ fd = open (file_data->file_name, O_RDONLY|O_BINARY);
if (fd == -1)
return NULL;
}