Skip to content

Commit 4be4b36

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 37af5cd commit 4be4b36

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

12041204
/* Decide whether to print the data or instruction by default, in case
12051205
we can not find the corresponding mapping symbols. */
1206-
mstate = MAP_DATA;
1207-
if ((info->section
1208-
&& info->section->flags & SEC_CODE)
1209-
|| !info->section)
1210-
mstate = MAP_INSN;
1206+
mstate = MAP_INSN;
1207+
if (info->section && (info->section->flags & SEC_CODE) == 0)
1208+
mstate = MAP_DATA;
12111209

12121210
if (info->symtab_size == 0
12131211
|| bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour)
12141212
return mstate;
12151213

1216-
/* Reset the last_map_symbol if we start to dump a new section. */
1217-
if (memaddr <= 0)
1214+
/* Reset the last_map_symbol if the address is zero. */
1215+
if (memaddr == 0)
12181216
last_map_symbol = -1;
12191217

12201218
/* If the last stop offset is different from the current one, then
@@ -1266,7 +1264,6 @@ riscv_search_mapping_symbol (bfd_vma memaddr,
12661264
if (riscv_get_map_state (n, &mstate, info, true))
12671265
{
12681266
symbol = n;
1269-
found = true;
12701267
break;
12711268
}
12721269
}

0 commit comments

Comments
 (0)