Skip to content

Commit

Permalink
Move jumps always to end of packet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Mar 16, 2024
1 parent 76814f9 commit f88134a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
14 changes: 1 addition & 13 deletions handwritten/hexagon_il_X_ops_c/non_insn_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,5 @@ RZ_IPI RZ_OWN RzILOpEffect *hex_il_op_jump_flag_init(HexInsnPktBundle *bundle) {
}

RZ_IPI RZ_OWN RzILOpEffect *hex_il_op_next_pkt_jmp(HexInsnPktBundle *bundle) {
bool has_direct_jump = false;
void **it;
rz_pvector_foreach (bundle->pkt->il_ops, it) {
HexILOp *op = *it;
if (op->attr & HEX_IL_INSN_ATTR_BRANCH && !(op->attr & HEX_IL_INSN_ATTR_COND)) {
has_direct_jump = true;
}
}
if (!has_direct_jump) {
// Append the jump to the adjacent packet.
return BRANCH(VARL("jump_flag"), EMPTY(), JMP(U32(bundle->pkt->pkt_addr + (HEX_INSN_SIZE * rz_list_length(bundle->pkt->bin)))));
}
return EMPTY();
return BRANCH(VARL("jump_flag"), JMP(VARL("jump_target")), JMP(U32(bundle->pkt->pkt_addr + (HEX_INSN_SIZE * rz_list_length(bundle->pkt->bin)))));
}
5 changes: 3 additions & 2 deletions handwritten/hexagon_il_c/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,10 @@ RZ_IPI RzILOpEffect *hex_get_il_op(const ut32 addr, const bool get_pkt_op) {
rz_pvector_push(p->il_ops, &hex_endloop01_op);
}

// Add a jump to the next packet.
rz_pvector_push(p->il_ops, &hex_next_jump_to_next_pkt);
rz_pvector_push(p->il_ops, &hex_pkt_commit);
// Add a jump to the next packet. This always has to come last.
rz_pvector_push(p->il_ops, &hex_next_jump_to_next_pkt);


check_for_jumps(p, &might_has_jumped);

Expand Down
2 changes: 1 addition & 1 deletion rzil_compiler

0 comments on commit f88134a

Please sign in to comment.