summaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-04-15 01:33:13 +0930
committerAlan Modra <amodra@gmail.com>2021-04-15 14:16:55 +0930
commitd0ecdcddc363ad7f05fc50cf1eee4028fa7f8964 (patch)
tree2c075eb545457086b9749fbdeae5d28b9b62cda0 /binutils/objcopy.c
parentddfe525f2875e76e0c32ff348fc0d3d6aa5fb4a3 (diff)
Make objcopy -p work when an output file is specified
More fallout from the PR27456 fixes. PR 27456 * rename.c (smart_rename): When TO and FROM are equal, just set file timestamp. * objcopy.c (strip_main, copy_main): Always call smart_rename.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 3b6a7e5016..946802ebb7 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4864,10 +4864,9 @@ strip_main (int argc, char *argv[])
output_target, NULL);
if (status == 0)
{
- if (output_file != tmpname)
- status = smart_rename (tmpname,
- output_file ? output_file : argv[i],
- copyfd, &statbuf, preserve_dates) != 0;
+ const char *oname = output_file ? output_file : argv[i];
+ status = smart_rename (tmpname, oname, copyfd,
+ &statbuf, preserve_dates) != 0;
if (status == 0)
status = hold_status;
}
@@ -5949,9 +5948,9 @@ copy_main (int argc, char *argv[])
output_target, input_arch);
if (status == 0)
{
- if (tmpname != output_filename)
- status = smart_rename (tmpname, input_filename, copyfd,
- &statbuf, preserve_dates) != 0;
+ const char *oname = output_filename ? output_filename : input_filename;
+ status = smart_rename (tmpname, oname, copyfd,
+ &statbuf, preserve_dates) != 0;
}
else
{