Skip to content

Commit

Permalink
Check for all float extensions for vabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Oct 22, 2023
1 parent 11acb50 commit 13742eb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions librz/analysis/arch/arm/arm_cs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RZ_IPI int rz_arm_cs_analysis_op_32_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 a
RZ_IPI int rz_arm_cs_analysis_op_64_esil(RzAnalysis *a, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn);

RZ_IPI bool rz_arm_cs_is_group_member(RZ_NONNULL const cs_insn *insn, arm_insn_group feature);
RZ_IPI bool rz_arm_cs_is_float_insn(const cs_insn *insn);

#if CS_NEXT_VERSION >= 6
RZ_IPI const char *rz_arm32_cs_esil_prefix_cond(RzAnalysisOp *op, ARMCC_CondCodes cond_type);
Expand Down
31 changes: 30 additions & 1 deletion librz/analysis/arch/arm/arm_il32.c
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,35 @@ static inline ut32 cvt_isize(arm_vectordata_type type, bool *is_signed) {
}
}

/**
* \brief Tests if the instruction is part of a float supporting
* group (NEON, VFP MVEFloat...).
*
* \param insn The instruction to test.
* \return true The instruction is a float instruction.
* \return false The instruction is not a float instruction.
*/
RZ_IPI bool rz_arm_cs_is_float_insn(const cs_insn *insn) {
rz_return_val_if_fail(insn && insn->detail, false);
uint32_t i = 0;
arm_insn_group group_it = insn->detail->groups[i];
while (group_it) {
switch (group_it) {
default:
break;
case ARM_FEATURE_HasNEON:
case ARM_FEATURE_HasVFP2:
case ARM_FEATURE_HasVFP3:
case ARM_FEATURE_HasVFP4:
case ARM_FEATURE_HasDPVFP:
case ARM_FEATURE_HasMVEFloat:
return true;
}
group_it = insn->detail->groups[++i];
}
return false;
}

static RzILOpEffect *try_as_int_cvt(cs_insn *insn, bool is_thumb, bool *success) {
bool is_f2i = false;
bool is_signed = false;
Expand Down Expand Up @@ -4015,7 +4044,7 @@ static RzILOpEffect *vabs(cs_insn *insn, bool is_thumb) {
}

#if CS_NEXT_VERSION >= 6
if (!rz_arm_cs_is_group_member(insn, ARM_FEATURE_HasNEON)) {
if (!rz_arm_cs_is_float_insn(insn)) {
#else
if (!rz_arm_cs_is_group_member(insn, ARM_GRP_NEON)) {
#endif
Expand Down

0 comments on commit 13742eb

Please sign in to comment.