From: Andrew Burgess <aburgess@redhat.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: binutils@sourceware.org
Subject: Re: [PATCH 1/2] opcodes/mips: use .word/.short for undefined instructions
Date: Fri, 06 Jan 2023 16:40:32 +0000 [thread overview]
Message-ID: <87fscny5tr.fsf@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2301061545130.54090@angie.orcam.me.uk>
"Maciej W. Rozycki" <macro@orcam.me.uk> writes:
> Hi Andrew,
>
> In the course of reviewing outstanding upstream mailing list traffic I
> came across this change of yours.
>
> On Thu, 3 Nov 2022, Andrew Burgess via Binutils wrote:
>
>> diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
>> index faeebccfc3b..1d9875f2bb0 100644
>> --- a/opcodes/mips-dis.c
>> +++ b/opcodes/mips-dis.c
>> @@ -2515,7 +2515,10 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info)
>> }
>> }
>>
>> - infprintf (is, "0x%x", insn);
>> + if (length == 2)
>> + infprintf (is, ".short\t0x%x", insn);
>> + else
>> + infprintf (is, ".word\t0x%x", insn);
>
> FYI, I find this questionable as `.word' (at least with the MIPS target)
> implies natural alignment while 32-bit microMIPS encodings, valid or not,
> are not. Also, given the endianness peculiarity (analogous to the MIPS16
> extended encodings), I think this needs to be ".short\t0x%x, 0x%x" really,
> with the instruction word split into halfwords for any reasonable meaning.
> This is already reflected in the raw hex dump of instruction streams; the
> numbers printed need to match it.
>
> With the naked number previously used this obviously didn't matter as it
> stood out without any attempt to pretend to have a meaning. This is also
> the reason why I chose to keep it as it used to be since forever.
Hi,
Below is an initial patch. When I set the environment variable
DISABLE_MATCHING then the disassembler fails to match all instructions,
so prints .short for everything.
Right now I can't find anything where this doesn't work, but I don't
believe that the answer is actually this simple. Given your deeper
knowledge of the target, could you take a look at what I have below and
point me at some tests/configurations/whatever where this isn't going to
be good enough?
Alternatively, if this is enough, then I'll write this up into a proper
patch.
Thanks,
Andrew
---
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index 6a513cd8946..5c6ec9a1147 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -2554,6 +2554,9 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info)
opend = micromips_opcodes + bfd_micromips_num_opcodes;
for (op = micromips_opcodes; op < opend; op++)
{
+ if (getenv ("DISABLE_MATCHING") != NULL)
+ break;
+
if (op->pinfo != INSN_MACRO
&& !(no_aliases && (op->pinfo2 & INSN2_ALIAS))
&& (insn & op->mask) == op->match
@@ -2601,11 +2604,19 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info)
}
if (length == 2)
- infprintf (is, dis_style_assembler_directive, ".short");
+ {
+ infprintf (is, dis_style_assembler_directive, ".short");
+ infprintf (is, dis_style_text, "\t");
+ infprintf (is, dis_style_immediate, "0x%x", insn);
+ }
else
- infprintf (is, dis_style_assembler_directive, ".word");
- infprintf (is, dis_style_text, "\t");
- infprintf (is, dis_style_immediate, "0x%x", insn);
+ {
+ infprintf (is, dis_style_assembler_directive, ".short");
+ infprintf (is, dis_style_text, "\t");
+ infprintf (is, dis_style_immediate, "0x%x", (insn >> 16) & 0xffff);
+ infprintf (is, dis_style_text, ", ");
+ infprintf (is, dis_style_immediate, "0x%x", (insn & 0xffff));
+ }
info->insn_type = dis_noninsn;
return length;
next prev parent reply other threads:[~2023-01-06 16:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 13:58 [PATCH 0/2] MIPS disassembler styling Andrew Burgess
2022-11-03 13:58 ` [PATCH 1/2] opcodes/mips: use .word/.short for undefined instructions Andrew Burgess
2023-01-06 15:58 ` Maciej W. Rozycki
2023-01-06 16:40 ` Andrew Burgess [this message]
2023-01-08 16:05 ` Maciej W. Rozycki
2023-01-17 10:28 ` Andrew Burgess
2023-01-27 11:57 ` Maciej W. Rozycki
2023-01-30 9:34 ` Andrew Burgess
2023-02-01 10:40 ` Maciej W. Rozycki
2023-02-01 15:32 ` Andrew Burgess
2023-02-02 9:48 ` Maciej W. Rozycki
2023-02-03 9:31 ` Andrew Burgess
2023-02-13 12:07 ` Andrew Burgess
2023-02-14 4:43 ` Maciej W. Rozycki
2022-11-03 13:58 ` [PATCH 2/2] libopcodes/mips: add support for disassembler styling Andrew Burgess
2022-11-28 17:15 ` [PATCH 0/2] MIPS " Andrew Burgess
2022-11-30 16:50 ` Nick Clifton
2022-12-05 10:08 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fscny5tr.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=binutils@sourceware.org \
--cc=macro@orcam.me.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).