Skip to content

Commit 3d6fcbc

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 6921cd1 commit 3d6fcbc

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
@@ -1198,18 +1198,16 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
11981198

11991199
/* Decide whether to print the data or instruction by default, in case
12001200
we can not find the corresponding mapping symbols. */
1201-
mstate = MAP_DATA;
1202-
if ((info->section
1203-
&& info->section->flags & SEC_CODE)
1204-
|| !info->section)
1205-
mstate = MAP_INSN;
1201+
mstate = MAP_INSN;
1202+
if (info->section && (info->section->flags & SEC_CODE) == 0)
1203+
mstate = MAP_DATA;
12061204

12071205
if (info->symtab_size == 0
12081206
|| bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour)
12091207
return mstate;
12101208

1211-
/* Reset the last_map_symbol if we start to dump a new section. */
1212-
if (memaddr <= 0)
1209+
/* Reset the last_map_symbol if the address is zero. */
1210+
if (memaddr == 0)
12131211
last_map_symbol = -1;
12141212

12151213
/* If the last stop offset is different from the current one, then
@@ -1261,7 +1259,6 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
12611259
if (riscv_get_map_state (n, &mstate, info, true))
12621260
{
12631261
symbol = n;
1264-
found = true;
12651262
break;
12661263
}
12671264
}

0 commit comments

Comments
 (0)