From f57a841aea536a33e06a67c13bb15245742ba330 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 4 Dec 2003 18:24:07 +0000 Subject: 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. --- binutils/ChangeLog | 6 ++++++ binutils/objcopy.c | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'binutils') diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 526fb12..77f21b0 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2003-12-04 Nick Clifton + + * objcopy.c (copy_object): 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. + 2003-11-28 Ian Lance Taylor * cxxfilt.c (usage): Mention new -p/--no-params options. 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)); -- cgit v1.1