aboutsummaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index f075922..5cf4afd 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -320,15 +320,24 @@ set_endian (char *ignore_args, int from_tty, struct cmd_list_element *c)
}
/* Given SELECTED, a currently selected BFD architecture, and
- FROM_TARGET, a BFD architecture reported by the target description,
- return what architecture to use. Either may be NULL; if both are
- specified, we use the more specific. If the two are obviously
- incompatible, warn the user. */
+ TARGET_DESC, the current target description, return what
+ architecture to use.
+
+ SELECTED may be NULL, in which case we return the architecture
+ associated with TARGET_DESC. If SELECTED specifies a variant
+ of the architecture associtated with TARGET_DESC, return the
+ more specific of the two.
+
+ If SELECTED is a different architecture, but it is accepted as
+ compatible by the target, we can use the target architecture.
+
+ If SELECTED is obviously incompatible, warn the user. */
static const struct bfd_arch_info *
-choose_architecture_for_target (const struct bfd_arch_info *selected,
- const struct bfd_arch_info *from_target)
+choose_architecture_for_target (const struct target_desc *target_desc,
+ const struct bfd_arch_info *selected)
{
+ const struct bfd_arch_info *from_target = tdesc_architecture (target_desc);
const struct bfd_arch_info *compat1, *compat2;
if (selected == NULL)
@@ -358,6 +367,11 @@ choose_architecture_for_target (const struct bfd_arch_info *selected,
if (compat1 == NULL && compat2 == NULL)
{
+ /* BFD considers the architectures incompatible. Check our target
+ description whether it accepts SELECTED as compatible anyway. */
+ if (tdesc_compatible_p (target_desc, selected))
+ return from_target;
+
warning (_("Selected architecture %s is not compatible "
"with reported target architecture %s"),
selected->printable_name, from_target->printable_name);
@@ -685,7 +699,7 @@ gdbarch_info_fill (struct gdbarch_info *info)
/* From the target. */
if (info->target_desc != NULL)
info->bfd_arch_info = choose_architecture_for_target
- (info->bfd_arch_info, tdesc_architecture (info->target_desc));
+ (info->target_desc, info->bfd_arch_info);
/* From the default. */
if (info->bfd_arch_info == NULL)
info->bfd_arch_info = default_bfd_arch;