This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR binutils/5307: objcopy PE<->EFI doesn't work when both PE/EFI are enabled
- From: "H.J. Lu" <hjl at lucon dot org>
- To: binutils at sources dot redhat dot com
- Date: Mon, 12 Nov 2007 06:08:16 -0800
- Subject: PATCH: PR binutils/5307: objcopy PE<->EFI doesn't work when both PE/EFI are enabled
objcopy sets pe_opthdr.Subsystem in _bfd_XXi_swap_aouthdr_out if it is
IMAGE_SUBSYSTEM_UNKNOWN. But _bfd_XX_bfd_copy_private_bfd_data_common
copies pe_opthdr.Subsystem from input to output so that
pe_opthdr.Subsystem is never changed. This patch sets
pe_opthdr.Subsystem to IMAGE_SUBSYSTEM_UNKNOWN if output is different
from input.
H.J.
----
2007-11-12 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/5307
* peXXigen.c (_bfd_XX_bfd_copy_private_bfd_data_common): Don't
copy input subsystem if output is different from input.
--- bfd/peXXigen.c.sub 2007-07-03 19:35:09.000000000 -0700
+++ bfd/peXXigen.c 2007-11-11 20:23:11.000000000 -0800
@@ -1987,13 +1987,22 @@ _bfd_XX_print_private_bfd_data_common (b
bfd_boolean
_bfd_XX_bfd_copy_private_bfd_data_common (bfd * ibfd, bfd * obfd)
{
+ pe_data_type *ipe, *ope;
+
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_coff_flavour
|| obfd->xvec->flavour != bfd_target_coff_flavour)
return TRUE;
- pe_data (obfd)->pe_opthdr = pe_data (ibfd)->pe_opthdr;
- pe_data (obfd)->dll = pe_data (ibfd)->dll;
+ ipe = pe_data (ibfd);
+ ope = pe_data (obfd);
+
+ ope->pe_opthdr = ipe->pe_opthdr;
+ ope->dll = ipe->dll;
+
+ /* Don't copy input subsystem if output is different from input. */
+ if (obfd->xvec != ibfd->xvec)
+ ope->pe_opthdr.Subsystem = IMAGE_SUBSYSTEM_UNKNOWN;
/* For strip: if we removed .reloc, we'll make a real mess of things
if we don't remove this entry as well. */