aboutsummaryrefslogtreecommitdiff
path: root/bfd/peicode.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2009-04-17 13:46:18 +0000
committerH.J. Lu <hjl.tools@gmail.com>2009-04-17 13:46:18 +0000
commit92dd451149162bb67d49460d7d906ecbd0abeb1b (patch)
tree264458c1a68edc0d13335c26715e60c20f72bfd4 /bfd/peicode.h
parent69c5861ee1e736adf16998ba505b5054fc633f3f (diff)
downloadfsf-binutils-gdb-92dd451149162bb67d49460d7d906ecbd0abeb1b.zip
fsf-binutils-gdb-92dd451149162bb67d49460d7d906ecbd0abeb1b.tar.gz
fsf-binutils-gdb-92dd451149162bb67d49460d7d906ecbd0abeb1b.tar.bz2
bfd/
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.
Diffstat (limited to 'bfd/peicode.h')
-rw-r--r--bfd/peicode.h130
1 files changed, 3 insertions, 127 deletions
diff --git a/bfd/peicode.h b/bfd/peicode.h
index 357d1c8..2e96f12 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -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