diff options
author | Eli Zaretskii <eliz@gnu.org> | 2021-01-28 13:32:05 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-01-28 13:32:05 +0000 |
commit | a7ad3cb1fff75e8e11df40128adda66a42a06239 (patch) | |
tree | 79ec91b923fa0e19fb42ab012e7b6b79b12972a6 /binutils | |
parent | 0318cca4934fc5d85e83351842985ad2a3475146 (diff) | |
download | binutils-a7ad3cb1fff75e8e11df40128adda66a42a06239.zip binutils-a7ad3cb1fff75e8e11df40128adda66a42a06239.tar.gz binutils-a7ad3cb1fff75e8e11df40128adda66a42a06239.tar.bz2 |
Fix binutils tools so that they can cope with the special /dev/null file when run on Windows systems.
PR 27252
* bucomm.c (get_file_size): Add code to handle /dev/null on
Windows systems.
* elfedit.c (check_file): Likewise.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 7 | ||||
-rw-r--r-- | binutils/bucomm.c | 15 | ||||
-rw-r--r-- | binutils/elfedit.c | 14 |
3 files changed, 36 insertions, 0 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 712a9eb..c02a0eef 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,10 @@ +2021-01-28 Eli Zaretskii <eliz@gnu.org> + + PR 27252 + * bucomm.c (get_file_size): Add code to handle /dev/null on + Windows systems. + * elfedit.c (check_file): Likewise. + 2021-01-27 Nick Clifton <nickc@redhat.com> * objcopy.c (copy_main): Remove conditional control of the calls diff --git a/binutils/bucomm.c b/binutils/bucomm.c index 9e6521d..0499007 100644 --- a/binutils/bucomm.c +++ b/binutils/bucomm.c @@ -623,6 +623,21 @@ get_file_size (const char * file_name) else if (statbuf.st_size < 0) non_fatal (_("Warning: '%s' has negative size, probably it is too large"), file_name); +#if defined (_WIN32) && !defined (__CYGWIN__) + else if (statbuf.st_size == 0) + { + /* MS-Windows 'stat' doesn't reports the null device as a + regular file; fix that. */ + int fd = open (file_name, O_RDONLY | O_BINARY); + if (isatty (fd)) + { + close (fd); + non_fatal (_("Warning: '%s' is not an ordinary file"), + /* libtool wants to see /dev/null in the output. */ + strcasecmp (file_name, "nul") ? file_name : "/dev/null"); + } + } +#endif else return statbuf.st_size; diff --git a/binutils/elfedit.c b/binutils/elfedit.c index d90cbaf..260abe0 100644 --- a/binutils/elfedit.c +++ b/binutils/elfedit.c @@ -721,6 +721,20 @@ check_file (const char *file_name, struct stat *statbuf_p) return 1; } +#if defined (_WIN32) && !defined (__CYGWIN__) + else if (statbuf_p->st_size == 0) + { + /* MS-Windows 'stat' doesn't reports the null device as a + regular file; fix that. */ + int fd = open (file_name, O_RDONLY | O_BINARY); + if (isatty (fd)) + { + statbuf_p->st_mode &= ~S_IFREG; + statbuf_p->st_mode |= S_IFCHR; + } + } +#endif + if (! S_ISREG (statbuf_p->st_mode)) { error (_("'%s' is not an ordinary file\n"), file_name); |