bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 17 Apr 2009 13:46:18 +0000 (13:46 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 17 Apr 2009 13:46:18 +0000 (13:46 +0000)
2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>

PR binutils/10074
* coffcode.h (bfd_pei_p): New.

* config.bfd: Remove bfd_efi_bsdrv_ia32_vec,
bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
bfd_efi_rtdrv_x86_64_vec, bfd_efi_bsdrv_ia64_vec and
bfd_efi_rtdrv_ia64_vec.  Replace bfd_efi_app_ia32_vec,
bfd_efi_app_x86_64_vec and bfd_efi_app_ia64_vec with
i386pei_vec, x86_64pei_vec and bfd_pei_ia64_vec, respectively.

* configure.in: Remove bfd_efi_bsdrv_ia32_vec,
bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
bfd_efi_rtdrv_x86_64_vec,
bfd_efi_bsdrv_ia64_vec and bfd_efi_rtdrv_ia64_vec.  Replace
bfd_efi_ia64_vec with bfd_pei_ia64_vec.
* targets.c: Likewise.

* configure: Regenerated.
* libcoff.h: Likewise.
* Makefile.in: Likewise.

* efi-app-ia32.c: Removed.
* efi-app-x86_64.c: Likewise.
* efi-bsdrv-ia32.c: Likewise.
* efi-bsdrv-ia64.c: Likewise.
* efi-bsdrv-x86_64.c: Likewise.
* efi-rtdrv-ia32.c: Likewise.
* efi-rtdrv-ia64.c: Likewise.
* efi-rtdrv-x86_64.c: Likewise.
* efi-rtdrv-ia32.c: Likewise.

* efi-app-ia64.c: Moved to ...
* pei-ia64.c: This.
(TARGET_SYM): Set to bfd_pei_ia64_vec.
(TARGET_NAME): Set to pei-ia64.

* libpei.h (bfd_target_pei_p): Removed.
(bfd_target_pei_arch): Likewise.
(bfd_target_efi_app_p): Likewise.
(bfd_target_efi_app_arch): Likewise.
(bfd_target_efi_bsdrv_p): Likewise.
(bfd_target_efi_bsdrv_arch): Likewise.
(bfd_target_efi_rtdrv_p): Likewise.
(bfd_target_efi_rtdrv_arch): Likewise.
(bfd_pe_executable_p): Likewise.

* Makefile.am (BFD32_BACKENDS): Remove efi-app-ia32.lo,
efi-bsdrv-ia32.lo and efi-rtdrv-ia32.lo.
(BFD32_BACKENDS_CFILES): Remove efi-app-ia32.c, efi-bsdrv-ia32.c
and efi-rtdrv-ia32.c.
(BFD64_BACKENDS): Remove efi-app-ia64.lo, efi-bsdrv-ia64.lo,
efi-rtdrv-ia64.lo, efi-app-x86_64.lo, efi-bsdrv-x86_64.lo and
efi-rtdrv-x86_64.lo. Add pei-ia64.lo.
(BFD64_BACKENDS_CFILES): Remove efi-app-ia64.c, efi-bsdrv-ia64.c,
efi-rtdrv-ia64.c, efi-app-x86_64.c, efi-bsdrv-x86_64.c and
efi-rtdrv-x86_64.c. Add pei-ia64.c.
(efi-app-ia64.lo): Removed.
(efi-bsdrv-ia32.lo): Likewise.
(efi-rtdrv-ia32.lo): Likewise.
(efi-app-ia64.lo): Likewise.
(efi-bsdrv-ia64.lo): Likewise.
(efi-rtdrv-ia64.lo): Likewise.
(efi-app-x86_64.lo): Likewise.
(efi-bsdrv-x86_64.lo): Likewise.
(efi-rtdrv-x86_64.lo): Likewise.
(pei-ia64.lo): New.

* peicode.h (coff_swap_scnhdr_in): Replace bfd_pe_executable_p
with bfd_pei_p.
(arch_type): Removed.
(pe_arch): Likewise.
(pe_bfd_object_p): Just return coff_object_p.

* peXXigen.c (_bfd_XXi_swap_scnhdr_out): Replace
bfd_pe_executable_p with bfd_pei_p.

binutils/

2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>

PR binutils/10074
* objcopy.c: Include coff/i386.h and coff/pe.h.
(pe_file_alignment): New.
(pe_heap_commit): Likewise.
(pe_heap_reserve): Likewise.
(pe_image_base): Likewise.
(pe_section_alignment): Likewise.
(pe_stack_commit): Likewise.
(pe_stack_reserve): Likewise.
(pe_subsystem): Likewise.
(pe_major_subsystem_version): Likewise.
(pe_minor_subsystem_version): Likewise.
(set_pe_subsystem): Likewise.
(convert_efi_target): Likewise.
(command_line_switch): Add OPTION_FILE_ALIGNMENT,
OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
OPTION_STACK and OPTION_SUBSYSTEM.
(copy_options): Likewise.
(copy_usage): Add --file-alignment, --heap, --image-base,
--section-alignment, --stack and --subsystem.
(copy_object): Set up PE parameters.
(copy_main): Process Add OPTION_FILE_ALIGNMENT,
OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
OPTION_STACK and OPTION_SUBSYSTEM.   Convert EFI target to
PEI target.

* NEWS: Mention --file-alignment, --heap, --image-base,
--section-alignment, --stack and --subsystem command line
options for objcopy.

* doc/binutils.texi: Document --file-alignment, --heap,
--image-base, --section-alignment, --stack and --subsystem
command line options for objcopy.

26 files changed:
bfd/ChangeLog
bfd/Makefile.am
bfd/Makefile.in
bfd/coffcode.h
bfd/config.bfd
bfd/configure
bfd/configure.in
bfd/efi-app-ia32.c [deleted file]
bfd/efi-app-ia64.c [deleted file]
bfd/efi-app-x86_64.c [deleted file]
bfd/efi-bsdrv-ia32.c [deleted file]
bfd/efi-bsdrv-ia64.c [deleted file]
bfd/efi-bsdrv-x86_64.c [deleted file]
bfd/efi-rtdrv-ia32.c [deleted file]
bfd/efi-rtdrv-ia64.c [deleted file]
bfd/efi-rtdrv-x86_64.c [deleted file]
bfd/libcoff.h
bfd/libpei.h
bfd/peXXigen.c
bfd/pei-ia64.c [new file with mode: 0644]
bfd/peicode.h
bfd/targets.c
binutils/ChangeLog
binutils/NEWS
binutils/doc/binutils.texi
binutils/objcopy.c

index 894c497e97c15a839fae73f2cc6a1ffc111bd871..8f85d19b7c3489793fb8fcf0b37300b998b3350c 100644 (file)
@@ -1,3 +1,81 @@
+2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/10074
+       * coffcode.h (bfd_pei_p): New.
+
+       * config.bfd: Remove bfd_efi_bsdrv_ia32_vec,
+       bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
+       bfd_efi_rtdrv_x86_64_vec, bfd_efi_bsdrv_ia64_vec and
+       bfd_efi_rtdrv_ia64_vec.  Replace bfd_efi_app_ia32_vec,
+       bfd_efi_app_x86_64_vec and bfd_efi_app_ia64_vec with
+       i386pei_vec, x86_64pei_vec and bfd_pei_ia64_vec, respectively.
+
+       * configure.in: Remove bfd_efi_bsdrv_ia32_vec,
+       bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
+       bfd_efi_rtdrv_x86_64_vec,
+       bfd_efi_bsdrv_ia64_vec and bfd_efi_rtdrv_ia64_vec.  Replace
+       bfd_efi_ia64_vec with bfd_pei_ia64_vec.
+       * targets.c: Likewise.
+
+       * configure: Regenerated.
+       * libcoff.h: Likewise.
+       * Makefile.in: Likewise.
+
+       * efi-app-ia32.c: Removed.
+       * efi-app-x86_64.c: Likewise.
+       * efi-bsdrv-ia32.c: Likewise.
+       * efi-bsdrv-ia64.c: Likewise.
+       * efi-bsdrv-x86_64.c: Likewise.
+       * efi-rtdrv-ia32.c: Likewise.
+       * efi-rtdrv-ia64.c: Likewise.
+       * efi-rtdrv-x86_64.c: Likewise.
+       * efi-rtdrv-ia32.c: Likewise.
+
+       * efi-app-ia64.c: Moved to ...
+       * pei-ia64.c: This.
+       (TARGET_SYM): Set to bfd_pei_ia64_vec.
+       (TARGET_NAME): Set to pei-ia64.
+
+       * libpei.h (bfd_target_pei_p): Removed.
+       (bfd_target_pei_arch): Likewise.
+       (bfd_target_efi_app_p): Likewise.
+       (bfd_target_efi_app_arch): Likewise.
+       (bfd_target_efi_bsdrv_p): Likewise.
+       (bfd_target_efi_bsdrv_arch): Likewise.
+       (bfd_target_efi_rtdrv_p): Likewise.
+       (bfd_target_efi_rtdrv_arch): Likewise.
+       (bfd_pe_executable_p): Likewise.
+
+       * Makefile.am (BFD32_BACKENDS): Remove efi-app-ia32.lo,
+       efi-bsdrv-ia32.lo and efi-rtdrv-ia32.lo.
+       (BFD32_BACKENDS_CFILES): Remove efi-app-ia32.c, efi-bsdrv-ia32.c
+       and efi-rtdrv-ia32.c.
+       (BFD64_BACKENDS): Remove efi-app-ia64.lo, efi-bsdrv-ia64.lo,
+       efi-rtdrv-ia64.lo, efi-app-x86_64.lo, efi-bsdrv-x86_64.lo and
+       efi-rtdrv-x86_64.lo. Add pei-ia64.lo.
+       (BFD64_BACKENDS_CFILES): Remove efi-app-ia64.c, efi-bsdrv-ia64.c,
+       efi-rtdrv-ia64.c, efi-app-x86_64.c, efi-bsdrv-x86_64.c and
+       efi-rtdrv-x86_64.c. Add pei-ia64.c.
+       (efi-app-ia64.lo): Removed.
+       (efi-bsdrv-ia32.lo): Likewise.
+       (efi-rtdrv-ia32.lo): Likewise.
+       (efi-app-ia64.lo): Likewise.
+       (efi-bsdrv-ia64.lo): Likewise.
+       (efi-rtdrv-ia64.lo): Likewise.
+       (efi-app-x86_64.lo): Likewise.
+       (efi-bsdrv-x86_64.lo): Likewise.
+       (efi-rtdrv-x86_64.lo): Likewise.
+       (pei-ia64.lo): New.
+
+       * peicode.h (coff_swap_scnhdr_in): Replace bfd_pe_executable_p
+       with bfd_pei_p.
+       (arch_type): Removed.
+       (pe_arch): Likewise.
+       (pe_bfd_object_p): Just return coff_object_p.
+
+       * peXXigen.c (_bfd_XXi_swap_scnhdr_out): Replace
+       bfd_pe_executable_p with bfd_pei_p.
+
 2009-04-17  Christophe Lyon  <christophe.lyon@st.com>
 
        * elf32-arm.c (elf32_arm_size_stubs): Handle long branches through
index 683599ada7d9318619ada3965881914cd3cbfb67..771d5557f87ac91a6bf830a4fe3b8fe3347f585e 100644 (file)
@@ -242,9 +242,6 @@ BFD32_BACKENDS = \
        dwarf1.lo \
        ecoff.lo \
        ecofflink.lo \
-       efi-app-ia32.lo \
-       efi-bsdrv-ia32.lo \
-       efi-rtdrv-ia32.lo \
        elf.lo \
        elf32-am33lin.lo \
        elf32-arc.lo \
@@ -425,9 +422,6 @@ BFD32_BACKENDS_CFILES = \
        dwarf1.c \
        ecoff.c \
        ecofflink.c \
-       efi-app-ia32.c \
-       efi-bsdrv-ia32.c \
-       efi-rtdrv-ia32.c \
        elf.c \
        elf32-am33lin.c \
        elf32-arc.c \
@@ -573,12 +567,7 @@ BFD64_BACKENDS = \
        coff-alpha.lo \
        coff64-rs6000.lo \
        demo64.lo \
-       efi-app-ia64.lo \
-       efi-bsdrv-ia64.lo \
-       efi-rtdrv-ia64.lo \
-       efi-app-x86_64.lo \
-       efi-bsdrv-x86_64.lo \
-       efi-rtdrv-x86_64.lo \
+       pei-ia64.lo \
        elf64-x86-64.lo \
        elf64-alpha.lo \
        elf64-hppa.lo \
@@ -610,12 +599,7 @@ BFD64_BACKENDS_CFILES = \
        coff-alpha.c \
        coff64-rs6000.c \
        demo64.c \
-       efi-app-ia64.c \
-       efi-bsdrv-ia64.c \
-       efi-rtdrv-ia64.c \
-       efi-app-x86_64.c \
-       efi-bsdrv-x86_64.c \
-       efi-rtdrv-x86_64.c \
+       pei-ia64.c \
        elf64-x86-64.c \
        elf64-alpha.c \
        elf64-hppa.c \
@@ -1346,21 +1330,6 @@ ecofflink.lo: ecofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h \
   $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h libcoff.h \
   libecoff.h
-efi-app-ia32.lo: efi-app-ia32.c $(INCDIR)/filenames.h \
-  coff-i386.c $(INCDIR)/hashtab.h $(INCDIR)/coff/i386.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-bsdrv-ia32.lo: efi-bsdrv-ia32.c $(INCDIR)/filenames.h \
-  coff-i386.c $(INCDIR)/hashtab.h $(INCDIR)/coff/i386.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-rtdrv-ia32.lo: efi-rtdrv-ia32.c $(INCDIR)/filenames.h \
-  coff-i386.c $(INCDIR)/hashtab.h $(INCDIR)/coff/i386.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
 elf.lo: elf.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h $(INCDIR)/libiberty.h \
@@ -1909,36 +1878,11 @@ demo64.lo: demo64.c aoutf1.h $(INCDIR)/filenames.h \
   $(INCDIR)/hashtab.h $(INCDIR)/aout/sun4.h libaout.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
   $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-efi-app-ia64.lo: efi-app-ia64.c $(INCDIR)/filenames.h \
+pei-ia64.lo: pei-ia64.c $(INCDIR)/filenames.h \
   coff-ia64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/ia64.h \
   $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
   $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
   peicode.h libpei.h
-efi-bsdrv-ia64.lo: efi-bsdrv-ia64.c $(INCDIR)/filenames.h \
-  coff-ia64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/ia64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-rtdrv-ia64.lo: efi-rtdrv-ia64.c $(INCDIR)/filenames.h \
-  coff-ia64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/ia64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-app-x86_64.lo: efi-app-x86_64.c $(INCDIR)/filenames.h \
-  coff-x86_64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/x86_64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h \
-  coffcode.h peicode.h libpei.h
-efi-bsdrv-x86_64.lo: efi-bsdrv-x86_64.c $(INCDIR)/filenames.h \
-  coff-x86_64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/x86_64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h \
-  coffcode.h peicode.h libpei.h
-efi-rtdrv-x86_64.lo: efi-rtdrv-x86_64.c $(INCDIR)/filenames.h \
-  coff-x86_64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/x86_64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h \
-  coffcode.h peicode.h libpei.h
 elf64-x86-64.lo: elf64-x86-64.c $(INCDIR)/filenames.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h bfd_stdint.h \
index 24c8ee16b035af1c173955b187b09240ded203b7..1a00c47cc78aa146f114b57ad248b00dfe9ddd1a 100644 (file)
@@ -509,9 +509,6 @@ BFD32_BACKENDS = \
        dwarf1.lo \
        ecoff.lo \
        ecofflink.lo \
-       efi-app-ia32.lo \
-       efi-bsdrv-ia32.lo \
-       efi-rtdrv-ia32.lo \
        elf.lo \
        elf32-am33lin.lo \
        elf32-arc.lo \
@@ -692,9 +689,6 @@ BFD32_BACKENDS_CFILES = \
        dwarf1.c \
        ecoff.c \
        ecofflink.c \
-       efi-app-ia32.c \
-       efi-bsdrv-ia32.c \
-       efi-rtdrv-ia32.c \
        elf.c \
        elf32-am33lin.c \
        elf32-arc.c \
@@ -841,12 +835,7 @@ BFD64_BACKENDS = \
        coff-alpha.lo \
        coff64-rs6000.lo \
        demo64.lo \
-       efi-app-ia64.lo \
-       efi-bsdrv-ia64.lo \
-       efi-rtdrv-ia64.lo \
-       efi-app-x86_64.lo \
-       efi-bsdrv-x86_64.lo \
-       efi-rtdrv-x86_64.lo \
+       pei-ia64.lo \
        elf64-x86-64.lo \
        elf64-alpha.lo \
        elf64-hppa.lo \
@@ -878,12 +867,7 @@ BFD64_BACKENDS_CFILES = \
        coff-alpha.c \
        coff64-rs6000.c \
        demo64.c \
-       efi-app-ia64.c \
-       efi-bsdrv-ia64.c \
-       efi-rtdrv-ia64.c \
-       efi-app-x86_64.c \
-       efi-bsdrv-x86_64.c \
-       efi-rtdrv-x86_64.c \
+       pei-ia64.c \
        elf64-x86-64.c \
        elf64-alpha.c \
        elf64-hppa.c \
@@ -1943,21 +1927,6 @@ ecofflink.lo: ecofflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/aout/stab.def $(INCDIR)/coff/internal.h $(INCDIR)/coff/sym.h \
   $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h libcoff.h \
   libecoff.h
-efi-app-ia32.lo: efi-app-ia32.c $(INCDIR)/filenames.h \
-  coff-i386.c $(INCDIR)/hashtab.h $(INCDIR)/coff/i386.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-bsdrv-ia32.lo: efi-bsdrv-ia32.c $(INCDIR)/filenames.h \
-  coff-i386.c $(INCDIR)/hashtab.h $(INCDIR)/coff/i386.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-rtdrv-ia32.lo: efi-rtdrv-ia32.c $(INCDIR)/filenames.h \
-  coff-i386.c $(INCDIR)/hashtab.h $(INCDIR)/coff/i386.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
 elf.lo: elf.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h $(INCDIR)/libiberty.h \
@@ -2506,36 +2475,11 @@ demo64.lo: demo64.c aoutf1.h $(INCDIR)/filenames.h \
   $(INCDIR)/hashtab.h $(INCDIR)/aout/sun4.h libaout.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
   $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h aout-target.h
-efi-app-ia64.lo: efi-app-ia64.c $(INCDIR)/filenames.h \
+pei-ia64.lo: pei-ia64.c $(INCDIR)/filenames.h \
   coff-ia64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/ia64.h \
   $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
   $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
   peicode.h libpei.h
-efi-bsdrv-ia64.lo: efi-bsdrv-ia64.c $(INCDIR)/filenames.h \
-  coff-ia64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/ia64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-rtdrv-ia64.lo: efi-rtdrv-ia64.c $(INCDIR)/filenames.h \
-  coff-ia64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/ia64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h coffcode.h \
-  peicode.h libpei.h
-efi-app-x86_64.lo: efi-app-x86_64.c $(INCDIR)/filenames.h \
-  coff-x86_64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/x86_64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h \
-  coffcode.h peicode.h libpei.h
-efi-bsdrv-x86_64.lo: efi-bsdrv-x86_64.c $(INCDIR)/filenames.h \
-  coff-x86_64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/x86_64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h \
-  coffcode.h peicode.h libpei.h
-efi-rtdrv-x86_64.lo: efi-rtdrv-x86_64.c $(INCDIR)/filenames.h \
-  coff-x86_64.c $(INCDIR)/hashtab.h $(INCDIR)/coff/x86_64.h \
-  $(INCDIR)/coff/external.h $(INCDIR)/coff/internal.h \
-  $(INCDIR)/coff/pe.h libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h \
-  coffcode.h peicode.h libpei.h
 elf64-x86-64.lo: elf64-x86-64.c $(INCDIR)/filenames.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
   $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h bfd_stdint.h \
index 11cc457f207da727033c23515e9ad6b22cf8b62a..312aa7758ca97320fef97693584e7053a87a5c76 100644 (file)
@@ -1560,6 +1560,10 @@ Special entry points for gdb to swap in coff symbol table parts:
 .#define bfd_coff_print_pdata(a,p) \
 .  ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
 .
+.{* Macro: Returns true if the bfd is a PE executable as opposed to a
+.   PE object file.  *}
+.#define bfd_pei_p(abfd) \
+.  (CONST_STRNEQ ((abfd)->xvec->name, "pei-"))
 */
 
 /* See whether the magic number matches.  */
index 9e9e021c15a4613dbbf5cd3d508d2ffb46755efb..56894ad558adaef9ccffe4f5ac9ada616a8ba91f 100644 (file)
@@ -179,7 +179,7 @@ case "${targ}" in
     ;;
   ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu)
     targ_defvec=bfd_elf64_ia64_little_vec
