@@ -37,7 +37,7 @@ use std::marker::PhantomData;
3737use binaryninja:: architecture:: { BranchKind , IntrinsicId , RegisterId } ;
3838use binaryninja:: confidence:: { Conf , MAX_CONFIDENCE , MIN_CONFIDENCE } ;
3939use binaryninja:: logger:: Logger ;
40- use binaryninja:: low_level_il:: expression:: { LowLevelILExpressionKind , ValueExpr } ;
40+ use binaryninja:: low_level_il:: expression:: { ExpressionKind , ValueExpr } ;
4141use binaryninja:: low_level_il:: instruction:: InstructionKind ;
4242use binaryninja:: low_level_il:: lifting:: {
4343 LiftableLowLevelIL , LiftableLowLevelILWithSize , LowLevelILLabel ,
@@ -2868,9 +2868,7 @@ impl FunctionRecognizer for RiscVELFPLTRecognizer {
28682868 let ( auipc_dest, plt_base) = match auipc {
28692869 InstructionKind :: SetReg ( r) => {
28702870 let value = match r. source_expr ( ) . kind ( ) {
2871- LowLevelILExpressionKind :: Const ( v) | LowLevelILExpressionKind :: ConstPtr ( v) => {
2872- v. value ( )
2873- }
2871+ ExpressionKind :: Const ( v) | ExpressionKind :: ConstPtr ( v) => v. value ( ) ,
28742872 _ => return false ,
28752873 } ;
28762874 ( r. dest_reg ( ) , value)
@@ -2882,43 +2880,28 @@ impl FunctionRecognizer for RiscVELFPLTRecognizer {
28822880 let load = next_llil_instr. next ( ) . unwrap ( ) . kind ( ) ;
28832881 let ( mut entry, mut target_reg) = match load {
28842882 InstructionKind :: SetReg ( r) => match r. source_expr ( ) . kind ( ) {
2885- LowLevelILExpressionKind :: Load ( l) => {
2883+ ExpressionKind :: Load ( l) => {
28862884 let target_reg = r. dest_reg ( ) ;
28872885 let entry = match l. source_mem_expr ( ) . kind ( ) {
2888- LowLevelILExpressionKind :: Reg ( lr) if lr. source_reg ( ) == auipc_dest => {
2889- plt_base
2890- }
2891- LowLevelILExpressionKind :: Add ( a) => {
2892- match ( a. left ( ) . kind ( ) , a. right ( ) . kind ( ) ) {
2893- (
2894- LowLevelILExpressionKind :: Reg ( a) ,
2895- LowLevelILExpressionKind :: Const ( b)
2896- | LowLevelILExpressionKind :: ConstPtr ( b) ,
2897- ) if a. source_reg ( ) == auipc_dest => {
2898- plt_base. wrapping_add ( b. value ( ) )
2899- }
2900- (
2901- LowLevelILExpressionKind :: Const ( b)
2902- | LowLevelILExpressionKind :: ConstPtr ( b) ,
2903- LowLevelILExpressionKind :: Reg ( a) ,
2904- ) if a. source_reg ( ) == auipc_dest => {
2905- plt_base. wrapping_add ( b. value ( ) )
2906- }
2907- _ => return false ,
2908- }
2909- }
2910- LowLevelILExpressionKind :: Sub ( a) => {
2911- match ( a. left ( ) . kind ( ) , a. right ( ) . kind ( ) ) {
2912- (
2913- LowLevelILExpressionKind :: Reg ( a) ,
2914- LowLevelILExpressionKind :: Const ( b)
2915- | LowLevelILExpressionKind :: ConstPtr ( b) ,
2916- ) if a. source_reg ( ) == auipc_dest => {
2917- plt_base. wrapping_sub ( b. value ( ) )
2918- }
2919- _ => return false ,
2920- }
2921- }
2886+ ExpressionKind :: Reg ( lr) if lr. source_reg ( ) == auipc_dest => plt_base,
2887+ ExpressionKind :: Add ( a) => match ( a. left ( ) . kind ( ) , a. right ( ) . kind ( ) ) {
2888+ (
2889+ ExpressionKind :: Reg ( a) ,
2890+ ExpressionKind :: Const ( b) | ExpressionKind :: ConstPtr ( b) ,
2891+ ) if a. source_reg ( ) == auipc_dest => plt_base. wrapping_add ( b. value ( ) ) ,
2892+ (
2893+ ExpressionKind :: Const ( b) | ExpressionKind :: ConstPtr ( b) ,
2894+ ExpressionKind :: Reg ( a) ,
2895+ ) if a. source_reg ( ) == auipc_dest => plt_base. wrapping_add ( b. value ( ) ) ,
2896+ _ => return false ,
2897+ } ,
2898+ ExpressionKind :: Sub ( a) => match ( a. left ( ) . kind ( ) , a. right ( ) . kind ( ) ) {
2899+ (
2900+ ExpressionKind :: Reg ( a) ,
2901+ ExpressionKind :: Const ( b) | ExpressionKind :: ConstPtr ( b) ,
2902+ ) if a. source_reg ( ) == auipc_dest => plt_base. wrapping_sub ( b. value ( ) ) ,
2903+ _ => return false ,
2904+ } ,
29222905 _ => return false ,
29232906 } ;
29242907 ( entry, target_reg)
@@ -2945,7 +2928,7 @@ impl FunctionRecognizer for RiscVELFPLTRecognizer {
29452928 match & temp_reg_inst {
29462929 InstructionKind :: SetReg ( r) if llil. instruction_count ( ) >= 5 => {
29472930 match r. source_expr ( ) . kind ( ) {
2948- LowLevelILExpressionKind :: Reg ( op) if target_reg == op. source_reg ( ) => {
2931+ ExpressionKind :: Reg ( op) if target_reg == op. source_reg ( ) => {
29492932 // Update the target_reg to the temp reg.
29502933 target_reg = r. dest_reg ( ) ;
29512934 temp_reg_inst = next_llil_instr. next ( ) . unwrap ( ) . kind ( )
@@ -2961,9 +2944,7 @@ impl FunctionRecognizer for RiscVELFPLTRecognizer {
29612944 let ( next_pc_dest, next_pc, cur_pc) = match next_pc_inst {
29622945 InstructionKind :: SetReg ( r) => {
29632946 let value = match r. source_expr ( ) . kind ( ) {
2964- LowLevelILExpressionKind :: Const ( v) | LowLevelILExpressionKind :: ConstPtr ( v) => {
2965- v. value ( )
2966- }
2947+ ExpressionKind :: Const ( v) | ExpressionKind :: ConstPtr ( v) => v. value ( ) ,
29672948 _ => return false ,
29682949 } ;
29692950 ( r. dest_reg ( ) , value, r. address ( ) )
@@ -2979,13 +2960,13 @@ impl FunctionRecognizer for RiscVELFPLTRecognizer {
29792960 match jump {
29802961 InstructionKind :: TailCall ( j) => {
29812962 match j. target ( ) . kind ( ) {
2982- LowLevelILExpressionKind :: Reg ( r) if r. source_reg ( ) == target_reg => ( ) ,
2963+ ExpressionKind :: Reg ( r) if r. source_reg ( ) == target_reg => ( ) ,
29832964 _ => return false ,
29842965 } ;
29852966 }
29862967 InstructionKind :: Jump ( j) => {
29872968 match j. target ( ) . kind ( ) {
2988- LowLevelILExpressionKind :: Reg ( r) if r. source_reg ( ) == target_reg => ( ) ,
2969+ ExpressionKind :: Reg ( r) if r. source_reg ( ) == target_reg => ( ) ,
29892970 _ => return false ,
29902971 } ;
29912972 }
0 commit comments