@@ -52,7 +52,15 @@ inline static const char *ARMCondCodeToString(arm_cc cc) {
5252 return "al" ;
5353 }
5454}
55- #endif
55+ #else /* CS_NEXT_VERSION >= 6 */
56+ static inline bool is_alias64 (cs_insn * insn , aarch64_insn alias_id ) {
57+ return insn -> is_alias && (insn -> alias_id == alias_id );
58+ }
59+
60+ static inline bool is_alias32 (cs_insn * insn , arm_insn alias_id ) {
61+ return insn -> is_alias && (insn -> alias_id == alias_id );
62+ }
63+ #endif /* CS_NEXT_VERSION < 6 */
5664
5765typedef struct arm_cs_context_t {
5866 RzArmITContext it ; ///< Save IT values between instruction disassembly.
@@ -991,8 +999,43 @@ static void anop64(ArmCSContext *ctx, RzAnalysisOp *op, cs_insn *insn) {
991999 case CS_AARCH64 (_INS_CMN ):
9921000 case CS_AARCH64 (_INS_TST ):
9931001#endif
1002+ if (ISIMM64 (1 )) {
1003+ op -> val = IMM64 (1 );
1004+ }
9941005 op -> type = RZ_ANALYSIS_OP_TYPE_CMP ;
9951006 break ;
1007+ #if CS_NEXT_VERSION >= 6
1008+ case CS_AARCH64 (_INS_ADDS ):
1009+ if (is_alias64 (insn , AArch64_INS_ALIAS_CMN )) {
1010+ op -> type = RZ_ANALYSIS_OP_TYPE_CMP ;
1011+ } else {
1012+ op -> type = RZ_ANALYSIS_OP_TYPE_ADD ;
1013+ }
1014+ if (ISIMM64 (1 )) {
1015+ op -> val = IMM64 (1 );
1016+ }
1017+ break ;
1018+ case CS_AARCH64 (_INS_SUBS ):
1019+ if (is_alias64 (insn , AArch64_INS_ALIAS_CMP )) {
1020+ op -> type = RZ_ANALYSIS_OP_TYPE_CMP ;
1021+ } else {
1022+ op -> type = RZ_ANALYSIS_OP_TYPE_SUB ;
1023+ }
1024+ if (ISIMM64 (1 )) {
1025+ op -> val = IMM64 (1 );
1026+ }
1027+ break ;
1028+ case CS_AARCH64 (_INS_ANDS ):
1029+ if (is_alias64 (insn , AArch64_INS_ALIAS_TST )) {
1030+ op -> type = RZ_ANALYSIS_OP_TYPE_CMP ;
1031+ } else {
1032+ op -> type = RZ_ANALYSIS_OP_TYPE_AND ;
1033+ }
1034+ if (ISIMM64 (1 )) {
1035+ op -> val = IMM64 (1 );
1036+ }
1037+ break ;
1038+ #endif
9961039 case CS_AARCH64 (_INS_ROR ):
9971040 op -> cycles = 1 ;
9981041 op -> type = RZ_ANALYSIS_OP_TYPE_ROR ;
@@ -1175,8 +1218,13 @@ static void anop64(ArmCSContext *ctx, RzAnalysisOp *op, cs_insn *insn) {
11751218 op -> jump = IMM64 (0 );
11761219 }
11771220 break ;
1221+ #if CS_NEXT_VERSION >= 6
1222+ case CS_AARCH64 (_INS_UDF ):
1223+ op -> type = RZ_ANALYSIS_OP_TYPE_ILL ;
1224+ break ;
1225+ #endif
11781226 default :
1179- RZ_LOG_DEBUG ("ARM64 analysis: Op type %d at 0x%" PFMT64x " not handled\n" , insn -> id , op -> addr );
1227+ RZ_LOG_DEBUG ("ARM64 analysis: Op type %d (%s) at 0x%" PFMT64x " not handled\n" , insn -> id , insn -> mnemonic , op -> addr );
11801228 break ;
11811229 }
11821230}
@@ -1293,7 +1341,7 @@ jmp $$ + 4 + ( [delta] * 2 )
12931341 case ARM_INS_NOP :
12941342#else
12951343 case ARM_INS_HINT :
1296- if (insn -> alias_id != ARM_INS_ALIAS_NOP ) {
1344+ if (! is_alias32 ( insn , ARM_INS_ALIAS_NOP ) ) {
12971345 break ;
12981346 }
12991347#endif
@@ -1313,7 +1361,9 @@ jmp $$ + 4 + ( [delta] * 2 )
13131361 case ARM_INS_LDMIB :
13141362 case ARM_INS_LDM :
13151363#if CS_NEXT_VERSION >= 6
1316- if (insn -> alias_id == ARM_INS_ALIAS_POP || insn -> alias_id == ARM_INS_ALIAS_POPW || insn -> alias_id == ARM_INS_ALIAS_VPOP ) {
1364+ if (is_alias32 (insn , ARM_INS_ALIAS_POP ) ||
1365+ is_alias32 (insn , ARM_INS_ALIAS_POPW ) ||
1366+ is_alias32 (insn , ARM_INS_ALIAS_VPOP )) {
13171367 op -> type = RZ_ANALYSIS_OP_TYPE_POP ;
13181368 op -> stackop = RZ_ANALYSIS_STACK_DEC ;
13191369 op -> stackptr = -4LL * (insn -> detail -> arm .op_count - 1 );
@@ -1501,7 +1551,9 @@ jmp $$ + 4 + ( [delta] * 2 )
15011551 case ARM_INS_STMDA :
15021552 case ARM_INS_STMDB :
15031553#if CS_NEXT_VERSION >= 6
1504- if (insn -> alias_id == ARM_INS_ALIAS_PUSH || insn -> alias_id == ARM_INS_ALIAS_PUSHW || insn -> alias_id == ARM_INS_ALIAS_VPUSH ) {
1554+ if (is_alias32 (insn , ARM_INS_ALIAS_PUSH ) ||
1555+ is_alias32 (insn , ARM_INS_ALIAS_PUSHW ) ||
1556+ is_alias32 (insn , ARM_INS_ALIAS_VPUSH )) {
15051557 op -> type = RZ_ANALYSIS_OP_TYPE_PUSH ;
15061558 op -> stackop = RZ_ANALYSIS_STACK_INC ;
15071559 op -> stackptr = 4LL * (insn -> detail -> arm .op_count - 1 );
@@ -1534,7 +1586,8 @@ jmp $$ + 4 + ( [delta] * 2 )
15341586 case ARM_INS_STRT :
15351587 op -> cycles = 4 ;
15361588#if CS_NEXT_VERSION >= 6
1537- if (insn -> alias_id == ARM_INS_ALIAS_PUSH || insn -> alias_id == ARM_INS_ALIAS_PUSHW ) {
1589+ if (is_alias32 (insn , ARM_INS_ALIAS_PUSH ) ||
1590+ is_alias32 (insn , ARM_INS_ALIAS_PUSHW )) {
15381591 op -> type = RZ_ANALYSIS_OP_TYPE_PUSH ;
15391592 op -> stackop = RZ_ANALYSIS_STACK_INC ;
15401593 op -> stackptr = 4LL * (insn -> detail -> arm .op_count - 1 );
@@ -1572,7 +1625,8 @@ jmp $$ + 4 + ( [delta] * 2 )
15721625 case ARM_INS_LDRT :
15731626 op -> cycles = 4 ;
15741627#if CS_NEXT_VERSION >= 6
1575- if (insn -> alias_id == ARM_INS_ALIAS_POP || insn -> alias_id == ARM_INS_ALIAS_POPW ) {
1628+ if (is_alias32 (insn , ARM_INS_ALIAS_POP ) ||
1629+ is_alias32 (insn , ARM_INS_ALIAS_POPW )) {
15761630 op -> type = RZ_ANALYSIS_OP_TYPE_POP ;
15771631 op -> stackop = RZ_ANALYSIS_STACK_DEC ;
15781632 op -> stackptr = -4LL * (insn -> detail -> arm .op_count - 1 );
0 commit comments