@@ -9,14 +9,14 @@ use std::fmt;
9
9
use std:: hash:: Hash ;
10
10
use std:: marker:: PhantomData ;
11
11
12
+ use binaryninja:: architecture:: ArchitectureExt ;
12
13
use binaryninja:: relocation:: { Relocation , RelocationHandlerExt } ;
13
14
use binaryninja:: {
14
15
add_optional_plugin_dependency, architecture,
15
16
architecture:: {
16
- llvm_assemble, Architecture , ArchitectureExt , CoreArchitecture , CustomArchitectureHandle ,
17
- ImplicitRegisterExtend , InstructionInfo , LlvmServicesCodeModel , LlvmServicesDialect ,
18
- LlvmServicesRelocMode , Register as Reg , RegisterInfo , UnusedFlag , UnusedRegisterStack ,
19
- UnusedRegisterStackInfo ,
17
+ llvm_assemble, Architecture , CoreArchitecture , ImplicitRegisterExtend , InstructionInfo ,
18
+ LlvmServicesCodeModel , LlvmServicesDialect , LlvmServicesRelocMode , Register as Reg ,
19
+ RegisterInfo , UnusedFlag , UnusedRegisterStack , UnusedRegisterStackInfo ,
20
20
} ,
21
21
binaryview:: { BinaryView , BinaryViewExt } ,
22
22
callingconvention:: { register_calling_convention, CallingConventionBase , ConventionBuilder } ,
@@ -624,14 +624,11 @@ impl<D: RiscVDisassembler> architecture::Intrinsic for RiscVIntrinsic<D> {
624
624
}
625
625
626
626
struct RiscVArch < D : ' static + RiscVDisassembler + Send + Sync > {
627
- handle : CoreArchitecture ,
628
- custom_handle : CustomArchitectureHandle < RiscVArch < D > > ,
627
+ handle : & ' static CoreArchitecture ,
629
628
_dis : PhantomData < D > ,
630
629
}
631
630
632
631
impl < D : ' static + RiscVDisassembler + Send + Sync > architecture:: Architecture for RiscVArch < D > {
633
- type Handle = CustomArchitectureHandle < Self > ;
634
-
635
632
type RegisterInfo = Register < D > ;
636
633
type Register = Register < D > ;
637
634
type RegisterStackInfo = UnusedRegisterStackInfo < Self :: Register > ;
@@ -674,7 +671,7 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
674
671
self . max_instr_len ( )
675
672
}
676
673
677
- fn associated_arch_by_addr ( & self , _addr : & mut u64 ) -> CoreArchitecture {
674
+ fn associated_arch_by_addr ( & self , _addr : & mut u64 ) -> & ' static CoreArchitecture {
678
675
self . handle
679
676
}
680
677
@@ -977,29 +974,20 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
977
974
Text ,
978
975
) ) ;
979
976
} else {
980
- res. push ( InstructionTextToken :: new (
981
- "," ,
982
- OperandSeparator ,
983
- ) ) ;
977
+ res. push ( InstructionTextToken :: new ( "," , OperandSeparator ) ) ;
984
978
res. push ( InstructionTextToken :: new ( " " , Text ) ) ;
985
979
}
986
980
987
981
match * oper {
988
982
Operand :: R ( r) => {
989
983
let reg = self :: Register :: from ( r) ;
990
984
991
- res. push ( InstructionTextToken :: new (
992
- & reg. name ( ) ,
993
- Register ,
994
- ) ) ;
985
+ res. push ( InstructionTextToken :: new ( & reg. name ( ) , Register ) ) ;
995
986
}
996
987
Operand :: F ( r) => {
997
988
let reg = self :: Register :: from ( r) ;
998
989
999
- res. push ( InstructionTextToken :: new (
1000
- & reg. name ( ) ,
1001
- Register ,
1002
- ) ) ;
990
+ res. push ( InstructionTextToken :: new ( & reg. name ( ) , Register ) ) ;
1003
991
}
1004
992
Operand :: I ( i) => {
1005
993
match op {
@@ -1032,10 +1020,7 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
1032
1020
Operand :: M ( i, b) => {
1033
1021
let reg = self :: Register :: from ( b) ;
1034
1022
1035
- res. push ( InstructionTextToken :: new (
1036
- "" ,
1037
- BeginMemoryOperand ,
1038
- ) ) ;
1023
+ res. push ( InstructionTextToken :: new ( "" , BeginMemoryOperand ) ) ;
1039
1024
res. push ( InstructionTextToken :: new (
1040
1025
& if i < 0 {
1041
1026
format ! ( "-0x{:x}" , -i)
@@ -1046,15 +1031,9 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
1046
1031
) ) ;
1047
1032
1048
1033
res. push ( InstructionTextToken :: new ( "(" , Brace ) ) ;
1049
- res. push ( InstructionTextToken :: new (
1050
- & reg. name ( ) ,
1051
- Register ,
1052
- ) ) ;
1034
+ res. push ( InstructionTextToken :: new ( & reg. name ( ) , Register ) ) ;
1053
1035
res. push ( InstructionTextToken :: new ( ")" , Brace ) ) ;
1054
- res. push ( InstructionTextToken :: new (
1055
- "" ,
1056
- EndMemoryOperand ,
1057
- ) ) ;
1036
+ res. push ( InstructionTextToken :: new ( "" , EndMemoryOperand ) ) ;
1058
1037
}
1059
1038
Operand :: RM ( r) => {
1060
1039
res. push ( InstructionTextToken :: new ( r. name ( ) , Register ) ) ;
@@ -2140,8 +2119,8 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
2140
2119
true
2141
2120
}
2142
2121
2143
- fn handle ( & self ) -> CustomArchitectureHandle < Self > {
2144
- self . custom_handle
2122
+ fn core ( & self ) -> & ' static CoreArchitecture {
2123
+ self . handle
2145
2124
}
2146
2125
}
2147
2126
@@ -2869,22 +2848,18 @@ pub extern "C" fn CorePluginInit() -> bool {
2869
2848
binaryninja:: logger:: init ( log:: LevelFilter :: Trace ) . expect ( "Failed to set up logging" ) ;
2870
2849
2871
2850
use riscv_dis:: { RiscVIMACDisassembler , Rv32GRegs , Rv64GRegs } ;
2872
- let arch32 =
2873
- architecture:: register_architecture ( "rv32gc" , |custom_handle, core_arch| RiscVArch :: <
2874
- RiscVIMACDisassembler < Rv32GRegs > ,
2875
- > {
2876
- handle : core_arch,
2877
- custom_handle,
2878
- _dis : PhantomData ,
2879
- } ) ;
2880
- let arch64 =
2881
- architecture:: register_architecture ( "rv64gc" , |custom_handle, core_arch| RiscVArch :: <
2882
- RiscVIMACDisassembler < Rv64GRegs > ,
2883
- > {
2884
- handle : core_arch,
2885
- custom_handle,
2886
- _dis : PhantomData ,
2887
- } ) ;
2851
+ let arch32 = architecture:: register_architecture ( "rv32gc" , |core_arch| RiscVArch :: <
2852
+ RiscVIMACDisassembler < Rv32GRegs > ,
2853
+ > {
2854
+ handle : core_arch,
2855
+ _dis : PhantomData ,
2856
+ } ) ;
2857
+ let arch64 = architecture:: register_architecture ( "rv64gc" , |core_arch| RiscVArch :: <
2858
+ RiscVIMACDisassembler < Rv64GRegs > ,
2859
+ > {
2860
+ handle : core_arch,
2861
+ _dis : PhantomData ,
2862
+ } ) ;
2888
2863
2889
2864
arch32. register_relocation_handler ( "ELF" , |custom_handle, core_handler| {
2890
2865
RiscVELFRelocationHandler :: < RiscVIMACDisassembler < Rv32GRegs > > {
0 commit comments