public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelson@rivosinc.com>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Jan Beulich <jbeulich@suse.com>,
	Binutils <binutils@sourceware.org>,
	 Palmer Dabbelt <palmer@dabbelt.com>,
	Andrew Waterman <andrew@sifive.com>,
	 Jim Wilson <jim.wilson.gcc@gmail.com>,
	Kito Cheng <kito.cheng@sifive.com>
Subject: Re: [PATCH] RISC-V: don't disassemble unrecognized insns as .byte
Date: Mon, 30 Jan 2023 11:03:25 +0800	[thread overview]
Message-ID: <CAPpQWtAj5xoczt_8YNAwHK4mYNBfrsDqCz7gncX=6YUtWpPHew@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2301300149070.55843@angie.orcam.me.uk>

Hi Maciej,

On Mon, Jan 30, 2023 at 9:51 AM Maciej W. Rozycki <macro@orcam.me.uk> wrote:
>
> On Mon, 30 Jan 2023, Nelson Chu wrote:
>
> > > Insn width granularity being 16 bits, produce 16 bits of data per output
> > > element for the non-special-cased insn widths. Besides being slightly
> > > more natural (in particular having the first element carry everything
> > > that's needed for determining insn length), this is also slightly more
> > > compact.
> >
> > Sounds reasonable and good, so please commit, thanks.
>
>  Why not `.short' though, the more usual pseudo-op (and documented as
> portable in the GAS manual)?

Not sure if there are any documents mentioning this, but I remember
that there has always been an issue of hoping to distinguish whether
the encodings is an instruction or data  The .<N>byte may not be used
to do that at the beginning (maybe just let dis-assembler dump the
legal formats, https://github.com/bminor/binutils-gdb/commit/6a7f57668afcd841e8fc6b507a27bb20e9209fa9),
but sometimes it has the same effect - For example, .2byte is an
instruction but unrecognized, .short is a data in text.  However, it
isn't good enough, since,

% cat tmp.s
.text
.short 0x1
.insn 0x1
.2byte 0x1
% riscv64-unknown-elf-as tmp.s -o tmp.o
% riscv64-unknown-elf-objdump -d tmp.o
...
Disassembly of section .text:

0000000000000000 <.text>:
   0: 0001                .short 0x0001
   2: 0001                .2byte 0x1
   4: 0001                .short 0x0001
...

The .<N>byte in assembly will also be treated as data to dump, so
ideally, dump these unrecognized instructions as .insn is probably
more reasonable and won't be confused.

Thanks
Nelson

  reply	other threads:[~2023-01-30  3:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 13:14 Jan Beulich
2023-01-30  1:40 ` Nelson Chu
2023-01-30  1:51   ` Maciej W. Rozycki
2023-01-30  3:03     ` Nelson Chu [this message]
2023-01-30  3:33       ` Maciej W. Rozycki
2023-01-31  1:51         ` Nelson Chu
2023-01-30  2:07   ` Kito Cheng
2023-01-30  7:51   ` Jan Beulich

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='CAPpQWtAj5xoczt_8YNAwHK4mYNBfrsDqCz7gncX=6YUtWpPHew@mail.gmail.com' \
    --to=nelson@rivosinc.com \
    --cc=andrew@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=jim.wilson.gcc@gmail.com \
    --cc=kito.cheng@sifive.com \
    --cc=macro@orcam.me.uk \
    --cc=palmer@dabbelt.com \
    /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).