This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Report an error on objcopy/strip of sectionless binaries
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 7 Apr 2014 15:11:40 +0930
- Subject: Report an error on objcopy/strip of sectionless binaries
- Authentication-results: sourceware.org; auth=none
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/objcopy.c b/binutils/objcopy.c
index 6215919..873908c 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),
--
Alan Modra
Australia Development Lab, IBM