Skip to content

Commit 55a36e2

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 88793c2 commit 55a36e2

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
};
@@ -245,6 +246,7 @@ init_riscv_dis_private_data (struct disassemble_info *info)
245246
pd->print_addr = 0;
246247
for (int i = 0; i < (int)ARRAY_SIZE (pd->hi_addr); i++)
247248
pd->hi_addr[i] = -1;
249+
pd->last_section = NULL;
248250
pd->to_print_addr = false;
249251
pd->has_gp = false;
250252

@@ -256,6 +258,15 @@ init_riscv_dis_private_data (struct disassemble_info *info)
256258
}
257259
}
258260

261+
/* Initialize private data when the section to disassemble is changed. */
262+
263+
static void
264+
init_riscv_dis_private_data_for_section (struct disassemble_info *info)
265+
{
266+
struct riscv_private_data *pd = info->private_data;
267+
pd->last_section = info->section;
268+
}
269+
259270
/* Update architecture for disassembler with its context.
260271
Call initialization functions if either:
261272
- the architecture for current context is changed or
@@ -1308,7 +1319,13 @@ print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info)
13081319

13091320
/* Initialize the private data. */
13101321
if (info->private_data == NULL)
1311-
init_riscv_dis_private_data (info);
1322+
{
1323+
init_riscv_dis_private_data (info);
1324+
init_riscv_dis_private_data_for_section (info);
1325+
}
1326+
struct riscv_private_data *pd = info->private_data;
1327+
if (info->section != pd->last_section)
1328+
init_riscv_dis_private_data_for_section (info);
13121329

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

0 commit comments

Comments
 (0)