aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-mips.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r--bfd/elfxx-mips.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 751deed..13a8995 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14524,6 +14524,16 @@ struct mips_mach_extension
unsigned long extension, base;
};
+/* An array that maps 64-bit architectures to the corresponding 32-bit
+ architectures. */
+static const struct mips_mach_extension mips_mach_32_64[] =
+{
+ { bfd_mach_mipsisa64r6, bfd_mach_mipsisa32r6 },
+ { bfd_mach_mipsisa64r5, bfd_mach_mipsisa32r5 },
+ { bfd_mach_mipsisa64r3, bfd_mach_mipsisa32r3 },
+ { bfd_mach_mipsisa64r2, bfd_mach_mipsisa32r2 },
+ { bfd_mach_mipsisa64, bfd_mach_mipsisa32 }
+};
/* An array describing how BFD machines relate to one another. The entries
are ordered topologically with MIPS I extensions listed last. */
@@ -14601,29 +14611,37 @@ static const struct mips_mach_extension mips_mach_extensions[] =
{ bfd_mach_mips3900, bfd_mach_mips3000 }
};
-/* Return true if bfd machine EXTENSION is an extension of machine BASE. */
+/* Return true if bfd machine EXTENSION is the same as BASE, or if
+ EXTENSION is the 64-bit equivalent of a 32-bit BASE. */
static bool
-mips_mach_extends_p (unsigned long base, unsigned long extension)
+mips_mach_extends_32_64 (unsigned long base, unsigned long extension)
{
size_t i;
if (extension == base)
return true;
- if (base == bfd_mach_mipsisa32
- && mips_mach_extends_p (bfd_mach_mipsisa64, extension))
- return true;
+ for (i = 0; i < ARRAY_SIZE (mips_mach_32_64); i++)
+ if (extension == mips_mach_32_64[i].extension)
+ return base == mips_mach_32_64[i].base;
+
+ return false;
+}
+
+static bool
+mips_mach_extends_p (unsigned long base, unsigned long extension)
+{
+ size_t i;
- if (base == bfd_mach_mipsisa32r2
- && mips_mach_extends_p (bfd_mach_mipsisa64r2, extension))
+ if (mips_mach_extends_32_64 (base, extension))
return true;
for (i = 0; i < ARRAY_SIZE (mips_mach_extensions); i++)
if (extension == mips_mach_extensions[i].extension)
{
extension = mips_mach_extensions[i].base;
- if (extension == base)
+ if (mips_mach_extends_32_64 (base, extension))
return true;
}