Skip to content

Commit

Permalink
Add slot to HexInsn (needed for RzIL)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Sep 15, 2023
1 parent 408de4c commit f217ec1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions librz/asm/arch/hexagon/hexagon.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ typedef struct {
char text_infix[128]; ///< Textual disassembly of the instruction.
HexOp ops[HEX_MAX_OPERANDS]; ///< The operands of the instructions.
HexILInsn il_insn; ///< RZIL instruction. These are not meant for execution! Use the packet ops for that.
ut8 slot; ///< The slot the instruction is located.
} HexInsn;

/**
Expand Down
39 changes: 30 additions & 9 deletions librz/asm/arch/hexagon/hexagon_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,35 @@ RZ_API HexLoopAttr hex_get_loop_flag(const HexPkt *p) {
}
}

/**
* \brief Sets the given packet to valid and updates the packet information of
* each instruction in it.
*
* \param state The to operate on.
* \param pkt The packet to set to valid.
*/
static void make_packet_valid(RZ_BORROW HexState *state, RZ_BORROW HexPkt *pkt) {
rz_return_if_fail(state && pkt);
pkt->is_valid = true;
HexInsnContainer *hi = NULL;
RzListIter *it = NULL;
ut8 i = 0;
ut8 slot = 0;
rz_list_foreach (pkt->bin, it, hi) {
hex_set_pkt_info(&state->rz_asm, hi, pkt, i, true);
if (hi->is_duplex) {
hi->bin.sub[0]->slot = 0;
hi->bin.sub[1]->slot = 1;
slot = 2;
} else {
hi->bin.insn->slot = slot;
++slot;
}
++i;
}
pkt->last_access = rz_time_now();
}

/**
* \brief Sets the packet after \p pkt to valid and updates its textual assembly.
*
Expand All @@ -587,15 +616,7 @@ static void make_next_packet_valid(HexState *state, const HexPkt *pkt) {
if (p->is_valid) {
break;
}
p->is_valid = true;
HexInsnContainer *hi = NULL;
RzListIter *it = NULL;
ut8 slot = 0;
rz_list_foreach (p->bin, it, hi) {
hex_set_pkt_info(&state->rz_asm, hi, p, slot, true);
++slot;
}
p->last_access = rz_time_now();
make_packet_valid(state, p);
break;
}
}
Expand Down

0 comments on commit f217ec1

Please sign in to comment.