-    targ_selvecs="bfd_elf64_ia64_big_vec bfd_efi_app_ia64_vec bfd_efi_bsdrv_ia64_vec bfd_efi_rtdrv_ia64_vec"
+    targ_selvecs="bfd_elf64_ia64_big_vec bfd_pei_ia64_vec"
     want64=true
     ;;
   ia64*-*-hpux*)
@@ -556,8 +556,8 @@ case "${targ}" in
     ;;
   i[3-7]86-*-freebsd* | i[3-7]86-*-kfreebsd*-gnu | i[3-7]86-*-dragonfly*)
     targ_defvec=bfd_elf32_i386_freebsd_vec
-    targ_selvecs="bfd_elf32_i386_vec bfd_efi_app_ia32_vec bfd_efi_bsdrv_ia32_vec bfd_efi_rtdrv_ia32_vec i386coff_vec"
-    targ64_selvecs="bfd_elf64_x86_64_freebsd_vec bfd_elf64_x86_64_vec bfd_efi_app_x86_64_vec bfd_efi_bsdrv_x86_64_vec bfd_efi_rtdrv_x86_64_vec"
+    targ_selvecs="bfd_elf32_i386_vec i386pei_vec i386coff_vec"
+    targ64_selvecs="bfd_elf64_x86_64_freebsd_vec bfd_elf64_x86_64_vec x86_64pei_vec"
     # FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling.
     case "${targ}" in
       i[3-7]86-*-freebsd3* | i[3-7]86-*-freebsd4 | i[3-7]86-*-freebsd4.0*)
