- 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_p (*target_ptr))
- {
- /* Skip incompatible arch. */
- if (pe_arch (bfd_target_efi_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_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. */
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
- }
- }
+ if (opt_hdr_size != 0)
+ {
+ bfd_size_type amt = opt_hdr_size;
+ void * opthdr;
+
+ /* PR 17521 file: 230-131433-0.004. */
+ if (amt < sizeof (PEAOUTHDR))
+ amt = sizeof (PEAOUTHDR);
+
+ opthdr = bfd_zalloc (abfd, amt);
+ if (opthdr == NULL)
+ return NULL;
+ if (bfd_bread (opthdr, opt_hdr_size, abfd)
+ != (bfd_size_type) opt_hdr_size)
+ return NULL;
+
+ bfd_set_error (bfd_error_no_error);
+ bfd_coff_swap_aouthdr_in (abfd, opthdr, & internal_a);
+ if (bfd_get_error () != bfd_error_no_error)
+ return NULL;