public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Faulls <Joseph.Faulls@imgtec.com>
To: "binutils@sourceware.org" <binutils@sourceware.org>
Cc: "nelson@rivosinc.com" <nelson@rivosinc.com>
Subject: Re: [PATCH] RISC-V: Search for mapping symbols from the last one found
Date: Fri, 3 May 2024 12:56:47 +0000	[thread overview]
Message-ID: <LO4P265MB591425A791763905D3856FA5801F2@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <LO4P265MB59146D9EC80F0DF767BEFC7B800E2@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM>

[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]

Ping. I know it's a small patch, but it sped up disassembly of my use case from 5 minutes to 5 seconds.
________________________________
From: Joseph Faulls
Sent: Thursday, April 18, 2024 11:48 AM
To: binutils@sourceware.org <binutils@sourceware.org>
Cc: nelson@rivosinc.com <nelson@rivosinc.com>
Subject: [PATCH] RISC-V: Search for mapping symbols from the last one found

With previous behaviour, multiple mapping symbols within the same
function would result in all the mapping symbols being searched.
This could slow down disassembly dramatically.

Multiple mapping symbols within a function can be a result of encoding
instructions as data, like sometimes seen in random instruction
generators.

opcodes/ChangeLog:

        * riscv-dis.c (riscv_search_mapping_symbol): Use last mapping
          symbol if it exists.

Note for reviewers:
I don't see why the previous check 'n >= last_map_symbol exists'. Why do we force starting from the start of the function if the last mapping symbol was found after it? If I'm missing something, please let me know!

---
 opcodes/riscv-dis.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 684098d386a..24286702dd3 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -1076,11 +1076,12 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
   from_last_map_symbol = (last_map_symbol >= 0
                          && info->stop_offset == last_stop_offset);

-  /* Start scanning at the start of the function, or wherever
-     we finished last time.  */
-  n = info->symtab_pos + 1;
-  if (from_last_map_symbol && n >= last_map_symbol)
+  /* Start scanning from wherever we finished last time, or the start
+     of the function.  */
+  if (from_last_map_symbol)
     n = last_map_symbol;
+  else
+    n = info->symtab_pos + 1;

   /* Find the suitable mapping symbol to dump.  */
   for (; n < info->symtab_size; n++)
--
2.34.1

  reply	other threads:[~2024-05-03 12:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 10:48 Joseph Faulls
2024-05-03 12:56 ` Joseph Faulls [this message]
2024-05-06 15:12   ` Palmer Dabbelt
2024-05-14  0:34     ` Nelson Chu
2024-05-14  9:10       ` Joseph Faulls
2024-05-14 23:14         ` Nelson Chu

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=LO4P265MB591425A791763905D3856FA5801F2@LO4P265MB5914.GBRP265.PROD.OUTLOOK.COM \
    --to=joseph.faulls@imgtec.com \
    --cc=binutils@sourceware.org \
    --cc=nelson@rivosinc.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).