[PATCH] RISC-V/objdump: Do not re-seacrh for mapping symbols when didn't find any.
Nelson Chu
nelson@rivosinc.com
Tue Sep 24 05:10:42 GMT 2024
Hi,
On Fri, Sep 6, 2024 at 7:58 PM <dmitry.bushev@syntacore.com> wrote:
> 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;
>
Considering compatibility,
static int last_map_symbol = -1;
+static int no_map_symbol_before = 0;
static bfd_vma last_stop_offset = 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;
>
If we cannot find any map_symbol for this section, then
`from_last_map_symbol' will always be false, so `n' should always be
`info->symtab_pos', so ...
> - 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;
>
moved this to ...
> }
>
> if (found)
>
if (found)
{
..
}
else
no_map_symbol_before = info->symtab_pos;
Thanks
Nelson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20240924/a3cc68f3/attachment-0001.htm>
More information about the Binutils
mailing list