aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-12-04 18:24:07 +0000
committerNick Clifton <nickc@redhat.com>2003-12-04 18:24:07 +0000
commitf57a841aea536a33e06a67c13bb15245742ba330 (patch)
tree420b90c76d4d46bd6b0cfba0124eaee82e9686e5 /binutils/objcopy.c
parent2051433802d3710a2c35c6eed4f9990ea30e812f (diff)
downloadgdb-f57a841aea536a33e06a67c13bb15245742ba330.zip
gdb-f57a841aea536a33e06a67c13bb15245742ba330.tar.gz
gdb-f57a841aea536a33e06a67c13bb15245742ba330.tar.bz2
Do not copy the object if the output file's format cannot be set to that of
the input file. If the input file's format is unknown, fail.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 6807aac..2589017 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1138,9 +1138,19 @@ copy_object (bfd *ibfd, bfd *obfd)
if (!bfd_set_arch_mach (obfd, iarch, imach)
&& (ibfd->target_defaulted
|| bfd_get_arch (ibfd) != bfd_get_arch (obfd)))
- non_fatal (_("Warning: Output file cannot represent architecture %s"),
- bfd_printable_arch_mach (bfd_get_arch (ibfd),
- bfd_get_mach (ibfd)));
+ {
+ if (bfd_get_arch (ibfd) == bfd_arch_unknown)
+ fatal (_("Unable to recognise the format of the input file %s"),
+ bfd_get_filename (ibfd));
+ else
+ {
+ non_fatal (_("Warning: Output file cannot represent architecture %s"),
+ bfd_printable_arch_mach (bfd_get_arch (ibfd),
+ bfd_get_mach (ibfd)));
+ status = 1;
+ return;
+ }
+ }
if (!bfd_set_format (obfd, bfd_get_format (ibfd)))
RETURN_NONFATAL (bfd_get_filename (ibfd));