+ if (!abfd->target_defaulted)
+ {
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) /* rewind! */
+ goto err_ret;
+
+ right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
+
+ if (right_targ)
+ goto ok_ret;
+
+ /* For a long time the code has dropped through to check all
+ targets if the specified target was wrong. I don't know why,
+ and I'm reluctant to change it. However, in the case of an
+ archive, it can cause problems. If the specified target does
+ not permit archives (e.g., the binary target), then we should
+ not allow some other target to recognize it as an archive, but
+ should instead allow the specified target to recognize it as an
+ object. When I first made this change, it broke the PE target,
+ because the specified pei-i386 target did not recognize the
+ actual pe-i386 archive. Since there may be other problems of
+ this sort, I changed this test to check only for the binary
+ target. */
+ if (format == bfd_archive && save_targ == &binary_vec)
+ goto err_unrecog;
+ }