[PATCH v2] MIPS objdump: Add `eabi32` and `eabi64` ABI options
Anghelo Carvajal
angheloalf95@gmail.com
Tue Feb 11 19:56:22 GMT 2025
Extend gpr and fpr register names with names suitable for both EABIs.
Heavily inspired by the EABI documenation written by Eric Christopher,
which can be read at
https://sourceware.org/legacy-ml/binutils/2003-06/msg00436.html
Signed-off-by: Anghelo Carvajal <angheloalf95@gmail.com>
---
Hi Maciej,
Thanks for the review, I applied your requested changes.
Sorry for not going into more detail in my previous patch, this is the
first time I use `git send-email', so I sent the email without any
write-up.
> Thank you for linking the reference into the change description. As it
> only talks about argument registers when it comes to FPRs and does not
> mention which are static and which are temporary I have cross-checked it
> with GCC sources and things are looking good in your change.
Indeed, it doesn't mention which float registers are temporary nor
saved. What I did to ensure the names are correct was to look at the
generated assembly from GCC in godbolt and other compilers.
> We don't usually update ChangeLog files anymore, but you can include a
> record with your commit description if you like. In that case please
> use the imperative mood though, i.e.:
Oh, I thought ChangeLog files were still being updated since there are
changes as recent as this year.
I updated the entry following your advice, but I can also remove the
entry if preferred.
> As a matter of interest this is the first mention of the MIPS EABI I
> have seen in decades (which I gather means things have been working
> perfectly all the time on that side), so do you actually have a use for
> this stuff?
Yes! I do have an use for EABI. It is used in the Sony PlayStation 2's
reverse engineering community, which uses EABI for most of its games.
Specifically we are working on matching decompilation of PS2 games.
Using named registers for EABI allows to better think of what the
assembly is doing.
Anghelo
gas/testsuite/gas/mips/fpr-names-eabi32.d | 42 +++++++++++++++++++++++
gas/testsuite/gas/mips/fpr-names-eabi64.d | 42 +++++++++++++++++++++++
gas/testsuite/gas/mips/gpr-names-eabi32.d | 42 +++++++++++++++++++++++
gas/testsuite/gas/mips/gpr-names-eabi64.d | 42 +++++++++++++++++++++++
gas/testsuite/gas/mips/mips.exp | 4 +++
opcodes/ChangeLog | 6 ++++
opcodes/mips-dis.c | 18 ++++++++++
7 files changed, 196 insertions(+)
create mode 100644 gas/testsuite/gas/mips/fpr-names-eabi32.d
create mode 100644 gas/testsuite/gas/mips/fpr-names-eabi64.d
create mode 100644 gas/testsuite/gas/mips/gpr-names-eabi32.d
create mode 100644 gas/testsuite/gas/mips/gpr-names-eabi64.d
diff --git a/gas/testsuite/gas/mips/fpr-names-eabi32.d b/gas/testsuite/gas/mips/fpr-names-eabi32.d
new file mode 100644
index 00000000000..6d9e674e89c
--- /dev/null
+++ b/gas/testsuite/gas/mips/fpr-names-eabi32.d
@@ -0,0 +1,42 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -M gpr-names=numeric,fpr-names=eabi32
+#name: MIPS FPR disassembly (eabi32)
+#source: fpr-names.s
+
+# Check objdump's handling of -M fpr-names=foo options.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+0+0000 <[^>]*> 44800000 mtc1 \$0,fv0
+0+0004 <[^>]*> 44800800 mtc1 \$0,fv0f
+0+0008 <[^>]*> 44801000 mtc1 \$0,fv1
+0+000c <[^>]*> 44801800 mtc1 \$0,fv1f
+0+0010 <[^>]*> 44802000 mtc1 \$0,ft0
+0+0014 <[^>]*> 44802800 mtc1 \$0,ft0f
+0+0018 <[^>]*> 44803000 mtc1 \$0,ft1
+0+001c <[^>]*> 44803800 mtc1 \$0,ft1f
+0+0020 <[^>]*> 44804000 mtc1 \$0,ft2
+0+0024 <[^>]*> 44804800 mtc1 \$0,ft2f
+0+0028 <[^>]*> 44805000 mtc1 \$0,ft3
+0+002c <[^>]*> 44805800 mtc1 \$0,ft3f
+0+0030 <[^>]*> 44806000 mtc1 \$0,fa0
+0+0034 <[^>]*> 44806800 mtc1 \$0,fa0f
+0+0038 <[^>]*> 44807000 mtc1 \$0,fa1
+0+003c <[^>]*> 44807800 mtc1 \$0,fa1f
+0+0040 <[^>]*> 44808000 mtc1 \$0,fa2
+0+0044 <[^>]*> 44808800 mtc1 \$0,fa2f
+0+0048 <[^>]*> 44809000 mtc1 \$0,fa3
+0+004c <[^>]*> 44809800 mtc1 \$0,fa3f
+0+0050 <[^>]*> 4480a000 mtc1 \$0,fs0
+0+0054 <[^>]*> 4480a800 mtc1 \$0,fs0f
+0+0058 <[^>]*> 4480b000 mtc1 \$0,fs1
+0+005c <[^>]*> 4480b800 mtc1 \$0,fs1f
+0+0060 <[^>]*> 4480c000 mtc1 \$0,fs2
+0+0064 <[^>]*> 4480c800 mtc1 \$0,fs2f
+0+0068 <[^>]*> 4480d000 mtc1 \$0,fs3
+0+006c <[^>]*> 4480d800 mtc1 \$0,fs3f
+0+0070 <[^>]*> 4480e000 mtc1 \$0,fs4
+0+0074 <[^>]*> 4480e800 mtc1 \$0,fs4f
+0+0078 <[^>]*> 4480f000 mtc1 \$0,fs5
+0+007c <[^>]*> 4480f800 mtc1 \$0,fs5f
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/fpr-names-eabi64.d b/gas/testsuite/gas/mips/fpr-names-eabi64.d
new file mode 100644
index 00000000000..343feef8188
--- /dev/null
+++ b/gas/testsuite/gas/mips/fpr-names-eabi64.d
@@ -0,0 +1,42 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -M gpr-names=numeric,fpr-names=eabi64
+#name: MIPS FPR disassembly (eabi64)
+#source: fpr-names.s
+
+# Check objdump's handling of -M fpr-names=foo options.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+0+0000 <[^>]*> 44800000 mtc1 \$0,fv0
+0+0004 <[^>]*> 44800800 mtc1 \$0,fv1
+0+0008 <[^>]*> 44801000 mtc1 \$0,ft0
+0+000c <[^>]*> 44801800 mtc1 \$0,ft1
+0+0010 <[^>]*> 44802000 mtc1 \$0,ft2
+0+0014 <[^>]*> 44802800 mtc1 \$0,ft3
+0+0018 <[^>]*> 44803000 mtc1 \$0,ft4
+0+001c <[^>]*> 44803800 mtc1 \$0,ft5
+0+0020 <[^>]*> 44804000 mtc1 \$0,ft6
+0+0024 <[^>]*> 44804800 mtc1 \$0,ft7
+0+0028 <[^>]*> 44805000 mtc1 \$0,ft8
+0+002c <[^>]*> 44805800 mtc1 \$0,ft9
+0+0030 <[^>]*> 44806000 mtc1 \$0,fa0
+0+0034 <[^>]*> 44806800 mtc1 \$0,fa1
+0+0038 <[^>]*> 44807000 mtc1 \$0,fa2
+0+003c <[^>]*> 44807800 mtc1 \$0,fa3
+0+0040 <[^>]*> 44808000 mtc1 \$0,fa4
+0+0044 <[^>]*> 44808800 mtc1 \$0,fa5
+0+0048 <[^>]*> 44809000 mtc1 \$0,fa6
+0+004c <[^>]*> 44809800 mtc1 \$0,fa7
+0+0050 <[^>]*> 4480a000 mtc1 \$0,fs0
+0+0054 <[^>]*> 4480a800 mtc1 \$0,fs1
+0+0058 <[^>]*> 4480b000 mtc1 \$0,fs2
+0+005c <[^>]*> 4480b800 mtc1 \$0,fs3
+0+0060 <[^>]*> 4480c000 mtc1 \$0,fs4
+0+0064 <[^>]*> 4480c800 mtc1 \$0,fs5
+0+0068 <[^>]*> 4480d000 mtc1 \$0,fs6
+0+006c <[^>]*> 4480d800 mtc1 \$0,fs7
+0+0070 <[^>]*> 4480e000 mtc1 \$0,fs8
+0+0074 <[^>]*> 4480e800 mtc1 \$0,fs9
+0+0078 <[^>]*> 4480f000 mtc1 \$0,fs10
+0+007c <[^>]*> 4480f800 mtc1 \$0,fs11
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/gpr-names-eabi32.d b/gas/testsuite/gas/mips/gpr-names-eabi32.d
new file mode 100644
index 00000000000..523f883c22f
--- /dev/null
+++ b/gas/testsuite/gas/mips/gpr-names-eabi32.d
@@ -0,0 +1,42 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -M gpr-names=eabi32
+#name: MIPS GPR disassembly (eabi32)
+#source: gpr-names.s
+
+# Check objdump's handling of -M gpr-names=foo options.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+0+0000 <[^>]*> 3c000000 lui zero,0x0
+0+0004 <[^>]*> 3c010000 lui at,0x0
+0+0008 <[^>]*> 3c020000 lui v0,0x0
+0+000c <[^>]*> 3c030000 lui v1,0x0
+0+0010 <[^>]*> 3c040000 lui a0,0x0
+0+0014 <[^>]*> 3c050000 lui a1,0x0
+0+0018 <[^>]*> 3c060000 lui a2,0x0
+0+001c <[^>]*> 3c070000 lui a3,0x0
+0+0020 <[^>]*> 3c080000 lui a4,0x0
+0+0024 <[^>]*> 3c090000 lui a5,0x0
+0+0028 <[^>]*> 3c0a0000 lui a6,0x0
+0+002c <[^>]*> 3c0b0000 lui a7,0x0
+0+0030 <[^>]*> 3c0c0000 lui t0,0x0
+0+0034 <[^>]*> 3c0d0000 lui t1,0x0
+0+0038 <[^>]*> 3c0e0000 lui t2,0x0
+0+003c <[^>]*> 3c0f0000 lui t3,0x0
+0+0040 <[^>]*> 3c100000 lui s0,0x0
+0+0044 <[^>]*> 3c110000 lui s1,0x0
+0+0048 <[^>]*> 3c120000 lui s2,0x0
+0+004c <[^>]*> 3c130000 lui s3,0x0
+0+0050 <[^>]*> 3c140000 lui s4,0x0
+0+0054 <[^>]*> 3c150000 lui s5,0x0
+0+0058 <[^>]*> 3c160000 lui s6,0x0
+0+005c <[^>]*> 3c170000 lui s7,0x0
+0+0060 <[^>]*> 3c180000 lui t8,0x0
+0+0064 <[^>]*> 3c190000 lui t9,0x0
+0+0068 <[^>]*> 3c1a0000 lui k0,0x0
+0+006c <[^>]*> 3c1b0000 lui k1,0x0
+0+0070 <[^>]*> 3c1c0000 lui gp,0x0
+0+0074 <[^>]*> 3c1d0000 lui sp,0x0
+0+0078 <[^>]*> 3c1e0000 lui s8,0x0
+0+007c <[^>]*> 3c1f0000 lui ra,0x0
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/gpr-names-eabi64.d b/gas/testsuite/gas/mips/gpr-names-eabi64.d
new file mode 100644
index 00000000000..00a421e9acb
--- /dev/null
+++ b/gas/testsuite/gas/mips/gpr-names-eabi64.d
@@ -0,0 +1,42 @@
+#objdump: -dr --prefix-addresses --show-raw-insn -M gpr-names=eabi64
+#name: MIPS GPR disassembly (eabi32)
+#source: gpr-names.s
+
+# Check objdump's handling of -M gpr-names=foo options.
+
+.*: +file format .*mips.*
+
+Disassembly of section .text:
+0+0000 <[^>]*> 3c000000 lui zero,0x0
+0+0004 <[^>]*> 3c010000 lui at,0x0
+0+0008 <[^>]*> 3c020000 lui v0,0x0
+0+000c <[^>]*> 3c030000 lui v1,0x0
+0+0010 <[^>]*> 3c040000 lui a0,0x0
+0+0014 <[^>]*> 3c050000 lui a1,0x0
+0+0018 <[^>]*> 3c060000 lui a2,0x0
+0+001c <[^>]*> 3c070000 lui a3,0x0
+0+0020 <[^>]*> 3c080000 lui a4,0x0
+0+0024 <[^>]*> 3c090000 lui a5,0x0
+0+0028 <[^>]*> 3c0a0000 lui a6,0x0
+0+002c <[^>]*> 3c0b0000 lui a7,0x0
+0+0030 <[^>]*> 3c0c0000 lui t0,0x0
+0+0034 <[^>]*> 3c0d0000 lui t1,0x0
+0+0038 <[^>]*> 3c0e0000 lui t2,0x0
+0+003c <[^>]*> 3c0f0000 lui t3,0x0
+0+0040 <[^>]*> 3c100000 lui s0,0x0
+0+0044 <[^>]*> 3c110000 lui s1,0x0
+0+0048 <[^>]*> 3c120000 lui s2,0x0
+0+004c <[^>]*> 3c130000 lui s3,0x0
+0+0050 <[^>]*> 3c140000 lui s4,0x0
+0+0054 <[^>]*> 3c150000 lui s5,0x0
+0+0058 <[^>]*> 3c160000 lui s6,0x0
+0+005c <[^>]*> 3c170000 lui s7,0x0
+0+0060 <[^>]*> 3c180000 lui t8,0x0
+0+0064 <[^>]*> 3c190000 lui t9,0x0
+0+0068 <[^>]*> 3c1a0000 lui k0,0x0
+0+006c <[^>]*> 3c1b0000 lui k1,0x0
+0+0070 <[^>]*> 3c1c0000 lui gp,0x0
+0+0074 <[^>]*> 3c1d0000 lui sp,0x0
+0+0078 <[^>]*> 3c1e0000 lui s8,0x0
+0+007c <[^>]*> 3c1f0000 lui ra,0x0
+ \.\.\.
diff --git a/gas/testsuite/gas/mips/mips.exp b/gas/testsuite/gas/mips/mips.exp
index d3877a023a2..c654999aff5 100644
--- a/gas/testsuite/gas/mips/mips.exp
+++ b/gas/testsuite/gas/mips/mips.exp
@@ -1331,11 +1331,15 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test "gpr-names-32"
run_dump_test "gpr-names-n32"
run_dump_test "gpr-names-64"
+ run_dump_test "gpr-names-eabi32"
+ run_dump_test "gpr-names-eabi64"
run_dump_test "fpr-names-numeric"
run_dump_test "fpr-names-32"
run_dump_test "fpr-names-n32"
run_dump_test "fpr-names-64"
+ run_dump_test "fpr-names-eabi32"
+ run_dump_test "fpr-names-eabi64"
run_dump_test "cp0-names-numeric"
run_dump_test "cp0-names-r3000"
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 609e621dada..84012228339 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,9 @@
+2025-02-09 Anghelo Carvajal <angheloalf95@gmail.com>
+
+ * mips-dis.c (mips_fpr_names_eabi32): New variable.
+ (mips_fpr_names_eabi64): New variable.
+ (mips_abi_choices): Add "eabi32" and "eabi64" options.
+
2025-01-19 Nick Clifton <nickc@redhat.com>
* 2.44 Branch point.
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index befe353b663..cef67fef036 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -106,6 +106,22 @@ static const char * const mips_fpr_names_64[32] =
"fs0", "fs1", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7"
};
+static const char * const mips_fpr_names_eabi32[32] =
+{
+ "fv0", "fv0f", "fv1", "fv1f", "ft0", "ft0f", "ft1", "ft1f",
+ "ft2", "ft2f", "ft3", "ft3f", "fa0", "fa0f", "fa1", "fa1f",
+ "fa2", "fa2f", "fa3", "fa3f", "fs0", "fs0f", "fs1", "fs1f",
+ "fs2", "fs2f", "fs3", "fs3f", "fs4", "fs4f", "fs5", "fs5f",
+};
+
+static const char * const mips_fpr_names_eabi64[32] =
+{
+ "fv0", "fv1", "ft0", "ft1", "ft2", "ft3", "ft4", "ft5",
+ "ft6", "ft7", "ft8", "ft9", "fa0", "fa1", "fa2", "fa3",
+ "fa4", "fa5", "fa6", "fa7", "fs0", "fs1", "fs2", "fs3",
+ "fs4", "fs5", "fs6", "fs7", "fs8", "fs9", "fs10", "fs11",
+};
+
static const char * const mips_cp0_names_numeric[32] =
{
"$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7",
@@ -454,6 +470,8 @@ struct mips_abi_choice mips_abi_choices[] =
{ "32", mips_gpr_names_oldabi, mips_fpr_names_32 },
{ "n32", mips_gpr_names_newabi, mips_fpr_names_n32 },
{ "64", mips_gpr_names_newabi, mips_fpr_names_64 },
+ { "eabi32", mips_gpr_names_newabi, mips_fpr_names_eabi32 },
+ { "eabi64", mips_gpr_names_newabi, mips_fpr_names_eabi64 },
};
struct mips_arch_choice
--
2.34.1
More information about the Binutils
mailing list