[PATCH] LoongArch: Fix disassembly option parsing stopping at the first option
WANG Xuerui
i.swmail@xen0n.name
Mon Mar 24 07:54:25 GMT 2025
From: WANG Xuerui <git@xen0n.name>
Turns out the return value of parse_loongarch_dis_option acts as an
error code, and previously the function always signified failure with
a non-zero return value, making only the first disassembly option get
to take effect.
Fix by adding the missing `return 0`'s to the two success code paths.
Signed-off-by: WANG Xuerui <git@xen0n.name>
---
.../binutils-all/loongarch64/dis-options-multi.d | 10 ++++++++++
.../binutils-all/loongarch64/dis-options-no-alises.d | 10 ++++++++++
.../binutils-all/loongarch64/dis-options-numeric.d | 10 ++++++++++
.../testsuite/binutils-all/loongarch64/dis-options.s | 3 +++
opcodes/loongarch-dis.c | 7 ++++++-
5 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 binutils/testsuite/binutils-all/loongarch64/dis-options-multi.d
create mode 100644 binutils/testsuite/binutils-all/loongarch64/dis-options-no-alises.d
create mode 100644 binutils/testsuite/binutils-all/loongarch64/dis-options-numeric.d
create mode 100644 binutils/testsuite/binutils-all/loongarch64/dis-options.s
diff --git a/binutils/testsuite/binutils-all/loongarch64/dis-options-multi.d b/binutils/testsuite/binutils-all/loongarch64/dis-options-multi.d
new file mode 100644
index 00000000000..2f34cb866d1
--- /dev/null
+++ b/binutils/testsuite/binutils-all/loongarch64/dis-options-multi.d
@@ -0,0 +1,10 @@
+#name: LoongArch disassembler options: multiple
+#source: dis-options.s
+#objdump: -d --no-show-raw-insn -M no-aliases,numeric
+
+#...
+Disassembly of section \.text:
+
+[0-9a-f]+ <\.text>:
+ [0-9a-f]+:[ ]+or[ ]+\$r4, \$r21, \$r0
+ [0-9a-f]+:[ ]+jirl[ ]+\$r0, \$r1, 0
diff --git a/binutils/testsuite/binutils-all/loongarch64/dis-options-no-alises.d b/binutils/testsuite/binutils-all/loongarch64/dis-options-no-alises.d
new file mode 100644
index 00000000000..eb4ea62afc9
--- /dev/null
+++ b/binutils/testsuite/binutils-all/loongarch64/dis-options-no-alises.d
@@ -0,0 +1,10 @@
+#name: LoongArch disassembler options: no-aliases
+#source: dis-options.s
+#objdump: -d --no-show-raw-insn -M no-aliases
+
+#...
+Disassembly of section \.text:
+
+[0-9a-f]+ <\.text>:
+ [0-9a-f]+:[ ]+or[ ]+\$a0, \$r21, \$zero
+ [0-9a-f]+:[ ]+jirl[ ]+\$zero, \$ra, 0
diff --git a/binutils/testsuite/binutils-all/loongarch64/dis-options-numeric.d b/binutils/testsuite/binutils-all/loongarch64/dis-options-numeric.d
new file mode 100644
index 00000000000..e669cef30bf
--- /dev/null
+++ b/binutils/testsuite/binutils-all/loongarch64/dis-options-numeric.d
@@ -0,0 +1,10 @@
+#name: LoongArch disassembler options: numeric
+#source: dis-options.s
+#objdump: -d --no-show-raw-insn -M numeric
+
+#...
+Disassembly of section \.text:
+
+[0-9a-f]+ <\.text>:
+ [0-9a-f]+:[ ]+move[ ]+\$r4, \$r21
+ [0-9a-f]+:[ ]+ret
diff --git a/binutils/testsuite/binutils-all/loongarch64/dis-options.s b/binutils/testsuite/binutils-all/loongarch64/dis-options.s
new file mode 100644
index 00000000000..a3a4469eac3
--- /dev/null
+++ b/binutils/testsuite/binutils-all/loongarch64/dis-options.s
@@ -0,0 +1,3 @@
+.text
+ move $a0, $r21
+ ret
diff --git a/opcodes/loongarch-dis.c b/opcodes/loongarch-dis.c
index cc4a48c38b8..2e59bf8035f 100644
--- a/opcodes/loongarch-dis.c
+++ b/opcodes/loongarch-dis.c
@@ -95,13 +95,18 @@ static int
parse_loongarch_dis_option (const char *option)
{
if (strcmp (option, "no-aliases") == 0)
- loongarch_dis_show_aliases = false;
+ {
+ loongarch_dis_show_aliases = false;
+ return 0;
+ }
if (strcmp (option, "numeric") == 0)
{
loongarch_r_disname = loongarch_r_normal_name;
loongarch_f_disname = loongarch_f_normal_name;
+ return 0;
}
+
return -1;
}
--
2.48.1
More information about the Binutils
mailing list