gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / binutils / objcopy.c
index 738ef4c2c9135742d6c0518a3bac631574e8fa58..3866c7f458861dd522a44e07b20d8485f66719b1 100644 (file)
@@ -2983,6 +2983,9 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 
       for (pdump = dump_sections; pdump != NULL; pdump = pdump->next)
        {
+         FILE * f;
+         bfd_byte *contents;
+
          osec = bfd_get_section_by_name (ibfd, pdump->name);
          if (osec == NULL)
            {
@@ -3000,14 +3003,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
            }
 
          bfd_size_type size = bfd_section_size (osec);
-         if (size == 0)
-           {
-             bfd_nonfatal_message (NULL, ibfd, osec,
-                                   _("can't dump section - it is empty"));
-             continue;
-           }
+         /* Note - we allow the dumping of zero-sized sections.  */
 
-         FILE * f;
          f = fopen (pdump->filename, FOPEN_WB);
          if (f == NULL)
            {
@@ -3016,7 +3013,6 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
              continue;
            }
 
-         bfd_byte *contents;
          if (bfd_malloc_and_get_section (ibfd, osec, &contents))
            {
              if (fwrite (contents, 1, size, f) != size)
@@ -4298,6 +4294,7 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
              status = 1;
              bfd_nonfatal_message (NULL, ibfd, isection,
                                    _("relocation count is negative"));
+             free (relpp);
              return;
            }
        }
@@ -4322,7 +4319,7 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
                  temp_relpp [temp_relcount++] = relpp [i];
            }
          relcount = temp_relcount;
-         if (isection->orelocation == NULL)
+         if (relpp != isection->orelocation)
            free (relpp);
          relpp = temp_relpp;
        }
@@ -4331,7 +4328,8 @@ copy_relocations_in_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
       if (relcount == 0)
        {
          osection->flags &= ~SEC_RELOC;
-         free (relpp);
+         if (relpp != isection->orelocation)
+           free (relpp);
        }
     }
 }
This page took 0.024303 seconds and 4 git commands to generate.