@@ -123,6 +123,12 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext)
123
123
return ctx -> misa_ext & ext ;
124
124
}
125
125
126
+ //// --- Begin LibAFL code ---
127
+
128
+ void libafl_gen_cmp (target_ulong pc , TCGv op0 , TCGv op1 , MemOp ot );
129
+
130
+ //// --- End LibAFL code ---
131
+
126
132
#ifdef TARGET_RISCV32
127
133
#define get_xl (ctx ) MXL_RV32
128
134
#elif defined(CONFIG_USER_ONLY )
@@ -867,6 +873,13 @@ static bool gen_arith_imm_fn(DisasContext *ctx, arg_i *a, DisasExtend ext,
867
873
return true;
868
874
}
869
875
876
+ //// --- Begin LibAFL code ---
877
+
878
+ static void gen_slt (TCGv ret , TCGv s1 , TCGv s2 );
879
+ static void gen_sltu (TCGv ret , TCGv s1 , TCGv s2 );
880
+
881
+ //// --- End LibAFL code ---
882
+
870
883
static bool gen_arith_imm_tl (DisasContext * ctx , arg_i * a , DisasExtend ext ,
871
884
void (* func )(TCGv , TCGv , TCGv ),
872
885
void (* f128 )(TCGv , TCGv , TCGv , TCGv , TCGv , TCGv ))
@@ -876,6 +889,16 @@ static bool gen_arith_imm_tl(DisasContext *ctx, arg_i *a, DisasExtend ext,
876
889
TCGv src2 = tcg_constant_tl (a -> imm );
877
890
878
891
if (get_ol (ctx ) < MXL_RV128 ) {
892
+
893
+ //// --- Begin LibAFL code ---
894
+
895
+ if (func == gen_slt || func == gen_sltu ) {
896
+ MemOp memop = get_ol (ctx ) == MXL_RV32 ? MO_32 : MO_64 ;
897
+ libafl_gen_cmp (ctx -> base .pc_next , src1 , src2 , memop );
898
+ }
899
+
900
+ //// --- End LibAFL code ---
901
+
879
902
func (dest , src1 , src2 );
880
903
gen_set_gpr (ctx , a -> rd , dest );
881
904
} else {
@@ -902,6 +925,16 @@ static bool gen_arith(DisasContext *ctx, arg_r *a, DisasExtend ext,
902
925
TCGv src2 = get_gpr (ctx , a -> rs2 , ext );
903
926
904
927
if (get_ol (ctx ) < MXL_RV128 ) {
928
+
929
+ //// --- Begin LibAFL code ---
930
+
931
+ if (func == gen_slt || func == gen_sltu ) {
932
+ MemOp memop = get_ol (ctx ) == MXL_RV32 ? MO_32 : MO_64 ;
933
+ libafl_gen_cmp (ctx -> base .pc_next , src1 , src2 , memop );
934
+ }
935
+
936
+ //// --- End LibAFL code ---
937
+
905
938
func (dest , src1 , src2 );
906
939
gen_set_gpr (ctx , a -> rd , dest );
907
940
} else {
0 commit comments