[1/3] RISC-V: Easy optimization on riscv_search_mapping_symbol
Checks
Commit Message
From: Tsukasa OI <research_trasio@irq.a4lg.com>
Before further optimization, we can optimize the function
riscv_search_mapping_symbol a bit for clarity.
opcodes/ChangeLog:
* riscv-dis.c (riscv_search_mapping_symbol): Make MAP_INSN default
considering major usecases. Remove setting found here as no one
uses the value after setting this. memaddr cannot be negative
so simplify and change comment.
Idea-by: Nelson Chu <nelson@rivosinc.com>
---
opcodes/riscv-dis.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
@@ -1132,18 +1132,16 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
/* Decide whether to print the data or instruction by default, in case
we can not find the corresponding mapping symbols. */
- mstate = MAP_DATA;
- if ((info->section
- && info->section->flags & SEC_CODE)
- || !info->section)
- mstate = MAP_INSN;
+ mstate = MAP_INSN;
+ if (info->section && (info->section->flags & SEC_CODE) == 0)
+ mstate = MAP_DATA;
if (info->symtab_size == 0
|| bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour)
return mstate;
- /* Reset the last_map_symbol if we start to dump a new section. */
- if (memaddr <= 0)
+ /* Reset the last_map_symbol if the address is zero. */
+ if (memaddr == 0)
last_map_symbol = -1;
/* If the last stop offset is different from the current one, then
@@ -1195,7 +1193,6 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
if (riscv_get_map_state (n, &mstate, info, true))
{
symbol = n;
- found = true;
break;
}
}