@@ -594,7 +594,7 @@ case "${targ}" in
     ;;
   i[3-7]86-*-linux-*)
     targ_defvec=bfd_elf32_i386_vec
-    targ_selvecs="i386linux_vec bfd_efi_app_ia32_vec bfd_efi_bsdrv_ia32_vec bfd_efi_rtdrv_ia32_vec"
+    targ_selvecs="i386linux_vec i386pei_vec"
     targ64_selvecs=bfd_elf64_x86_64_vec
     ;;
 #ifdef BFD64
@@ -616,17 +616,17 @@ case "${targ}" in
     ;;
   x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
     targ_defvec=bfd_elf64_x86_64_freebsd_vec
-    targ_selvecs="bfd_elf32_i386_freebsd_vec i386coff_vec bfd_efi_app_ia32_vec bfd_efi_bsdrv_ia32_vec bfd_efi_rtdrv_ia32_vec bfd_efi_app_x86_64_vec bfd_efi_bsdrv_x86_64_vec bfd_efi_rtdrv_x86_64_vec bfd_elf32_i386_vec bfd_elf64_x86_64_vec"
+    targ_selvecs="bfd_elf32_i386_freebsd_vec i386coff_vec i386pei_vec x86_64pei_vec bfd_elf32_i386_vec bfd_elf64_x86_64_vec"
     want64=true
     ;;
   x86_64-*-netbsd* | x86_64-*-openbsd*)
     targ_defvec=bfd_elf64_x86_64_vec
-    targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec bfd_efi_app_ia32_vec bfd_efi_bsdrv_ia32_vec bfd_efi_rtdrv_ia32_vec bfd_efi_app_x86_64_vec bfd_efi_bsdrv_x86_64_vec bfd_efi_rtdrv_x86_64_vec"
+    targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec i386pei_vec x86_64pei_vec"
     want64=true
     ;;
   x86_64-*-linux-*)
     targ_defvec=bfd_elf64_x86_64_vec
