X-Git-Url: http://drtracing.org/?a=blobdiff_plain;ds=sidebyside;f=binutils%2Fobjcopy.c;h=3866c7f458861dd522a44e07b20d8485f66719b1;hb=ec8cec5b96e2ebbd5e25a737c69d311970a8b219;hp=738ef4c2c9135742d6c0518a3bac631574e8fa58;hpb=00386881a3d0f7ac89fcc5cc912da8cd69c04324;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 738ef4c2c9..3866c7f458 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -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); } } }