* objcopy.c (copy_object): Catch the case where an attempt is made to add a
authorNick Clifton <nickc@redhat.com>
Mon, 30 Jan 2006 13:06:53 +0000 (13:06 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 30 Jan 2006 13:06:53 +0000 (13:06 +0000)
    section that already exists and produce a more helpful warning message.

binutils/ChangeLog
binutils/objcopy.c

index 133cd20e8576768e2273f536cd3e7448dddc1543..f181bdf9ae5be9a94489594740544bd65c6e563f 100644 (file)
@@ -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.
index 1d19fa8cebf74c2731b414ddb6e8dd7e8d78b10c..a9fb877ec081d9201b3a9c48f14473ab68ba6a7f 100644 (file)
@@ -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))
            {
This page took 0.037982 seconds and 4 git commands to generate.