-    targ_selvecs="bfd_elf32_i386_vec i386linux_vec bfd_efi_app_ia32_vec bfd_efi_bsdrv_ia32_vec bfd_efi_rtdrv_ia32_vec bfd_efi_app_x86_64_vec bfd_efi_bsdrv_x86_64_vec bfd_efi_rtdrv_x86_64_vec"
+    targ_selvecs="bfd_elf32_i386_vec i386linux_vec i386pei_vec x86_64pei_vec"
     want64=true
     ;;
   x86_64-*-mingw*)
index 41520b24fb72f584c26ecbab5f5435072b77b8d7..3f7c69cb0e04184c1bd99259c2cecd64e0960d32 100755 (executable)
     armpei_little_vec)         tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
     b_out_vec_big_host)                tb="$tb bout.lo aout32.lo" ;;
     b_out_vec_little_host)     tb="$tb bout.lo aout32.lo" ;;
-    bfd_efi_app_ia32_vec)      tb="$tb efi-app-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_bsdrv_ia32_vec)    tb="$tb efi-bsdrv-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_rtdrv_ia32_vec)    tb="$tb efi-rtdrv-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_app_x86_64_vec)    tb="$tb efi-app-x86_64.lo pex64igen.lo cofflink.lo" ;target_size=64;;
-    bfd_efi_bsdrv_x86_64_vec)  tb="$tb efi-bsdrv-x86_64.lo pex64igen.lo cofflink.lo" ;target_size=64;;
-    bfd_efi_rtdrv_x86_64_vec)  tb="$tb efi-rtdrv-x86_64.lo pex64igen.lo cofflink.lo" ;target_size=64;;
-    bfd_efi_app_ia64_vec)      tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
-    bfd_efi_bsdrv_ia64_vec)    tb="$tb efi-bsdrv-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
-    bfd_efi_rtdrv_ia64_vec)    tb="$tb efi-rtdrv-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
+    bfd_pei_ia64_vec)          tb="$tb pei-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
     bfd_elf32_am33lin_vec)     tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
     bfd_elf32_avr_vec)         tb="$tb elf32-avr.lo elf32.lo $elf" ;;
     bfd_elf32_bfin_vec)                tb="$tb elf32-bfin.lo elf32.lo $elf" ;;
index 868730aa40f1fc8fd31a6882d65cbed19173d306..81255ddcf01072eaed88d8f18e28c1db51e116fe 100644 (file)
@@ -657,15 +657,7 @@ do
     armpei_little_vec)         tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
     b_out_vec_big_host)                tb="$tb bout.lo aout32.lo" ;;
     b_out_vec_little_host)     tb="$tb bout.lo aout32.lo" ;;
-    bfd_efi_app_ia32_vec)      tb="$tb efi-app-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_bsdrv_ia32_vec)    tb="$tb efi-bsdrv-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_rtdrv_ia32_vec)    tb="$tb efi-rtdrv-ia32.lo peigen.lo cofflink.lo" ;;
-    bfd_efi_app_x86_64_vec)    tb="$tb efi-app-x86_64.lo pex64igen.lo cofflink.lo" ;target_size=64;;
-    bfd_efi_bsdrv_x86_64_vec)  tb="$tb efi-bsdrv-x86_64.lo pex64igen.lo cofflink.lo" ;target_size=64;;
-    bfd_efi_rtdrv_x86_64_vec)  tb="$tb efi-rtdrv-x86_64.lo pex64igen.lo cofflink.lo" ;target_size=64;;
-    bfd_efi_app_ia64_vec)      tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
-    bfd_efi_bsdrv_ia64_vec)    tb="$tb efi-bsdrv-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
-    bfd_efi_rtdrv_ia64_vec)    tb="$tb efi-rtdrv-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
+    bfd_pei_ia64_vec)          tb="$tb pei-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
     bfd_elf32_am33lin_vec)     tb="$tb elf32-am33lin.lo elf32.lo $elf" ;;
     bfd_elf32_avr_vec)         tb="$tb elf32-avr.lo elf32.lo $elf" ;;
     bfd_elf32_bfin_vec)                tb="$tb elf32-bfin.lo elf32.lo $elf" ;;
diff --git a/bfd/efi-app-ia32.c b/bfd/efi-app-ia32.c
deleted file mode 100644 (file)
index aaa80c5..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* BFD back-end for Intel IA-32 EFI application files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
-   Contributed by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_app_ia32_vec
-#define TARGET_NAME "efi-app-ia32"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM   IMAGE_SUBSYSTEM_EFI_APPLICATION
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-i386.c"
diff --git a/bfd/efi-app-ia64.c b/bfd/efi-app-ia64.c
deleted file mode 100644 (file)
index 449c4c7..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* BFD back-end for HP/Intel IA-64 EFI application files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
-   Contributed by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_app_ia64_vec
-#define TARGET_NAME "efi-app-ia64"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define COFF_WITH_pep
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM           IMAGE_SUBSYSTEM_EFI_APPLICATION
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-ia64.c"
diff --git a/bfd/efi-app-x86_64.c b/bfd/efi-app-x86_64.c
deleted file mode 100644 (file)
index d2a04f3..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/* BFD back-end for Intel64 UEFI application files.
-   Copyright 2007, 2009 Free Software Foundation, Inc.
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_app_x86_64_vec
-#define TARGET_NAME "efi-app-x86_64"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define COFF_WITH_pep
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM   IMAGE_SUBSYSTEM_EFI_APPLICATION
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-x86_64.c"
diff --git a/bfd/efi-bsdrv-ia32.c b/bfd/efi-bsdrv-ia32.c
deleted file mode 100644 (file)
index 112b2b4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* BFD back-end for Intel IA-32 EFI Boot Service driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Peter Jones <pjones@redhat.com>
-   Based on efi-app-ia32.c by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_bsdrv_ia32_vec
-#define TARGET_NAME "efi-bsdrv-ia32"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM   IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-i386.c"
diff --git a/bfd/efi-bsdrv-ia64.c b/bfd/efi-bsdrv-ia64.c
deleted file mode 100644 (file)
index f08c568..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD back-end for HP/Intel IA-64 EFI Boot Service driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Peter Jones <pjones@redhat.com>
-   Based on efi-app-ia64.c by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_bsdrv_ia64_vec
-#define TARGET_NAME "efi-bsdrv-ia64"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define COFF_WITH_pep
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM           IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-ia64.c"
diff --git a/bfd/efi-bsdrv-x86_64.c b/bfd/efi-bsdrv-x86_64.c
deleted file mode 100644 (file)
index dfe00f4..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD back-end for Intel64 UEFI Boot Service driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Peter Jones <pjones@redhat.com>
-   Based on efi-app-x86_64.c by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_bsdrv_x86_64_vec
-#define TARGET_NAME "efi-bsdrv-x86_64"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define COFF_WITH_pep
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM   IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-x86_64.c"
diff --git a/bfd/efi-rtdrv-ia32.c b/bfd/efi-rtdrv-ia32.c
deleted file mode 100644 (file)
index b127cbc..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* BFD back-end for Intel IA-32 EFI runtime driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Peter Jones <pjones@redhat.com>
-   Based on efi-app-ia32.c by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_rtdrv_ia32_vec
-#define TARGET_NAME "efi-rtdrv-ia32"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM   IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-i386.c"
diff --git a/bfd/efi-rtdrv-ia64.c b/bfd/efi-rtdrv-ia64.c
deleted file mode 100644 (file)
index d93416d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD back-end for HP/Intel IA-64 EFI runtime driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Peter Jones <pjones@redhat.com>
-   Based on efi-app-ia64.c by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_rtdrv_ia64_vec
-#define TARGET_NAME "efi-rtdrv-ia64"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define COFF_WITH_pep
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM           IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-ia64.c"
diff --git a/bfd/efi-rtdrv-x86_64.c b/bfd/efi-rtdrv-x86_64.c
deleted file mode 100644 (file)
index c66b63c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* BFD back-end for Intel64 UEFI runtime driver files.
-   Copyright 1999, 2000, 2001, 2002, 2007, 2008, 2009 Free Software Foundation, Inc.
-   Contributed by Peter Jones <pjones@redhat.com>
-   Based on efi-app-x86_64.c by David Mosberger <davidm@hpl.hp.com>
-
-   This file is part of BFD, the Binary File Descriptor library.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-   MA 02110-1301, USA.  */
-
-#include "sysdep.h"
-#include "bfd.h"
-
-#define TARGET_SYM bfd_efi_rtdrv_x86_64_vec
-#define TARGET_NAME "efi-rtdrv-x86_64"
-#define COFF_IMAGE_WITH_PE
-#define COFF_WITH_PE
-#define COFF_WITH_pep
-#define PCRELOFFSET TRUE
-#define TARGET_UNDERSCORE '_'
-/* Long section names not allowed in executable images, only object files.  */
-#define COFF_LONG_SECTION_NAMES 0
-#define PEI_TARGET_SUBSYSTEM   IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER
-#define PEI_FORCE_MINIMUM_ALIGNMENT
-
-#include "coff-x86_64.c"
index a053f6bf9e2f8e1e56b428c958d613059639083e..247f1c4cc730678b0f151ab4d6028ad96756f665 100644 (file)
@@ -950,3 +950,7 @@ typedef struct
 #define bfd_coff_print_pdata(a,p) \
   ((coff_backend_info (a)->_bfd_coff_print_pdata) (a, p))
 
