[binutils-gdb] MIPS: Add missing Allegrex machine type handling
Maciej W. Rozycki
macro@sourceware.org
Sun Nov 8 18:44:52 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ea2f63dbf28248746891feb40d0d2e154981797
commit 0ea2f63dbf28248746891feb40d0d2e154981797
Author: Maciej W. Rozycki <macro@orcam.me.uk>
Date: Sun Nov 8 18:39:34 2026 +0000
MIPS: Add missing Allegrex machine type handling
Complement commit df18f71b565c ("Add MIPS Allegrex CPU as a MIPS2-based
CPU") and define missing AFL_EXT_ALLEGREX .MIPS.abiflags tag. Also add
the Allegrex machine type to a.out and reorder it in the list of MIPS II
extensions to maintain reverse chronology.
Diff:
---
bfd/aoutx.h | 1 +
bfd/elfxx-mips.c | 4 +++-
binutils/readelf.c | 3 +++
elfcpp/mips.h | 6 +++++-
gas/testsuite/gas/mips/elf_mach_allegrex.d | 22 ++++++++++++++++++++++
gas/testsuite/gas/mips/mips.exp | 1 +
gold/mips.cc | 13 +++++++++++++
include/elf/mips.h | 1 +
8 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 12950157ab1..908fb062511 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -786,6 +786,7 @@ NAME (aout, machine_type) (enum bfd_architecture arch,
break;
case bfd_mach_mips6000:
case bfd_mach_mips4010:
+ case bfd_mach_mips_allegrex:
arch_flags = M_MIPS2;
break;
case bfd_mach_mips4000:
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index fd33ca2e0b2..8af886e17ed 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -14730,8 +14730,8 @@ static const struct mips_mach_extension mips_mach_extensions[] =
/* MIPS II extensions. */
{ bfd_mach_mips4000, bfd_mach_mips6000 },
{ bfd_mach_mipsisa32, bfd_mach_mips6000 },
- { bfd_mach_mips4010, bfd_mach_mips6000 },
{ bfd_mach_mips_allegrex, bfd_mach_mips6000 },
+ { bfd_mach_mips4010, bfd_mach_mips6000 },
/* MIPS I extensions. */
{ bfd_mach_mips6000, bfd_mach_mips3000 },
@@ -14784,6 +14784,7 @@ bfd_mips_isa_ext_mach (unsigned int isa_ext)
{
case AFL_EXT_3900: return bfd_mach_mips3900;
case AFL_EXT_4010: return bfd_mach_mips4010;
+ case AFL_EXT_ALLEGREX: return bfd_mach_mips_allegrex;
case AFL_EXT_4100: return bfd_mach_mips4100;
case AFL_EXT_4111: return bfd_mach_mips4111;
case AFL_EXT_4120: return bfd_mach_mips4120;
@@ -14814,6 +14815,7 @@ bfd_mips_isa_ext (bfd *abfd)
{
case bfd_mach_mips3900: return AFL_EXT_3900;
case bfd_mach_mips4010: return AFL_EXT_4010;
+ case bfd_mach_mips_allegrex: return AFL_EXT_ALLEGREX;
case bfd_mach_mips4100: return AFL_EXT_4100;
case bfd_mach_mips4111: return AFL_EXT_4111;
case bfd_mach_mips4120: return AFL_EXT_4120;
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 13741f627d7..62a67dab851 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -20126,6 +20126,9 @@ print_mips_isa_ext (unsigned int isa_ext)
case AFL_EXT_INTERAPTIV_MR2:
fputs ("Imagination interAptiv MR2", stdout);
break;
+ case AFL_EXT_ALLEGREX:
+ fputs ("Sony PSP Allegrex", stdout);
+ break;
default:
fprintf (stdout, "%s (%d)", _("Unknown"), isa_ext);
}
diff --git a/elfcpp/mips.h b/elfcpp/mips.h
index b202ed07223..6f1e9ff93ae 100644
--- a/elfcpp/mips.h
+++ b/elfcpp/mips.h
@@ -218,6 +218,7 @@ enum
EF_MIPS_MACH_3900 = 0x00810000,
EF_MIPS_MACH_4010 = 0x00820000,
EF_MIPS_MACH_4100 = 0x00830000,
+ EF_MIPS_MACH_ALLEGREX = 0x00840000,
EF_MIPS_MACH_4650 = 0x00850000,
EF_MIPS_MACH_4120 = 0x00870000,
EF_MIPS_MACH_4111 = 0x00880000,
@@ -242,6 +243,7 @@ enum
E_MIPS_MACH_3900 = EF_MIPS_MACH_3900,
E_MIPS_MACH_4010 = EF_MIPS_MACH_4010,
E_MIPS_MACH_4100 = EF_MIPS_MACH_4100,
+ E_MIPS_MACH_ALLEGREX = EF_MIPS_MACH_ALLEGREX,
E_MIPS_MACH_4650 = EF_MIPS_MACH_4650,
E_MIPS_MACH_4120 = EF_MIPS_MACH_4120,
E_MIPS_MACH_4111 = EF_MIPS_MACH_4111,
@@ -391,7 +393,9 @@ enum
// Cavium Networks Octeon3.
AFL_EXT_OCTEON3 = 19,
// Imagination interAptiv MR2.
- AFL_EXT_INTERAPTIV_MR2 = 20
+ AFL_EXT_INTERAPTIV_MR2 = 20,
+ // Sony PSP Allegrex.
+ AFL_EXT_ALLEGREX = 21
};
// Masks for the flags1 word of an ABI flags structure.
diff --git a/gas/testsuite/gas/mips/elf_mach_allegrex.d b/gas/testsuite/gas/mips/elf_mach_allegrex.d
new file mode 100644
index 00000000000..ee75414f8f1
--- /dev/null
+++ b/gas/testsuite/gas/mips/elf_mach_allegrex.d
@@ -0,0 +1,22 @@
+#readelf: -Ah
+#name: ELF Allegrex markings
+#as: -32 -march=allegrex
+#source: empty.s
+
+ELF Header:
+#...
+ Flags: +0x..84...., .*allegrex.*
+#...
+
+MIPS ABI Flags Version: 0
+
+ISA: MIPS2
+GPR size: 32
+CPR1 size: 32
+CPR2 size: 0
+FP ABI: .*
+ISA Extension: Sony PSP Allegrex
+ASEs:
+ None
+FLAGS 1: .*
+FLAGS 2: .*
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index fe149c92798..d9aeb1138ef 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -1198,6 +1198,7 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "elf_ase_micromips-2"
# Verify that machine markings are handled properly.
+ run_dump_test "elf_mach_allegrex"
run_dump_test "elf_mach_5900"
run_dump_test "elf_mach_interaptiv-mr2"
run_dump_test "elf_mach_p6600"
diff --git a/gold/mips.cc b/gold/mips.cc
index 826ab8f76fc..26b2afbff7c 100644
--- a/gold/mips.cc
+++ b/gold/mips.cc
@@ -3979,6 +3979,7 @@ class Target_mips : public Sized_target<size, big_endian>
mach_mips16000 = 16000,
mach_mips16 = 16,
mach_mips5 = 5,
+ mach_mips_allegrex = 10111431, // octal 'AL', 31
mach_mips_loongson_2e = 3001,
mach_mips_loongson_2f = 3002,
mach_mips_gs464 = 3003,
@@ -4206,6 +4207,7 @@ class Target_mips : public Sized_target<size, big_endian>
// MIPS II extensions.
this->add_extension(mach_mips4000, mach_mips6000);
this->add_extension(mach_mipsisa32, mach_mips6000);
+ this->add_extension(mach_mips_allegrex, mach_mips6000);
this->add_extension(mach_mips4010, mach_mips6000);
// MIPS I extensions.
@@ -8870,6 +8872,9 @@ Target_mips<size, big_endian>::elf_mips_mach(elfcpp::Elf_Word flags)
case elfcpp::EF_MIPS_MACH_4010:
return mach_mips4010;
+ case elfcpp::EF_MIPS_MACH_ALLEGREX:
+ return mach_mips_allegrex;
+
case elfcpp::EF_MIPS_MACH_4100:
return mach_mips4100;
@@ -8983,6 +8988,9 @@ Target_mips<size, big_endian>::mips_isa_ext_mach(unsigned int isa_ext)
case elfcpp::AFL_EXT_4010:
return mach_mips4010;
+ case elfcpp::AFL_EXT_ALLEGREX:
+ return mach_mips_allegrex;
+
case elfcpp::AFL_EXT_4100:
return mach_mips4100;
@@ -9053,6 +9061,9 @@ Target_mips<size, big_endian>::mips_isa_ext(unsigned int mips_mach)
case mach_mips4010:
return elfcpp::AFL_EXT_4010;
+ case mach_mips_allegrex:
+ return elfcpp::AFL_EXT_ALLEGREX;
+
case mach_mips4100:
return elfcpp::AFL_EXT_4100;
@@ -12575,6 +12586,8 @@ Target_mips<size, big_endian>::elf_mips_mach_name(elfcpp::Elf_Word e_flags)
return "mips:4010";
case elfcpp::EF_MIPS_MACH_4100:
return "mips:4100";
+ case elfcpp::EF_MIPS_MACH_ALLEGREX:
+ return "mips:allegrex";
case elfcpp::EF_MIPS_MACH_4111:
return "mips:4111";
case elfcpp::EF_MIPS_MACH_4120:
diff --git a/include/elf/mips.h b/include/elf/mips.h
index b8d460d9f54..187585efc6d 100644
--- a/include/elf/mips.h
+++ b/include/elf/mips.h
@@ -1322,6 +1322,7 @@ extern void bfd_mips_elf_swap_abiflags_v0_out
#define AFL_EXT_LOONGSON_2F 18 /* ST Microelectronics Loongson 2F. */
#define AFL_EXT_OCTEON3 19 /* Cavium Networks Octeon3. */
#define AFL_EXT_INTERAPTIV_MR2 20 /* Imagination interAptiv MR2. */
+#define AFL_EXT_ALLEGREX 21 /* Sony PSP Allegrex. */
/* Masks for the flags1 word of an ABI flags structure. */
#define AFL_FLAGS1_ODDSPREG 1 /* Uses odd single-precision registers. */
More information about the Binutils-cvs
mailing list