diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2018-08-14 12:22:35 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-08-14 12:22:35 +0100 |
commit | 2a50366ded329bfb39d387253450c9d5302c3503 (patch) | |
tree | 3e94a8baeff1e9d05dadc08a896ebf4812fa9032 /gas | |
parent | 08887f4a644fb31fd04faa4208c523dbf9b4f93b (diff) | |
download | gdb-2a50366ded329bfb39d387253450c9d5302c3503.zip gdb-2a50366ded329bfb39d387253450c9d5302c3503.tar.gz gdb-2a50366ded329bfb39d387253450c9d5302c3503.tar.bz2 |
When the assembler reports that the input and output are the same, report the file names involved, in order to help debugging. Also do not equate two files are the same if the have the same inode value but reside on different file systems.
* as.c (main): Improve check for input file matching output file.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 4 | ||||
-rw-r--r-- | gas/as.c | 27 |
2 files changed, 24 insertions, 7 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index b61b995..5adf8cb 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +2018-08-14 Robert Yang <liezhi.yang@windriver.com> + + * as.c (main): Improve check for input file matching output file. + 2018-08-11 H.J. Lu <hongjiu.lu@intel.com> * config/tc-i386.c (cpu_arch): Add .cmov and .fxsr. @@ -1259,14 +1259,27 @@ main (int argc, char ** argv) { struct stat sib; - if (stat (argv[i], &sib) == 0) + /* Check that the input file and output file are different. */ + if (stat (argv[i], &sib) == 0 + && sib.st_ino == sob.st_ino + /* POSIX emulating systems may support stat() but if the + underlying file system does not support a file serial number + of some kind then they will return 0 for the inode. So + two files with an inode of 0 may not actually be the same. + On real POSIX systems no ordinary file will ever have an + inode of 0. */ + && sib.st_ino != 0 + /* Different files may have the same inode number if they + reside on different devices, so check the st_dev field as + well. */ + && sib.st_dev == sob.st_dev) { - if (sib.st_ino == sob.st_ino && sib.st_ino != 0) - { - /* Don't let as_fatal remove the output file! */ - out_file_name = NULL; - as_fatal (_("The input and output files must be distinct")); - } + const char *saved_out_file_name = out_file_name; + + /* Don't let as_fatal remove the output file! */ + out_file_name = NULL; + as_fatal (_("The input '%s' and output '%s' files are the same"), + argv[i], saved_out_file_name); } } } |