[PATCH 1/2] gas/as.c: print input and output details when error

2018-08-08 Thread Robert Yang
Print input and output details (filename, inode number) when error, this makes
the debug easier.

Signed-off-by: Robert Yang 
---
 gas/as.c | 4 +++-
 gas/as.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gas/as.c b/gas/as.c
index 02c7d29..6afe9a5 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1259,8 +1259,10 @@ main (int argc, char ** argv)
  if (sib.st_ino == sob.st_ino && sib.st_ino != 0)
{
  /* Don't let as_fatal remove the output file!  */
+ saved_out_file_name = xstrdup (out_file_name);
  out_file_name = NULL;
- as_fatal (_("The input and output files must be distinct"));
+ as_fatal (_("The input (%s, ino: %ld) and output (%s, ino: 
%ld) files must be distinct"),
+  argv[i], sib.st_ino, saved_out_file_name, 
sob.st_ino);
}
}
}
diff --git a/gas/as.h b/gas/as.h
index 52bb5a7..d97d9b5 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -375,6 +375,7 @@ COMMON int flag_noexecstack;
 
 /* name of emitted object file */
 COMMON const char *out_file_name;
+COMMON const char *saved_out_file_name;
 
 /* name of file defining extensions to the basic instruction set */
 COMMON char *insttbl_file_name;
-- 
2.7.4


___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[PATCH 2/2] gas/as.c: compare device id

2018-08-09 Thread Robert Yang
Different files may have the same inode number on different devices, for
example:

$ cat foo.c | gcc -x c - -o /dev/null

In this case, gcc will create a /tmp/foo.s, and if /tmp is a tmpfs, foo.s' ino
starts from a small number such 3, and /dev/null's ino is also small (e.g., 6),
so this is very likely to happen when there are many gcc's runs.

Compare device id will fix the problem.

Signed-off-by: Robert Yang 
---
 gas/as.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gas/as.c b/gas/as.c
index 6afe9a5..becc7d2 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1256,7 +1256,7 @@ main (int argc, char ** argv)
 
  if (stat (argv[i], &sib) == 0)
{
- if (sib.st_ino == sob.st_ino && sib.st_ino != 0)
+ if (sib.st_ino == sob.st_ino && sib.st_ino != 0 && sib.st_dev == 
sib.st_dev)
{
  /* Don't let as_fatal remove the output file!  */
  saved_out_file_name = xstrdup (out_file_name);
-- 
2.7.4


___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils