[PATCH] RISC-V: Search for mapping symbols from the last one found

Joseph Faulls Joseph.Faulls@imgtec.com
Thu Apr 18 10:48:56 GMT 2024


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20240418/bd17a185/attachment.htm>


More information about the Binutils mailing list