From 999d6dff80fab12d22c2a8d91923db6bde7fb3e5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 28 Jun 2019 10:18:49 +0930 Subject: Plugin target handling This patch fixes failures with LTO on mingw32 targets. Since git commit 7cf7fcc83c all possible targets (minus binary) are matched in bfd_check_format_matches rather than lower priority targets being excluded once a higher priority target matches. During linking that results in the ld/plugin.c plugin_object_p function being called with the input file xvec set to plugin_vec, which means plugin_get_ir_dummy_bfd doesn't see the real format of the file (pe-i386). It defaults to the output format instead, which happens to be pei-i386, and this wrong choice persists for the dummy bfd. pei-i386 isn't recognised as a valid linker input file. So, omit recognizing a plugin object in bfd_check_format_matches when some other object format matches, and make sure those other object formats are checked first. * format.c (bfd_check_format_matches): Don't match plugin target if another target matches. Expand comment. * targets.c (_bfd_target_vector): Move plugin_vec after all other non-corefile targets, outside !SELECT_VECS. * config.bfd: Don't handle targ=plugin here. * configure.ac: Don't add plugin to enable_targets or handle in target loop setting selvecs and other target vars. * configure: Regenerate. --- bfd/format.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'bfd/format.c') diff --git a/bfd/format.c b/bfd/format.c index 97a9229..1d1363d 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -290,8 +290,15 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) { const bfd_target *temp; - /* Don't check the default target twice. */ + /* The binary target matches anything, so don't return it when + searching. Don't match the plugin target if we have another + alternative since we want to properly set the input format + before allowing a plugin to claim the file. Also, don't + check the default target twice. */ if (*target == &binary_vec +#if BFD_SUPPORTS_PLUGINS + || (match_count != 0 && *target == &plugin_vec) +#endif || (!abfd->target_defaulted && *target == save_targ)) continue; -- cgit v1.1