1
- use std:: { borrow:: Cow , sync:: Mutex } ;
1
+ use std:: { borrow:: Cow , collections :: BTreeMap , sync:: Mutex } ;
2
2
3
3
use anyhow:: { anyhow, bail, Result } ;
4
4
use object:: { elf, Endian , Endianness , File , FileFlags , Object , Relocation , RelocationFlags } ;
@@ -7,7 +7,7 @@ use rabbitizer::{config, Abi, InstrCategory, Instruction, OperandType};
7
7
use crate :: {
8
8
arch:: { ObjArch , ProcessCodeResult } ,
9
9
diff:: { DiffObjConfig , MipsAbi , MipsInstrCategory } ,
10
- obj:: { ObjInfo , ObjIns , ObjInsArg , ObjInsArgValue , ObjReloc , ObjSection , SymbolRef } ,
10
+ obj:: { ObjIns , ObjInsArg , ObjInsArgValue , ObjReloc , ObjSection } ,
11
11
} ;
12
12
13
13
static RABBITIZER_MUTEX : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
@@ -57,15 +57,12 @@ impl ObjArchMips {
57
57
impl ObjArch for ObjArchMips {
58
58
fn process_code (
59
59
& self ,
60
- obj : & ObjInfo ,
61
- symbol_ref : SymbolRef ,
60
+ address : u64 ,
61
+ code : & [ u8 ] ,
62
+ relocations : & [ ObjReloc ] ,
63
+ line_info : & BTreeMap < u64 , u64 > ,
62
64
config : & DiffObjConfig ,
63
65
) -> 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
-
69
66
let _guard = RABBITIZER_MUTEX . lock ( ) . map_err ( |e| anyhow ! ( "Failed to lock mutex: {e}" ) ) ?;
70
67
configure_rabbitizer ( match config. mips_abi {
71
68
MipsAbi :: Auto => self . abi ,
@@ -82,14 +79,14 @@ impl ObjArch for ObjArchMips {
82
79
MipsInstrCategory :: R5900 => InstrCategory :: R5900 ,
83
80
} ;
84
81
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 ;
87
84
let ins_count = code. len ( ) / 4 ;
88
85
let mut ops = Vec :: < u16 > :: with_capacity ( ins_count) ;
89
86
let mut insts = Vec :: < ObjIns > :: with_capacity ( ins_count) ;
90
87
let mut cur_addr = start_address as u32 ;
91
88
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) ;
93
90
let code = self . endianness . read_u32_bytes ( chunk. try_into ( ) ?) ;
94
91
let instruction = Instruction :: new ( code, cur_addr, instr_category) ;
95
92
@@ -155,7 +152,7 @@ impl ObjArch for ObjArchMips {
155
152
}
156
153
}
157
154
}
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) ;
159
156
insts. push ( ObjIns {
160
157
address : cur_addr as u64 ,
161
158
size : 4 ,
0 commit comments