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/configure | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'bfd/configure') diff --git a/bfd/configure b/bfd/configure index 6f95045..b1a727a 100755 --- a/bfd/configure +++ b/bfd/configure @@ -12409,10 +12409,6 @@ else fi -if test "$plugins" = "yes"; then - enable_targets="$enable_targets plugin" -fi - # Check whether --enable-64-bit-bfd was given. if test "${enable_64_bit_bfd+set}" = set; then : enableval=$enable_64_bit_bfd; case "${enableval}" in @@ -14613,12 +14609,12 @@ selarchs= TDEFINES= for targ in $target $canon_targets do - if test "x$targ" = "xall"; then + if test $targ = all; then all_targets=true assocvecs="$assocvecs $targ_defvec $targ_selvecs" - else + elif test $targ != plugin; then . $srcdir/config.bfd - if test "x$targ" = "x$target"; then + if test $targ = $target; then defvec=$targ_defvec fi selvecs="$selvecs $targ_defvec $targ_selvecs" @@ -14856,7 +14852,6 @@ do pef_xlib_vec) tb="$tb pef.lo" ;; pj_elf32_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;; pj_elf32_le_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;; - plugin_vec) tb="$tb plugin.lo" ;; powerpc_boot_vec) tb="$tb ppcboot.lo" ;; powerpc_elf32_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; powerpc_elf32_le_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; @@ -14983,6 +14978,10 @@ do fi done +if test "$plugins" = "yes"; then + tb="$tb plugin.lo" +fi + # Target architecture .o files. # A couple of CPUs use shorter file names to avoid problems on DOS # filesystems. -- cgit v1.1