+
+static const bfd_arch_info_type *
+bfd_m68k_compatible (const bfd_arch_info_type *a,
+ const bfd_arch_info_type *b)
+{
+ if (a->arch != b->arch)
+ return NULL;
+
+ if (a->bits_per_word != b->bits_per_word)
+ return NULL;
+
+ if (!a->mach)
+ return b;
+ if (!b->mach)
+ return a;
+
+ if (a->mach <= bfd_mach_m68060 && b->mach <= bfd_mach_m68060)
+ /* Merge m68k machine. */
+ return a->mach > b->mach ? a : b;
+ else if (a->mach >= bfd_mach_cpu32 && b->mach >= bfd_mach_cpu32)
+ {
+ /* Merge the machine features. */
+ unsigned features = (bfd_m68k_mach_to_features (a->mach)
+ | bfd_m68k_mach_to_features (b->mach));
+
+ /* CPU32 and Coldfire are incompatible. */
+ if ((~features & (cpu32 | mcfisa_a)) == 0)
+ return NULL;
+
+ /* Fido and Coldfire are incompatible. */
+ if ((~features & (fido_a | mcfisa_a)) == 0)
+ return NULL;
+
+ /* ISA A+ and ISA B are incompatible. */
+ if ((~features & (mcfisa_aa | mcfisa_b)) == 0)
+ return NULL;
+
+ /* ISA B and ISA C are incompatible. */
+ if ((~features & (mcfisa_b | mcfisa_c)) == 0)
+ return NULL;
+
+ /* MAC and EMAC code cannot be merged. */
+ if ((~features & (mcfmac | mcfemac)) == 0)
+ return NULL;
+
+ /* CPU32 is compatible with Fido except that Fido does not
+ support tbl instructions. Warn when the user wants to mix
+ the two. */
+ if ((a->mach == bfd_mach_cpu32 && b->mach == bfd_mach_fido)
+ || (a->mach == bfd_mach_fido && b->mach == bfd_mach_cpu32))
+ {
+ static int cpu32_fido_mix_warning;
+ if (!cpu32_fido_mix_warning)
+ {
+ cpu32_fido_mix_warning = 1;
+ (*_bfd_error_handler) ("warning: linking CPU32 objects with fido objects");
+ }
+ return bfd_lookup_arch (a->arch,
+ bfd_m68k_features_to_mach (fido_a | m68881));
+ }
+
+ return bfd_lookup_arch (a->arch, bfd_m68k_features_to_mach (features));
+ }
+ else
+ /* They are incompatible. */
+ return NULL;
+}