+/* Macro: Returns true if the bfd is a PE executable as opposed to a
+   PE object file.  */
+#define bfd_pei_p(abfd) \
+  (CONST_STRNEQ ((abfd)->xvec->name, "pei-"))
index 2178d24f76c0836e9f2a8b1c28d4a669a3798d17..f5bfa4cac389a15326d951d2cdb447b58c4c1d75 100644 (file)
 
 #endif /* !COFF_WITH_pep */
 
-/* Returns true if the target is a PE executable target.  */
-#define bfd_target_pei_p(xvec)                                 \
-  (CONST_STRNEQ ((xvec)->name, "pei-"))
-
-/* Return the arch string of a PE executable target.  */
-#define bfd_target_pei_arch(xvec)                              \
-  ((xvec)->name + sizeof ("pei-") - 1)
-
-/* Returns true if the target is an EFI application target.  */
-#define bfd_target_efi_app_p(xvec)                             \
-   (CONST_STRNEQ ((xvec)->name, "efi-app-"))
-
-/* Return the arch string of an EFI application target.  */
-#define bfd_target_efi_app_arch(xvec)                          \
-  ((xvec)->name + sizeof ("efi-app-") - 1)
-
-/* Returns true if the target is an EFI Boot Service driver target.  */
-#define bfd_target_efi_bsdrv_p(xvec)                           \
-   (CONST_STRNEQ ((xvec)->name, "efi-bsdrv-"))
-
-/* Return the arch string of an EFI Boot Service driver target.  */
-#define bfd_target_efi_bsdrv_arch(xvec)                                \
-  ((xvec)->name + sizeof ("efi-bsdrv-") - 1)
-
-/* Returns true if the target is an EFI runtime driver target.  */
-#define bfd_target_efi_rtdrv_p(xvec)                           \
-   (CONST_STRNEQ ((xvec)->name, "efi-rtdrv-"))
-
-/* Return the arch string of an EFI runtime driver target.  */
-#define bfd_target_efi_rtdrv_arch(xvec)                                \
-  ((xvec)->name + sizeof ("efi-rtdrv-") - 1)
-
-/* Macro: Returns true if the bfd is a PE executable as opposed to a
-   PE object file.  */
-#define bfd_pe_executable_p(abfd)                      \
-  (   bfd_target_pei_p ((abfd)->xvec)                  \
-   || bfd_target_efi_app_p ((abfd)->xvec)              \
-   || bfd_target_efi_bsdrv_p ((abfd)->xvec)            \
-   || bfd_target_efi_rtdrv_p ((abfd)->xvec))
-
 /* These functions are architecture dependent, and are in peicode.h:
    coff_swap_reloc_in
    int coff_swap_reloc_out
index 246de27c23135e305b7fdff7cf4e001f89486a69..b3b39deda261215653bc2b08f75f90a9d98a744a 100644 (file)
@@ -879,7 +879,7 @@ _bfd_XXi_swap_scnhdr_out (bfd * abfd, void * in, void * out)
      sometimes).  */
   if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
     {
-      if (bfd_pe_executable_p (abfd))
+      if (bfd_pei_p (abfd))
        {
          ps = scnhdr_int->s_size;
          ss = 0;
@@ -892,7 +892,7 @@ _bfd_XXi_swap_scnhdr_out (bfd * abfd, void * in, void * out)
     }
   else
     {
-      if (bfd_pe_executable_p (abfd))
+      if (bfd_pei_p (abfd))
        ps = scnhdr_int->s_paddr;
       else
        ps = 0;
diff --git a/bfd/pei-ia64.c b/bfd/pei-ia64.c
new file mode 100644 (file)
index 0000000..dc1980d
--- /dev/null
@@ -0,0 +1,40 @@
+/* BFD back-end for HP/Intel IA-64 PE IMAGE COFF files.
+   Copyright 1999, 2000, 2001, 2002, 2007, 2009 Free Software Foundation, Inc.
+   Contributed by David Mosberger <davidm@hpl.hp.com>
+
+   This implementation only supports objcopy to ouput IA-64 PE IMAGE COFF
+   files.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+
+#define TARGET_SYM bfd_pei_ia64_vec
+#define TARGET_NAME "pei-ia64"
+#define COFF_IMAGE_WITH_PE
+#define COFF_WITH_PE
+#define COFF_WITH_pep
+#define PCRELOFFSET TRUE
+#define TARGET_UNDERSCORE '_'
+/* Long section names not allowed in executable images, only object files.  */
+#define COFF_LONG_SECTION_NAMES 0
+#define PEI_TARGET_SUBSYSTEM           IMAGE_SUBSYSTEM_EFI_APPLICATION
+#define PEI_FORCE_MINIMUM_ALIGNMENT
+
+#include "coff-ia64.c"
index 357d1c881efefb166e4caa53db6ba986fd992600..2e96f1263ffa805043aa658a2fc16540ee05829c 100644 (file)
@@ -236,8 +236,8 @@ coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in)
      use the virtual size (stored in s_paddr) instead.  */
   if (scnhdr_int->s_paddr > 0
       && (((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0
-          && (! bfd_pe_executable_p (abfd) || scnhdr_int->s_size == 0))
-          || (bfd_pe_executable_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr))))
+          && (! bfd_pei_p (abfd) || scnhdr_int->s_size == 0))
+          || (bfd_pei_p (abfd) && (scnhdr_int->s_size > scnhdr_int->s_paddr))))
   /* This code used to set scnhdr_int->s_paddr to 0.  However,
      coff_set_alignment_hook stores s_paddr in virt_size, which
      only works if it correctly holds the virtual size of the
@@ -1236,25 +1236,6 @@ pe_ILF_object_p (bfd * abfd)
   return abfd->xvec;
 }
 
-enum arch_type
-{
-  arch_type_unknown,
-  arch_type_i386,
-  arch_type_x86_64
-};
-
-static enum arch_type
-pe_arch (const char *arch)
-{
-  if (strcmp (arch, "i386") == 0 || strcmp (arch, "ia32") == 0)
-    return arch_type_i386;
-
-  if (strcmp (arch, "x86_64") == 0 || strcmp (arch, "x86-64") == 0)
-    return arch_type_x86_64;
-
-  return arch_type_unknown;
-}
-
 static const bfd_target *
 pe_bfd_object_p (bfd * abfd)
 {
@@ -1262,8 +1243,6 @@ pe_bfd_object_p (bfd * abfd)
   struct external_PEI_DOS_hdr dos_hdr;
   struct external_PEI_IMAGE_hdr image_hdr;
   file_ptr offset;
-  const bfd_target *target;
-  struct bfd_preserve preserve;
 
   /* Detect if this a Microsoft Import Library Format element.  */
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
@@ -1328,110 +1307,7 @@ pe_bfd_object_p (bfd * abfd)
       return NULL;
     }
 
