Skip to content

Commit 0b977cf

Browse files
committed
RISC-V: Per-section private data initialization
This is one more preparation for mapping symbol optimization. It adds a separate function that is called when the section to disassemble is changed. This commit enables tracking per-section state management required for the next optimization ("RISC-V: Optimized search on mapping symbols"). opcodes/ChangeLog: * riscv-dis.c (struct riscv_private_data): Add last_section. (init_riscv_dis_private_data): Initialize last_section. (init_riscv_dis_private_data_for_section): New function. update last_section here. (print_insn_riscv): Track section changes.
1 parent 43297a5 commit 0b977cf

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

opcodes/riscv-dis.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct riscv_private_data
8989
bfd_vma gp;
9090
bfd_vma print_addr;
9191
bfd_vma hi_addr[NGPR];
92+
void* last_section;
9293
bool to_print_addr;
9394
bool has_gp;
9495
};
@@ -264,6 +265,7 @@ init_riscv_dis_private_data (struct disassemble_info *info)
264265
pd->print_addr = 0;
265266
for (int i = 0; i < (int)ARRAY_SIZE (pd->hi_addr); i++)
266267
pd->hi_addr[i] = -1;
268+
pd->last_section = NULL;
267269
pd->to_print_addr = false;
268270
pd->has_gp = false;
269271

@@ -275,6 +277,15 @@ init_riscv_dis_private_data (struct disassemble_info *info)
275277
}
276278
}
277279

280+
/* Initialize private data when the section to disassemble is changed. */
281+
282+
static void
283+
init_riscv_dis_private_data_for_section (struct disassemble_info *info)
284+
{
285+
struct riscv_private_data *pd = info->private_data;
286+
pd->last_section = info->section;
287+
}
288+
278289
/* Update architecture for disassembler with its context.
279290
Call initialization functions if either:
280291
- the architecture for current context is changed or
@@ -1416,7 +1427,13 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
14161427

14171428
/* Initialize the private data. */
14181429
if (info->private_data == NULL)
1419-
init_riscv_dis_private_data (info);
1430+
{
1431+
init_riscv_dis_private_data (info);
1432+
init_riscv_dis_private_data_for_section (info);
1433+
}
1434+
struct riscv_private_data *pd = info->private_data;
1435+
if (info->section != pd->last_section)
1436+
init_riscv_dis_private_data_for_section (info);
14201437

14211438
/* Guess and update XLEN if we haven't determined it yet. */
14221439
if (xlen == 0)

0 commit comments

Comments
 (0)