Skip to content

Commit 685d976

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 4be4b36 commit 685d976

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
};
@@ -259,6 +260,7 @@ init_riscv_dis_private_data (struct disassemble_info *info)
259260
pd->print_addr = 0;
260261
for (int i = 0; i < (int)ARRAY_SIZE (pd->hi_addr); i++)
261262
pd->hi_addr[i] = -1;
263+
pd->last_section = NULL;
262264
pd->to_print_addr = false;
263265
pd->has_gp = false;
264266

@@ -270,6 +272,15 @@ init_riscv_dis_private_data (struct disassemble_info *info)
270272
}
271273
}
272274

275+
/* Initialize private data when the section to disassemble is changed. */
276+
277+
static void
278+
init_riscv_dis_private_data_for_section (struct disassemble_info *info)
279+
{
280+
struct riscv_private_data *pd = info->private_data;
281+
pd->last_section = info->section;
282+
}
283+
273284
/* Update architecture for disassembler with its context.
274285
Call initialization functions if either:
275286
- the architecture for current context is changed or
@@ -1411,7 +1422,13 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
14111422

14121423
/* Initialize the private data. */
14131424
if (info->private_data == NULL)
1414-
init_riscv_dis_private_data (info);
1425+
{
1426+
init_riscv_dis_private_data (info);
1427+
init_riscv_dis_private_data_for_section (info);
1428+
}
1429+
struct riscv_private_data *pd = info->private_data;
1430+
if (info->section != pd->last_section)
1431+
init_riscv_dis_private_data_for_section (info);
14151432

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

0 commit comments

Comments
 (0)