-  preserve.marker = NULL;
-  if (! bfd_preserve_save (abfd, &preserve))
-    return NULL;
-
-  target = coff_object_p (abfd);
-  if (target)
-    {
-      pe_data_type *pe = pe_data (abfd);
-      struct internal_extra_pe_aouthdr *i = &pe->pe_opthdr;
-      bfd_boolean efi = i->Subsystem == IMAGE_SUBSYSTEM_EFI_APPLICATION
-                     || i->Subsystem == IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER
-                     || i->Subsystem == IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;
-      enum arch_type arch;
-      const bfd_target * const *target_ptr;
-
-      /* Get the machine.  */
-      if (bfd_target_efi_app_p (abfd->xvec))
-       arch = pe_arch (bfd_target_efi_app_arch (abfd->xvec));
-      else if (bfd_target_efi_bsdrv_p (abfd->xvec))
-        arch = pe_arch (bfd_target_efi_bsdrv_arch (abfd->xvec));
-      else if (bfd_target_efi_rtdrv_p (abfd->xvec))
-        arch = pe_arch (bfd_target_efi_rtdrv_arch (abfd->xvec));
-      else
-       arch = pe_arch (bfd_target_pei_arch (abfd->xvec));
-
-      /* Don't check PE vs. EFI if arch is unknown.  */
-      if (arch == arch_type_unknown)
-       {
-         bfd_preserve_finish (abfd, &preserve);
-         return target;
-       }
-
-      for (target_ptr = bfd_target_vector; *target_ptr != NULL;
-          target_ptr++)
-       {
-         if (*target_ptr == target
-             || (*target_ptr)->flavour != bfd_target_coff_flavour)
-           continue;
-
-         if (bfd_target_efi_app_p (*target_ptr))
-           {
-             /* Skip incompatible arch.  */
-             if (pe_arch (bfd_target_efi_app_arch (*target_ptr)) != arch)
-               continue;
-
-             if (efi)
-               {
-                 /* TARGET_PTR is an EFI backend.  Don't match
-                    TARGET with a EFI file.  */
-                 bfd_set_error (bfd_error_wrong_format);
-                 return NULL;
-               }
-           }
-          else if (bfd_target_efi_bsdrv_p (*target_ptr))
-           {
-             /* Skip incompatible arch.  */
-             if (pe_arch (bfd_target_efi_bsdrv_arch (*target_ptr)) != arch)
-               continue;
-
-             if (efi)
-               {
-                 /* TARGET_PTR is an EFI backend.  Don't match
-                    TARGET with a EFI file.  */
-                 bfd_set_error (bfd_error_wrong_format);
-                 return NULL;
-               }
-           }
-          else if (bfd_target_efi_rtdrv_p (*target_ptr))
-           {
-             /* Skip incompatible arch.  */
-             if (pe_arch (bfd_target_efi_rtdrv_arch (*target_ptr)) != arch)
-               continue;
-
-             if (efi)
-               {
-no_match:
-                 /* TARGET_PTR is an EFI backend.  Don't match
-                    TARGET with a EFI file.  */
-                 bfd_preserve_restore (abfd, &preserve);
-                 bfd_set_error (bfd_error_wrong_format);
-                 return NULL;
-               }
-           }
-         else if (bfd_target_pei_p (*target_ptr))
-           {
-             /* Skip incompatible arch.  */
-             if (pe_arch (bfd_target_pei_arch (*target_ptr)) != arch)
-               continue;
-
-             if (!efi)
-               {
-                 /* TARGET_PTR is a PE backend.  Don't match
-                    TARGET with a PE file.  */
-                 goto no_match;
-               }
-           }
-       }
-
-      bfd_preserve_finish (abfd, &preserve);
-    }
-  else
-    bfd_preserve_restore (abfd, &preserve);
-
-  return target;
+  return coff_object_p (abfd);
 }
 
 #define coff_object_p pe_bfd_object_p
index c9d4c31fab0aec071f09dfd1960c9ea5b1b75307..daca6158a40a98be9e376149c80870752db6d493 100644 (file)
@@ -565,15 +565,7 @@ extern const bfd_target armpei_big_vec;
 extern const bfd_target armpei_little_vec;
 extern const bfd_target b_out_vec_big_host;
 extern const bfd_target b_out_vec_little_host;
-extern const bfd_target bfd_efi_app_ia32_vec;
-extern const bfd_target bfd_efi_bsdrv_ia32_vec;
-extern const bfd_target bfd_efi_rtdrv_ia32_vec;
-extern const bfd_target bfd_efi_app_x86_64_vec;
-extern const bfd_target bfd_efi_bsdrv_x86_64_vec;
-extern const bfd_target bfd_efi_rtdrv_x86_64_vec;
-extern const bfd_target bfd_efi_app_ia64_vec;
-extern const bfd_target bfd_efi_bsdrv_ia64_vec;
-extern const bfd_target bfd_efi_rtdrv_ia64_vec;
+extern const bfd_target bfd_pei_ia64_vec;
 extern const bfd_target bfd_elf32_avr_vec;
 extern const bfd_target bfd_elf32_bfin_vec;
 extern const bfd_target bfd_elf32_bfinfdpic_vec;
@@ -893,16 +885,8 @@ static const bfd_target * const _bfd_target_vector[] =
        &armpei_little_vec,
        &b_out_vec_big_host,
        &b_out_vec_little_host,
-       &bfd_efi_app_ia32_vec,
-       &bfd_efi_bsdrv_ia32_vec,
-       &bfd_efi_rtdrv_ia32_vec,
 #ifdef BFD64
-       &bfd_efi_app_x86_64_vec,
-       &bfd_efi_bsdrv_x86_64_vec,
-       &bfd_efi_rtdrv_x86_64_vec,
-       &bfd_efi_app_ia64_vec,
-       &bfd_efi_bsdrv_ia64_vec,
-       &bfd_efi_rtdrv_ia64_vec,
+       &bfd_pei_ia64_vec,
 #endif
        &bfd_elf32_avr_vec,
        &bfd_elf32_bfin_vec,
index 4f755b972fa8f086f3cc376af9221326ee5ef586..5032687a6896c596cb1420140409197944d13b50 100644 (file)
@@ -1,3 +1,39 @@
+2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/10074
+       * objcopy.c: Include coff/i386.h and coff/pe.h.
+       (pe_file_alignment): New.
+       (pe_heap_commit): Likewise.
+       (pe_heap_reserve): Likewise.
+       (pe_image_base): Likewise.
+       (pe_section_alignment): Likewise.
+       (pe_stack_commit): Likewise.
+       (pe_stack_reserve): Likewise.
+       (pe_subsystem): Likewise.
+       (pe_major_subsystem_version): Likewise.
+       (pe_minor_subsystem_version): Likewise.
+       (set_pe_subsystem): Likewise.
+       (convert_efi_target): Likewise.
+       (command_line_switch): Add OPTION_FILE_ALIGNMENT,
+       OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
+       OPTION_STACK and OPTION_SUBSYSTEM.
+       (copy_options): Likewise.
+       (copy_usage): Add --file-alignment, --heap, --image-base,
+       --section-alignment, --stack and --subsystem.
+       (copy_object): Set up PE parameters.
+       (copy_main): Process Add OPTION_FILE_ALIGNMENT,
+       OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
+       OPTION_STACK and OPTION_SUBSYSTEM.   Convert EFI target to
+       PEI target.
+
+       * NEWS: Mention --file-alignment, --heap, --image-base,
+       --section-alignment, --stack and --subsystem command line
+       options for objcopy.
+
+       * doc/binutils.texi: Document --file-alignment, --heap,
+       --image-base, --section-alignment, --stack and --subsystem
+       command line options for objcopy.
+
 2009-04-15  Anthony Green  <green@moxielogic.com>
 
        * MAINTAINERS: Add myself and Moxie port maintainer.
index b4d562c337e7caabd9b081b2ad2b0c0fd9443746..3434b9f6b802ccf4e86d199d57cb45847589a72f 100644 (file)
@@ -1,5 +1,9 @@
 -*- text -*-
 
+* Add --file-alignment, --heap, --image-base, --section-alignment,
+  --stack and --subsystem command line options to objcopy, which will
+  set PE optional header.
+
 * Option --dwarf/-W of objdump is now as flexible as readelf --debug-dump/-w.
 
 * --as-needed now links in a dynamic library if it satisfies undefined
