diff -rupN --no-dereference binutils-2.32/bfd/config.bfd binutils-2.32-new/bfd/config.bfd --- binutils-2.32/bfd/config.bfd 2019-01-19 17:01:32.000000000 +0100 +++ binutils-2.32-new/bfd/config.bfd 2019-11-19 20:47:16.708676031 +0100 @@ -217,11 +217,6 @@ esac # convention, else the table becomes a real mess to understand and maintain. case "${targ}" in - plugin) - targ_defvec=plugin_vec - targ_selvecs="plugin_vec" - ;; - # START OF targmatch.h #ifdef BFD64 aarch64-*-darwin*) diff -rupN --no-dereference binutils-2.32/bfd/configure binutils-2.32-new/bfd/configure --- binutils-2.32/bfd/configure 2019-02-02 16:47:56.000000000 +0100 +++ binutils-2.32-new/bfd/configure 2019-11-19 20:47:16.710676043 +0100 @@ -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 @@ -14580,12 +14576,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" @@ -14820,7 +14816,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" ;; @@ -14947,6 +14942,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. diff -rupN --no-dereference binutils-2.32/bfd/configure.ac binutils-2.32-new/bfd/configure.ac --- binutils-2.32/bfd/configure.ac 2019-01-19 17:01:32.000000000 +0100 +++ binutils-2.32-new/bfd/configure.ac 2019-11-19 20:47:16.710676043 +0100 @@ -46,10 +46,6 @@ ACX_LARGEFILE AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes") -if test "$plugins" = "yes"; then - enable_targets="$enable_targets plugin" -fi - AC_ARG_ENABLE(64-bit-bfd, [ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)], [case "${enableval}" in @@ -348,12 +344,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" @@ -588,7 +584,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" ;; @@ -715,6 +710,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. diff -rupN --no-dereference binutils-2.32/bfd/format.c binutils-2.32-new/bfd/format.c --- binutils-2.32/bfd/format.c 2019-01-19 17:01:33.000000000 +0100 +++ binutils-2.32-new/bfd/format.c 2019-11-19 20:47:16.710676043 +0100 @@ -290,8 +290,15 @@ bfd_check_format_matches (bfd *abfd, bfd { 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; diff -rupN --no-dereference binutils-2.32/bfd/targets.c binutils-2.32-new/bfd/targets.c --- binutils-2.32/bfd/targets.c 2019-01-19 17:01:33.000000000 +0100 +++ binutils-2.32-new/bfd/targets.c 2019-11-19 20:47:16.711676049 +0100 @@ -1142,10 +1142,6 @@ static const bfd_target * const _bfd_tar &pj_elf32_vec, &pj_elf32_le_vec, -#if BFD_SUPPORTS_PLUGINS - &plugin_vec, -#endif - &powerpc_boot_vec, &powerpc_elf32_vec, &powerpc_elf32_le_vec, @@ -1298,6 +1294,10 @@ static const bfd_target * const _bfd_tar /* Likewise for ihex. */ &ihex_vec, +#if BFD_SUPPORTS_PLUGINS + &plugin_vec, +#endif + /* Add any required traditional-core-file-handler. */ #ifdef AIX386_CORE