Skip to content

Commit

Permalink
Fix shuffling and setup of jump_target
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Mar 22, 2024
1 parent 0fcead0 commit aa40433
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion librz/arch/isa/hexagon/hexagon.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,4 +841,4 @@ RZ_API const HexOp hex_alias_to_op(HexRegAlias alias, bool tmp_reg);
RZ_API const char *hex_alias_to_reg_name(HexRegAlias alias, bool tmp_reg);
RZ_API const HexOp hex_explicit_to_op(ut32 reg_num, HexRegClass reg_class, bool tmp_reg);

#endif
#endif
13 changes: 7 additions & 6 deletions librz/arch/isa/hexagon/hexagon_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,17 @@ static HexILOp hex_endloop01_op = {
/**
* \brief Sends the IL op at \p start to the position \p newloc.
*
* Note: THis is a copy of the same function implemented by Qualcomm in QEMU.
* Note: This is a copy of the same function implemented by Qualcomm in QEMU.
* See: https://gitlab.com/qemu-project/qemu/-/blob/master/target/hexagon/decode.c :: decode_send_insn_to
*
* \param ops The IL ops list.
* \param start Index of the op to move.
* \param newloc Position the op shall be moved to.
*/
static void hex_send_insn_to_i(RzPVector /*<HexILOp *>*/ *ops, ut8 start, ut8 newloc) {
rz_return_if_fail(ops);
rz_return_if_fail(ops && newloc < rz_pvector_len(ops));

st32 direction;
st32 i;
if (start == newloc) {
return;
}
Expand All @@ -75,9 +74,11 @@ static void hex_send_insn_to_i(RzPVector /*<HexILOp *>*/ *ops, ut8 start, ut8 ne
/* move towards beginning */
direction = -1;
}
for (i = start; i != newloc; i += direction) {
HexILOp *tmp_op = rz_pvector_assign_at(ops, i, (HexILOp *)rz_pvector_at(ops, i + direction));
rz_pvector_assign_at(ops, i + direction, tmp_op);
for (st32 i = start; i != newloc; i += direction) {
HexILOp *neighbor_op = (HexILOp *)rz_pvector_at(ops, i + direction);
HexILOp *to_move_op = (HexILOp *)rz_pvector_at(ops, i);
rz_pvector_set(ops, i, neighbor_op);
rz_pvector_set(ops, i + direction, to_move_op);
}
}

Expand Down
2 changes: 1 addition & 1 deletion librz/arch/isa/hexagon/il_ops/hexagon_il_non_insn_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ RZ_IPI RZ_OWN RzILOpEffect *hex_commit_packet(HexInsnPktBundle *bundle) {
}

RZ_IPI RZ_OWN RzILOpEffect *hex_il_op_jump_flag_init(HexInsnPktBundle *bundle) {
return SETL("jump_flag", IL_FALSE);
return SEQ2(SETL("jump_flag", IL_FALSE), SETL("jump_target", U32(0xffffffff)));
}

RZ_IPI RZ_OWN RzILOpEffect *hex_il_op_next_pkt_jmp(HexInsnPktBundle *bundle) {
Expand Down

0 comments on commit aa40433

Please sign in to comment.