aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-04-07 13:44:50 +0930
committerAlan Modra <amodra@gmail.com>2014-04-07 13:59:31 +0930
commit5063a42103f83b921b0b6899acdd5d4d920fdc36 (patch)
tree6f4061fb293067a8be046a4d10367b85472e2c8a /binutils/objcopy.c
parent27f0d6b4fe4888e3bb0bdc8e64af51c521fa9f1d (diff)
downloadgdb-5063a42103f83b921b0b6899acdd5d4d920fdc36.zip
gdb-5063a42103f83b921b0b6899acdd5d4d920fdc36.tar.gz
gdb-5063a42103f83b921b0b6899acdd5d4d920fdc36.tar.bz2
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.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c7
1 files changed, 7 insertions, 0 deletions
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),