2009-04-24 H.J. Lu * objcopy.c (copy_object): Call bfd_copy_private_bfd_data before changing PE parameters. Index: binutils/objcopy.c =================================================================== --- binutils/objcopy.c (revision 5816) +++ binutils/objcopy.c (working copy) @@ -1412,6 +1412,7 @@ copy_object (bfd *ibfd, bfd *obfd) void *dhandle; enum bfd_architecture iarch; unsigned int imach; + bfd_boolean copy_private_bfd_data = TRUE; if (ibfd->xvec->byteorder != obfd->xvec->byteorder && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN @@ -1491,6 +1492,15 @@ copy_object (bfd *ibfd, bfd *obfd) /* Set up PE parameters. */ pe_data_type *pe = pe_data (obfd); + /* Copy PE parameters before changing them. */ + copy_private_bfd_data = FALSE; + if (! bfd_copy_private_bfd_data (ibfd, obfd)) + { + bfd_nonfatal_message (NULL, obfd, NULL, + _("error copying private BFD data")); + return FALSE; + } + if (pe_file_alignment != (bfd_vma) -1) pe->pe_opthdr.FileAlignment = pe_file_alignment; else @@ -1913,7 +1923,8 @@ copy_object (bfd *ibfd, bfd *obfd) from the input BFD to the output BFD. This is done last to permit the routine to look at the filtered symbol table, which is important for the ECOFF code at least. */ - if (! bfd_copy_private_bfd_data (ibfd, obfd)) + if (copy_private_bfd_data + && ! bfd_copy_private_bfd_data (ibfd, obfd)) { bfd_nonfatal_message (NULL, obfd, NULL, _("error copying private BFD data"));