index 55d14d0d004b525a2dfaa70ed0a3be0a0d893633..fe30d6a5f4e34d74f4d6198825e93546a3121ffa 100644 (file)
@@ -1027,6 +1027,12 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
         [@option{--readonly-text}]
         [@option{--pure}]
         [@option{--impure}]
+        [@option{--file-alignment=}@var{num}]
+        [@option{--heap=}@var{size}]
+        [@option{--image-base=}@var{address}]
+        [@option{--section-alignment=}@var{num}]
+        [@option{--stack=}@var{size}]
+        [@option{--subsystem=}@var{which}:@var{major}.@var{minor}]
         [@option{-v}|@option{--verbose}]
         [@option{-V}|@option{--version}]
         [@option{--help}] [@option{--info}]
@@ -1520,6 +1526,49 @@ distribution and the second a debugging information file which is only
 needed if debugging abilities are required.  The suggested procedure
 to create these files is as follows:
 
+@item --file-alignment @var{num}
+Specify the file alignment.  Sections in the file will always begin at
+file offsets which are multiples of this number.  This defaults to
+512.
+[This option is specific to PE targets.]
+
+@item --heap @var{reserve}
+@itemx --heap @var{reserve},@var{commit}
+Specify the number of bytes of memory to reserve (and optionally commit)
+to be used as heap for this program.
+[This option is specific to PE targets.]
+
+@item --image-base @var{value}
+Use @var{value} as the base address of your program or dll.  This is
+the lowest memory location that will be used when your program or dll
+is loaded.  To reduce the need to relocate and improve performance of
+your dlls, each should have a unique base address and not overlap any
+other dlls.  The default is 0x400000 for executables, and 0x10000000
+for dlls.
+[This option is specific to PE targets.]
+
+@item --section-alignment @var{num}
+Sets the section alignment.  Sections in memory will always begin at
+addresses which are a multiple of this number.  Defaults to 0x1000.
+[This option is specific to PE targets.]
+
+@item --stack @var{reserve}
+@itemx --stack @var{reserve},@var{commit}
+Specify the number of bytes of memory to reserve (and optionally commit)
+to be used as stack for this program.
+[This option is specific to PE targets.]
+
+@item --subsystem @var{which}
+@itemx --subsystem @var{which}:@var{major}
+@itemx --subsystem @var{which}:@var{major}.@var{minor}
+Specifies the subsystem under which your program will execute.  The
+legal values for @var{which} are @code{native}, @code{windows},
+@code{console}, @code{posix}, @code{efi-app}, @code{efi-bsd},
+@code{efi-rtd}, @code{efi-rom}, and @code{xbox}.  You may optionally set
+the subsystem version also.  Numeric values are also accepted for
+@var{which}.
+[This option is specific to PE targets.]
+
 @enumerate
 @item Link the executable as normal.  Assuming that is is called
 @code{foo} then...
index 02e4d351a7fb5272364db4e15a9edaa55f2f54f3..b7c84d841771dca3d6560ecb20797f7c37017adf 100644 (file)
 #include "coff/internal.h"
 #include "libcoff.h"
 
+/* FIXME: See bfd/peXXigen.c for why we include an architecture specific
+   header in generic PE code.  */
+#include "coff/i386.h"
+#include "coff/pe.h"
+
+static bfd_vma pe_file_alignment = (bfd_vma) -1;
+static bfd_vma pe_heap_commit = (bfd_vma) -1;
+static bfd_vma pe_heap_reserve = (bfd_vma) -1;
+static bfd_vma pe_image_base = (bfd_vma) -1;
+static bfd_vma pe_section_alignment = (bfd_vma) -1;
+static bfd_vma pe_stack_commit = (bfd_vma) -1;
+static bfd_vma pe_stack_reserve = (bfd_vma) -1;
+static short pe_subsystem = -1;
+static short pe_major_subsystem_version = -1;
+static short pe_minor_subsystem_version = -1;
+
 struct is_specified_symbol_predicate_data
 {
   const char   *name;
@@ -280,7 +296,13 @@ enum command_line_switch
     OPTION_PURE,
     OPTION_IMPURE,
     OPTION_EXTRACT_SYMBOL,
-    OPTION_REVERSE_BYTES
+    OPTION_REVERSE_BYTES,
+    OPTION_FILE_ALIGNMENT,
+    OPTION_HEAP,
+    OPTION_IMAGE_BASE,
+    OPTION_SECTION_ALIGNMENT,
+    OPTION_STACK,
+    OPTION_SUBSYSTEM
   };
 
 /* Options to handle if running as "strip".  */
@@ -394,6 +416,12 @@ static struct option copy_options[] =
   {"weaken-symbols", required_argument, 0, OPTION_WEAKEN_SYMBOLS},
   {"wildcard", no_argument, 0, 'w'},
   {"writable-text", no_argument, 0, OPTION_WRITABLE_TEXT},
+  {"file-alignment", required_argument, 0, OPTION_FILE_ALIGNMENT},
+  {"heap", required_argument, 0, OPTION_HEAP},
+  {"image-base", required_argument, 0 , OPTION_IMAGE_BASE},
+  {"section-alignment", required_argument, 0, OPTION_SECTION_ALIGNMENT},
+  {"stack", required_argument, 0, OPTION_STACK},
+  {"subsystem", required_argument, 0, OPTION_SUBSYSTEM},
   {0, no_argument, 0, 0}
 };
 
@@ -515,6 +543,15 @@ copy_usage (FILE *stream, int exit_status)
      --prefix-alloc-sections <prefix>\n\
                                    Add <prefix> to start of every allocatable\n\
                                      section name\n\
+     --file-alignment <num>        Set PE file alignment to <num>\n\
+     --heap <reserve>[,<commit>]   Set PE reserve/commit heap to <reserve>/\n\
+                                   <commit>\n\
+     --image-base <address>        Set PE image base to <address>\n\
+     --section-alignment <num>     Set PE section alignment to <num>\n\
+     --stack <reserve>[,<commit>]  Set PE reserve/commit stack to <reserve>/\n\
+                                   <commit>\n\
+     --subsystem <name>[:<version>]\n\
+                                   Set PE subsystem to <name> [& <version>]\n]\
   -v --verbose                     List all object files modified\n\
   @<file>                          Read options from <file>\n\
   -V --version                     Display this program's version number\n\
@@ -1448,6 +1485,58 @@ copy_object (bfd *ibfd, bfd *obfd)
       return FALSE;
     }
 
+  if (bfd_get_flavour (obfd) == bfd_target_coff_flavour
+      && bfd_pei_p (obfd))
+    {
+      /* Set up PE parameters.  */
+      pe_data_type *pe = pe_data (obfd);
+
+      if (pe_file_alignment != (bfd_vma) -1)
+       pe->pe_opthdr.FileAlignment = pe_file_alignment;
+      else
+       pe_file_alignment = PE_DEF_FILE_ALIGNMENT;
+
+      if (pe_heap_commit != (bfd_vma) -1)
+       pe->pe_opthdr.SizeOfHeapCommit = pe_heap_commit;
+
+      if (pe_heap_reserve != (bfd_vma) -1)
+       pe->pe_opthdr.SizeOfHeapCommit = pe_heap_reserve;
+
+      if (pe_image_base != (bfd_vma) -1)
+       pe->pe_opthdr.ImageBase = pe_image_base;
+
+      if (pe_section_alignment != (bfd_vma) -1)
+       pe->pe_opthdr.SectionAlignment = pe_section_alignment;
+      else
+       pe_section_alignment = PE_DEF_SECTION_ALIGNMENT;
+
+      if (pe_stack_commit != (bfd_vma) -1)
+       pe->pe_opthdr.SizeOfStackCommit = pe_stack_commit;
+
+      if (pe_stack_reserve != (bfd_vma) -1)
+       pe->pe_opthdr.SizeOfStackCommit = pe_stack_reserve;
+
+      if (pe_subsystem != -1)
+       pe->pe_opthdr.Subsystem = pe_subsystem;
+
+      if (pe_major_subsystem_version != -1)
+       pe->pe_opthdr.MajorSubsystemVersion = pe_major_subsystem_version;
+
+      if (pe_minor_subsystem_version != -1)
+       pe->pe_opthdr.MinorSubsystemVersion = pe_minor_subsystem_version;
+
+      if (pe_file_alignment > pe_section_alignment)
+       {
+         char file_alignment[20], section_alignment[20];
+
+         sprintf_vma (file_alignment, pe_file_alignment);
+         sprintf_vma (section_alignment, pe_section_alignment);
+         non_fatal (_("warning: file alignment (0x%s) > section alignment (0x%s)"),
+
+                    file_alignment, section_alignment);
+       }
+    }
+
   if (isympp)
     free (isympp);
 
