X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Fobjcopy.c;h=873908c688d3d6b450dfe6f6e4faf147b3d45848;hb=1547d98f5a774617b38f2bdd9be3b5c21c2b9312;hp=cb2be497b837b97b17ff1a81a587ca7a58c708e5;hpb=4b95cf5c0c75d6efc1b2f96af72317aecca079f1;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/objcopy.c b/binutils/objcopy.c index cb2be497b8..873908c688 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1598,6 +1598,13 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) return FALSE; } + if (ibfd->sections == NULL) + { + non_fatal (_("error: the input file '%s' has no sections"), + bfd_get_archive_filename (ibfd)); + return FALSE; + } + if (verbose) printf (_("copy from `%s' [%s] to `%s' [%s]\n"), bfd_get_archive_filename (ibfd), bfd_get_target (ibfd), @@ -1875,7 +1882,12 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) bfd_byte * contents = xmalloc (size); if (bfd_get_section_contents (ibfd, sec, contents, 0, size)) - fwrite (contents, 1, size, f); + { + if (fwrite (contents, 1, size, f) != size) + fatal (_("error writing section contents to %s (error: %s)"), + pdump->filename, + strerror (errno)); + } else bfd_nonfatal_message (NULL, ibfd, sec, _("could not retrieve section contents"));