blob: 2369a6fad9945a20d7a478a6573c6688c3847313 [file] [log] [blame]
Configure scripts tend to do things like this:
nm -B /dev/null
which, on Windows, turn into:
nm -B nul
and nul here acts like a normal file with 0 size as far as stat() is concerned.
Check harder for the file in question being unusual (isatty() does see that).
And since configure script expects /dev/nul, do report it that way.
diff -urN binutils-2.27.orig/binutils/bucomm.c binutils-2.27/binutils/bucomm.c
--- binutils-2.27.orig/binutils/bucomm.c 2016-08-03 09:36:51.000000000 +0200
+++ binutils-2.27/binutils/bucomm.c 2016-09-21 20:43:33.158175700 +0200
@@ -575,6 +575,15 @@
{
struct stat statbuf;
+ int f, t;
+ t = -1;
+ f = open (file_name, O_RDONLY | O_BINARY);
+ if (f != 0)
+ {
+ t = isatty (f);
+ close (f);
+ }
+
if (stat (file_name, &statbuf) < 0)
{
if (errno == ENOENT)
@@ -600,8 +600,15 @@
}
else if (S_ISDIR (statbuf.st_mode))
non_fatal (_("Warning: '%s' is a directory"), file_name);
- else if (! S_ISREG (statbuf.st_mode))
- non_fatal (_("Warning: '%s' is not an ordinary file"), file_name);
+ else if (! S_ISREG (statbuf.st_mode) || t > 0)
+ {
+#ifdef _WIN32
+ /* libtool passes /dev/null and checks for /dev/null in the output */
+ if (stricmp (file_name, "nul") == 0)
+ file_name = "/dev/null";
+#endif
+ non_fatal (_("Warning: '%s' is not an ordinary file"), file_name);
+ }
else if (statbuf.st_size < 0)
non_fatal (_("Warning: '%s' has negative size, probably it is too large"),
file_name);
diff -urN binutils-2.27.orig/binutils/elfedit.c binutils-2.27/binutils/elfedit.c
--- binutils-2.27.orig/binutils/elfedit.c 2016-08-03 09:36:51.000000000 +0200
+++ binutils-2.27/binutils/elfedit.c 2016-09-21 20:38:40.359931800 +0200
@@ -483,6 +483,14 @@
check_file (const char *file_name, struct stat *statbuf_p)
{
struct stat statbuf;
+ int f, t;
+ t = -1;
+ f = open (file_name, O_RDONLY | O_BINARY);
+ if (f != 0)
+ {
+ t = isatty (f);
+ close (f);
+ }
if (statbuf_p == NULL)
statbuf_p = &statbuf;
@@ -497,8 +505,13 @@
return 1;
}
- if (! S_ISREG (statbuf_p->st_mode))
+ if (! S_ISREG (statbuf_p->st_mode) || t > 0)
{
+#ifdef _WIN32
+ /* libtool passes /dev/null and checks for /dev/null in the output */
+ if (stricmp (file_name, "nul") == 0)
+ file_name = "/dev/null";
+#endif
error (_("'%s' is not an ordinary file\n"), file_name);
return 1;
}