@@ -2928,6 +3017,117 @@ strip_main (int argc, char *argv[])
   return status;
 }
 
+/* Set up PE subsystem.  */
+
+static void
+set_pe_subsystem (const char *s)
+{
+  const char *version, *subsystem;
+  size_t i;
+  static const struct
+    {
+      const char *name;
+      const char set_def;
+      const short value;
+    }
+  v[] =
+    {
+      { "native", 0, IMAGE_SUBSYSTEM_NATIVE },  
+      { "windows", 0, IMAGE_SUBSYSTEM_WINDOWS_GUI },
+      { "console", 0, IMAGE_SUBSYSTEM_WINDOWS_CUI },
+      { "posix", 0, IMAGE_SUBSYSTEM_POSIX_CUI },
+      { "wince", 0, IMAGE_SUBSYSTEM_WINDOWS_CE_GUI },
+      { "efi-app", 1, IMAGE_SUBSYSTEM_EFI_APPLICATION },
+      { "efi-bsd", 1, IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER },
+      { "efi-rtd", 1, IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER },
+      { "efi-rom", 1, IMAGE_SUBSYSTEM_EFI_ROM },
+      { "xbox", 0, IMAGE_SUBSYSTEM_XBOX }
+    };
+  short value;
+  char *copy;
+  int set_def = -1;
+
+  /* Check for the presence of a version number.  */
+  version = strchr (s, ':');
+  if (version == NULL)
+    subsystem = s;
+  else
+    {
+      int len = version - s;
+      copy = xstrdup (s);
+      subsystem = copy;
+      copy[len] = '\0';
+      version = copy + 1 + len;
+      pe_major_subsystem_version = strtoul (version, &copy, 0);
+      if (*copy == '.')
+       pe_minor_subsystem_version = strtoul (copy + 1, &copy, 0);
+      if (*copy != '\0')
+       non_fatal (_("%s: bad version in PE subsystem"), s);
+    }
+
+  /* Check for numeric subsystem.  */
+  value = (short) strtol (subsystem, &copy, 0);
+  if (*copy == '\0')
+    {
+      for (i = 0; i < ARRAY_SIZE (v); i++)
+       if (v[i].value == value)
+         {
+           pe_subsystem = value;
+           set_def = v[i].set_def;
+           break;
+         }
+    }
+  else
+    {
+      /* Search for subsystem by name.  */
+      for (i = 0; i < ARRAY_SIZE (v); i++)
+       if (strcmp (subsystem, v[i].name) == 0)
+         {
+           pe_subsystem = v[i].value;
+           set_def = v[i].set_def;
+           break;
+         }
+    }
+
+  switch (set_def)
+    {
+    case -1:
+      fatal (_("unknown PE subsystem: %s"), s);
+      break;
+    case 0:
+      break;
+    default:
+      if (pe_file_alignment == (bfd_vma) -1)
+       pe_file_alignment = PE_DEF_FILE_ALIGNMENT;
+      if (pe_section_alignment == (bfd_vma) -1)
+       pe_section_alignment = PE_DEF_SECTION_ALIGNMENT;
+      break;
+    }
+}
+
+/* Convert EFI target to PEI target.  */
+
+static void
+convert_efi_target (char *efi)
+{
+  efi[0] = 'p';
+  efi[1] = 'e';
+  efi[2] = 'i';
+
+  if (strcmp (efi + 4, "ia32") == 0)
+    {
+      /* Change ia32 to i386.  */
+      efi[5]= '3';
+      efi[6]= '8';
+      efi[7]= '6';
+    }
+  else if (strcmp (efi + 4, "x86_64") == 0)
+    {
+      /* Change x86_64 to x86-64.  */
+      efi[7] = '-';
+    }
+}
+
 static int
 copy_main (int argc, char *argv[])
 {
@@ -3466,6 +3666,59 @@ copy_main (int argc, char *argv[])
             break;
           }
 
+       case OPTION_FILE_ALIGNMENT:
+         pe_file_alignment = parse_vma (optarg, "--file-alignment");
+         break;
+       
+       case OPTION_HEAP:
+           {
+             char *end;
+             pe_heap_reserve = strtoul (optarg, &end, 0);
+             if (end == optarg
+                 || (*end != '.' && *end != '\0'))
+               non_fatal (_("%s: invalid reserve value for --heap"),
+                          optarg);
+             else if (*end != '\0')
+               {
+                 pe_heap_commit = strtoul (end + 1, &end, 0);
+                 if (*end != '\0')
+                   non_fatal (_("%s: invalid commit value for --heap"),
+                              optarg);
+               }
+           }
+         break;
+       
+       case OPTION_IMAGE_BASE:
+         pe_image_base = parse_vma (optarg, "--image-base");
+         break;
+       
+       case OPTION_SECTION_ALIGNMENT:
+         pe_section_alignment = parse_vma (optarg,
+                                           "--section-alignment");
+         break;
+       
+       case OPTION_SUBSYSTEM:
+         set_pe_subsystem (optarg);
+         break;
+       
+       case OPTION_STACK:
+           {
+             char *end;
+             pe_stack_reserve = strtoul (optarg, &end, 0);
+             if (end == optarg
+                 || (*end != '.' && *end != '\0'))
+               non_fatal (_("%s: invalid reserve value for --stack"),
+                          optarg);
+             else if (*end != '\0')
+               {
+                 pe_stack_commit = strtoul (end + 1, &end, 0);
+                 if (*end != '\0')
+                   non_fatal (_("%s: invalid commit value for --stack"),
+                              optarg);
+               }
+           }
+         break;
+       
        case 0:
          /* We've been given a long option.  */
          break;
@@ -3505,6 +3758,59 @@ copy_main (int argc, char *argv[])
   if (output_target == NULL)
     output_target = input_target;
 
+  /* Convert input EFI target to PEI target.  */
+  if (input_target != NULL
+      && strncmp (input_target, "efi-", 4) == 0)
+    {
+      char *efi;
+
+      efi = xstrdup (output_target + 4);
+      if (strncmp (efi, "bsdrv-", 6) == 0
+         || strncmp (efi, "rtdrv-", 6) == 0)
+       efi += 2;
+      else if (strncmp (efi, "app-", 4) != 0)
+       fatal (_("unknown input EFI target: %s"), input_target);
+
+      input_target = efi;
+      convert_efi_target (efi);
+    }
+
+  /* Convert output EFI target to PEI target.  */
+  if (output_target != NULL
+      && strncmp (output_target, "efi-", 4) == 0)
+    {
+      char *efi;
+
+      efi = xstrdup (output_target + 4);
+      if (strncmp (efi, "app-", 4) == 0)
+       {
+         if (pe_subsystem == -1)
+           pe_subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION;
+       }
+      else if (strncmp (efi, "bsdrv-", 6) == 0)
+       {
+         if (pe_subsystem == -1)
+           pe_subsystem = IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;
+         efi += 2;
+       }
+      else if (strncmp (efi, "rtdrv-", 6) == 0)
+       {
+         if (pe_subsystem == -1)
+           pe_subsystem = IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;
+         efi += 2;
+       }
+      else
+       fatal (_("unknown output EFI target: %s"), output_target);
+
+      if (pe_file_alignment == (bfd_vma) -1)
+       pe_file_alignment = PE_DEF_FILE_ALIGNMENT;
+      if (pe_section_alignment == (bfd_vma) -1)
+       pe_section_alignment = PE_DEF_SECTION_ALIGNMENT;
+
+      output_target = efi;
+      convert_efi_target (efi);
+    }
+
   if (binary_architecture != NULL)
     {
       if (input_target && strcmp (input_target, "binary") == 0)