Skip to content

Commit 7bcaa4b

Browse files
committed
RISC-V: Easy optimization on riscv_search_mapping_symbol
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 <[email protected]>
1 parent f3378df commit 7bcaa4b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

opcodes/riscv-dis.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,18 +1132,16 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
11321132

11331133
/* Decide whether to print the data or instruction by default, in case
11341134
we can not find the corresponding mapping symbols. */
1135-
mstate = MAP_DATA;
1136-
if ((info->section
1137-
&& info->section->flags & SEC_CODE)
1138-
|| !info->section)
1139-
mstate = MAP_INSN;
1135+
mstate = MAP_INSN;
1136+
if (info->section && (info->section->flags & SEC_CODE) == 0)
1137+
mstate = MAP_DATA;
11401138

11411139
if (info->symtab_size == 0
11421140
|| bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour)
11431141
return mstate;
11441142

1145-
/* Reset the last_map_symbol if we start to dump a new section. */
1146-
if (memaddr <= 0)
1143+
/* Reset the last_map_symbol if the address is zero. */
1144+
if (memaddr == 0)
11471145
last_map_symbol = -1;
11481146

11491147
/* If the last stop offset is different from the current one, then
@@ -1195,7 +1193,6 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
11951193
if (riscv_get_map_state (n, &mstate, info, true))
11961194
{
11971195
symbol = n;
1198-
found = true;
11991196
break;
12001197
}
12011198
}

0 commit comments

Comments
 (0)