aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-05-13 11:15:59 +0000
committerNick Clifton <nickc@redhat.com>2003-05-13 11:15:59 +0000
commit0fcdcb91886d295168c7b4fc9dca7264aa516956 (patch)
tree2b1ff3372ae60318291c7dcebf635e59030d8c22 /binutils/objcopy.c
parent3959a22a502d16d780418a4c32083d383a6ef553 (diff)
downloadgdb-0fcdcb91886d295168c7b4fc9dca7264aa516956.zip
gdb-0fcdcb91886d295168c7b4fc9dca7264aa516956.tar.gz
gdb-0fcdcb91886d295168c7b4fc9dca7264aa516956.tar.bz2
Treat identical src/dst file names as if only one entered. One Windows
creating an output file of the same name as the input file will delete the input file before it is read.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 4507249..27c844f 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2733,9 +2733,10 @@ copy_main (argc, argv)
if (stat (input_filename, & statbuf) < 0)
fatal (_("Cannot stat: %s: %s"), input_filename, strerror (errno));
- /* If there is no destination file then create a temp and rename
- the result into the input. */
- if (output_filename == (char *) NULL)
+ /* If there is no destination file, or the source and destination files
+ are the same, then create a temp and rename the result into the input. */
+ if ((output_filename == (char *) NULL) ||
+ (strcmp (input_filename, output_filename) == 0))
{
char *tmpname = make_tempname (input_filename);