Sources Bugzilla – Bug 6449
objdump -S and DOS-style line-endings
Last modified: 2012-02-15 12:13:13 UTC
When using objdump to create intermixed source/disassembly (-S) with build/host mingw/minsys a size-check fails for source-files with DOS-line endings (\r\n) since this gets translated "internally" to a single char. When opening the file in binary mode the sizes match. Proposed fix/patch: --- binutils-2.18.50_org/binutils/objdump.c Sat Mar 1 07:19:06 2008 +++ binutils-2.18.50/binutils/objdump.c Thu Mar 13 12:29:47 2008 @@ -70,6 +70,14 @@ #include <sys/stat.h> +#ifndef O_BINARY +#ifdef _O_BINARY +#define O_BINARY _O_BINARY +#else +#define O_BINARY 0 +#endif +#endif + /* Internal headers for the ELF .stab-dump code - sorry. */ #define BYTES_IN_WORD 32 #include "aout/aout64.h" @@ -975,7 +983,7 @@ #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;
There are so many #ifndef O_BINARY #ifdef _O_BINARY #define O_BINARY _O_BINARY #define setmode _setmode #else #define O_BINARY 0 #endif #endif in binutils sources. It should go into sysdep.h.
It was added to sysdep.h (via including include/binary-io.h) and objdump.c in binutils also specifies O_BINARY for open. So bug is fixed.