diff options
author | Nick Clifton <nickc@redhat.com> | 2006-01-30 13:06:53 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2006-01-30 13:06:53 +0000 |
commit | c8782eeec392f4d5166f6f69b5dcf01a3ac24c74 (patch) | |
tree | 4f00d77bc377e6e2ec32bcfd05d01df0e32a9d9d | |
parent | 790433a9e137297eda7547b5a62e268731afbe8d (diff) | |
download | binutils-gdb-c8782eeec392f4d5166f6f69b5dcf01a3ac24c74.tar.gz |
* objcopy.c (copy_object): Catch the case where an attempt is made to add a
section that already exists and produce a more helpful warning message.
-rw-r--r-- | binutils/ChangeLog | 6 | ||||
-rw-r--r-- | binutils/objcopy.c | 18 |
2 files changed, 20 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 133cd20e857..f181bdf9ae5 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2006-01-30 Nick Clifton <nickc@redhat.com> + + * objcopy.c (copy_object): Catch the case where an attempt is made + to add a section that already exists and produce a more helpful + warning message. + 2006-01-26 Nick Clifton <nickc@redhat.com> * po/vi.po: New Vietnamese translation. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 1d19fa8cebf..a9fb877ec08 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1313,13 +1313,23 @@ copy_object (bfd *ibfd, bfd *obfd) if (pset != NULL && pset->set_flags) flags = pset->flags | SEC_HAS_CONTENTS; - padd->section = bfd_make_section_with_flags (obfd, padd->name, flags); - if (padd->section == NULL) + /* bfd_make_section_with_flags() does not return very helpful + error codes, so check for the most likely user error first. */ + if (bfd_get_section_by_name (obfd, padd->name)) { - non_fatal (_("can't create section `%s': %s"), - padd->name, bfd_errmsg (bfd_get_error ())); + non_fatal (_("can't add section '%s' - it already exists!"), padd->name); return FALSE; } + else + { + padd->section = bfd_make_section_with_flags (obfd, padd->name, flags); + if (padd->section == NULL) + { + non_fatal (_("can't create section `%s': %s"), + padd->name, bfd_errmsg (bfd_get_error ())); + return FALSE; + } + } if (! bfd_set_section_size (obfd, padd->section, padd->size)) { |