1- use std:: { borrow:: Cow , sync:: Mutex } ;
1+ use std:: { borrow:: Cow , collections :: BTreeMap , sync:: Mutex } ;
22
33use anyhow:: { anyhow, bail, Result } ;
44use object:: { elf, Endian , Endianness , File , FileFlags , Object , Relocation , RelocationFlags } ;
@@ -7,7 +7,7 @@ use rabbitizer::{config, Abi, InstrCategory, Instruction, OperandType};
77use crate :: {
88 arch:: { ObjArch , ProcessCodeResult } ,
99 diff:: { DiffObjConfig , MipsAbi , MipsInstrCategory } ,
10- obj:: { ObjInfo , ObjIns , ObjInsArg , ObjInsArgValue , ObjReloc , ObjSection , SymbolRef } ,
10+ obj:: { ObjIns , ObjInsArg , ObjInsArgValue , ObjReloc , ObjSection } ,
1111} ;
1212
1313static RABBITIZER_MUTEX : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
@@ -57,15 +57,12 @@ impl ObjArchMips {
5757impl ObjArch for ObjArchMips {
5858 fn process_code (
5959 & self ,
60- obj : & ObjInfo ,
61- symbol_ref : SymbolRef ,
60+ address : u64 ,
61+ code : & [ u8 ] ,
62+ relocations : & [ ObjReloc ] ,
63+ line_info : & BTreeMap < u64 , u64 > ,
6264 config : & DiffObjConfig ,
6365 ) -> Result < ProcessCodeResult > {
64- let ( section, symbol) = obj. section_symbol ( symbol_ref) ;
65- let section = section. ok_or_else ( || anyhow ! ( "Code symbol section not found" ) ) ?;
66- let code = & section. data
67- [ symbol. section_address as usize ..( symbol. section_address + symbol. size ) as usize ] ;
68-
6966 let _guard = RABBITIZER_MUTEX . lock ( ) . map_err ( |e| anyhow ! ( "Failed to lock mutex: {e}" ) ) ?;
7067 configure_rabbitizer ( match config. mips_abi {
7168 MipsAbi :: Auto => self . abi ,
@@ -82,14 +79,14 @@ impl ObjArch for ObjArchMips {
8279 MipsInstrCategory :: R5900 => InstrCategory :: R5900 ,
8380 } ;
8481
85- let start_address = symbol . address ;
86- let end_address = symbol . address + symbol . size ;
82+ let start_address = address;
83+ let end_address = address + code . len ( ) as u64 ;
8784 let ins_count = code. len ( ) / 4 ;
8885 let mut ops = Vec :: < u16 > :: with_capacity ( ins_count) ;
8986 let mut insts = Vec :: < ObjIns > :: with_capacity ( ins_count) ;
9087 let mut cur_addr = start_address as u32 ;
9188 for chunk in code. chunks_exact ( 4 ) {
92- let reloc = section . relocations . iter ( ) . find ( |r| ( r. address as u32 & !3 ) == cur_addr) ;
89+ let reloc = relocations. iter ( ) . find ( |r| ( r. address as u32 & !3 ) == cur_addr) ;
9390 let code = self . endianness . read_u32_bytes ( chunk. try_into ( ) ?) ;
9491 let instruction = Instruction :: new ( code, cur_addr, instr_category) ;
9592
@@ -155,7 +152,7 @@ impl ObjArch for ObjArchMips {
155152 }
156153 }
157154 }
158- let line = section . line_info . range ( ..=cur_addr as u64 ) . last ( ) . map ( |( _, & b) | b) ;
155+ let line = line_info. range ( ..=cur_addr as u64 ) . last ( ) . map ( |( _, & b) | b) ;
159156 insts. push ( ObjIns {
160157 address : cur_addr as u64 ,
161158 size : 4 ,
0 commit comments