public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelson.chu@sifive.com>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Binutils <binutils@sourceware.org>, Jim Wilson <jimw@sifive.com>,
	 Andrew Waterman <andrew@sifive.com>,
	Kito Cheng <kito.cheng@sifive.com>
Subject: Re: [RFC] RISC-V: PR27916, Support mapping symbols.
Date: Thu, 24 Jun 2021 10:06:56 +0800	[thread overview]
Message-ID: <CAJYME4GkRXEKobg4F3p-dVUpsOtXR=6dHMUiKts=qiAm=ZuqRQ@mail.gmail.com> (raw)
In-Reply-To: <mhng-09efa1bf-68c4-4a57-95f6-a670a3f83393@palmerdabbelt-glaptop>

Hi Palmer,

Sorry for the late reply, thanks for your suggestion :)

On Thu, Jun 3, 2021 at 12:18 PM Palmer Dabbelt <palmer@dabbelt.com> wrote:
>
> On Fri, 28 May 2021 19:18:18 PDT (-0700), nelson.chu@sifive.com wrote:
> > Similar to ARM/AARCH64, we add mapping symbols in the symbol table,
> > to mark the start addresses of data and instructions.  The $d means data,
> > and the $x means instruction.  Then the disassembler uses these symbols
>
> We picked "__global_pointer$" under the assumption "$" would avoid any
> conflicts with symbols from user code, so these should be safe too.
> IIRC that's a normal way to do these things, and with Arm already having
> those names that seems like a good way to go.

Thanks for agreeing this.

> > TODOS,
> > * Need to add new directive, .inst 0x00000013, to show this is encoded as an
> > instruction, rather than a data.
>
> Maybe just an add explicit 4-byte NOP pseudo instruction or alias?  I
> keep finding myself in the position where I want to insert exactly 4
> bytes of NOP and the automatic compression gets in the way.

Oh, it may not be good to give the nop as example.  We have .insn
directive to let users can use their own instructions, or some new
instruction, which haven't supported in the old binutils.  For
example, if users want to use sifive cache instruction, they cannot
just write "cflush.d1.l1" and complied by the fsf binutils, but they
can write ".insn i SYSTEM, 0, x0, x10, -0x40".  But as you can see,
the .insn directive may not easy to use for some cases.  Therefore, I
believe most of the users are using ".word 0xfc050073" rather than the
.insn.  But if they always use ".word xxxxx" to encode their
instructions, then the mapping symbols will treat these .word as data
rather than instruction.  I see that arm defines .inst/.inst.w/.inst.n
to resolve the problem, so maybe we can follow this way.

> > * Consider RVC to NORVC, and DATA to INSN, we probably need to add the
> > alignments automatically by assembler.  But in fact the things that need
> > to be dealt with are more complicated than imagined.
>
> We've been through this a bunch of times and it always ends up somewhat
> hairy.  There's sort of this balance between trying to avoid inserting
> non-executable instructions -- either a single-byte NOP (for re-aligning
> on bytes) or a two-byte NOP outside of C (for re-aligning when turning
> off C).  IIRC we spent a lot of time trying to do a better job than
> we're currently doing and there were always enough edge cases that we
> decided to just make the user deal with these issues explicitly.
>
> If you've got an idea of how to do a better job I'm all ears, just
> warning that this might be more frusturation than it's worth.

Thanks, this issue really really frustrated me for a long time, haha.
The priority of this isn't high, so I just record it as one of the
TODO, and don't want to give up it.  Maybe someday, or someone will
have amazing ideas that surprise us.

> > * Consider the testcase mapping-norelax-04b.s, there is a c.nop which is
> > used to do the alignment, but the rvc extension is disabled.  This may
> > looks weird and confuse user, so maybe we should treat these alignments
> > as MAP_DATA rather than MAP_INSN?  Or maybe treat as a new MAP_ALIGNMNET?
>
> IMO that's the right way to go here.  The C instructions aren't valid
> without the C ISA, so they're not really quite instructions at that
> point.  As above there's always been a bunch of rough edges around this
> sort of thing, though, so it might be hard to make this work without
> causing a headache somewhere else.

Yeah, just consider one of these issue may be fine, but if we consider
all of them at the same time, then things will start to get out of
control...


Thanks again for the feedback
Nelson

      reply	other threads:[~2021-06-24  2:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-29  2:18 Nelson Chu
2021-06-03  4:18 ` Palmer Dabbelt
2021-06-24  2:06   ` Nelson Chu [this message]

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='CAJYME4GkRXEKobg4F3p-dVUpsOtXR=6dHMUiKts=qiAm=ZuqRQ@mail.gmail.com' \
    --to=nelson.chu@sifive.com \
    --cc=andrew@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=jimw@sifive.com \
    --cc=kito.cheng@sifive.com \
    --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).