From: Alan Modra Date: Mon, 7 Apr 2014 04:14:50 +0000 (+0930) Subject: Report an error on objcopy/strip of sectionless binaries X-Git-Tag: gdb-7.8-release~645 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5063a42103f83b921b0b6899acdd5d4d920fdc36;p=thirdparty%2Fbinutils-gdb.git Report an error on objcopy/strip of sectionless binaries All strip operations require section headers to be present, as do most objcopy operations. BFD is seriously confused by objects without section info. The error message added here is similar to the error on attempting to strip/objcopy a zero length object. PR binutils/16811 * objcopy.c (copy_object): Error if no sections. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 931d9d080dc..56df68f03c1 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2014-04-07 Alan Modra + + PR binutils/16811 + * objcopy.c (copy_object): Error if no sections. + 2014-04-03 Markus Trippelsdorf PR binutils/14698 diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 6215919bb7c..873908c688d 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),