[PATCH] RISC-V/objdump: Do not re-seacrh for mapping symbols when didn't find any.
dmitry.bushev@syntacore.com
dmitry.bushev@syntacore.com
Fri Sep 6 11:56:29 GMT 2024
From: Dmitry Bushev <dmitry.bushev@syntacore.com>
In object files without any mapping symbols it's better to not
search up to start of a section upon each instruction entry. Instead,
cache symbol number from which search was started and if no symbol found,
next time do not search past that symbol.
Signed-off-by: Dmitry Bushev <dmitry.bushev@syntacore.com>
---
opcodes/riscv-dis.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 8ab138e45ce..c754e1d9460 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -69,6 +69,7 @@ struct riscv_private_data
/* Used for mapping symbols. */
static int last_map_symbol = -1;
static bfd_vma last_stop_offset = 0;
+static int no_mapping_symbols_before = 0;
static bfd_vma last_map_symbol_boundary = 0;
static enum riscv_seg_mstate last_map_state = MAP_NONE;
static asection *last_map_section = NULL;
@@ -1136,7 +1137,10 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
/* Reset the last_map_symbol if we start to dump a new section. */
if (memaddr <= 0)
- last_map_symbol = -1;
+ {
+ last_map_symbol = -1;
+ no_mapping_symbols_before = 0;
+ }
/* If the last stop offset is different from the current one, then
don't use the last_map_symbol to search. We usually reset the
@@ -1172,8 +1176,9 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
if (!found)
{
n = from_last_map_symbol ? last_map_symbol : info->symtab_pos;
+ int start_n = n;
- for (; n >= 0; n--)
+ for (; n >= no_mapping_symbols_before; n--)
{
bfd_vma addr = bfd_asymbol_value (info->symtab[n]);
/* We have searched all possible symbols in the range. */
@@ -1187,6 +1192,10 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
break;
}
}
+ /* Remember that we already scanned all symbols before start_n and
+ * didn't find any. Next time, do not scan those symbols again. */
+ if (!found)
+ no_mapping_symbols_before = start_n;
}
if (found)
--
2.34.1
More information about the Binutils
mailing list