X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fobjcopy.c;h=3866c7f458861dd522a44e07b20d8485f66719b1;hb=c5316fc6e634858a3821e612e613342da562e0b3;hp=e6711a99fb2f0324c8f7edea21580daa061cfdaa;hpb=9cc89dc0acc140cb27e21d2597af42d36444673b;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/objcopy.c b/binutils/objcopy.c index e6711a99fb..3866c7f458 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -2774,6 +2774,11 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) file_alignment, section_alignment); } + + if (preserve_dates + && bfd_get_flavour (ibfd) == bfd_target_coff_flavour + && bfd_pei_p (ibfd)) + pe->timestamp = pe_data (ibfd)->coff.timestamp; } if (isympp) @@ -2978,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) { @@ -2995,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) { @@ -3011,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) @@ -4293,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; } } @@ -4317,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; } @@ -4326,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); } } }