1
- use std:: { borrow:: Cow , collections:: HashMap } ;
1
+ use std:: {
2
+ borrow:: Cow ,
3
+ collections:: { BTreeMap , HashMap } ,
4
+ } ;
2
5
3
- use anyhow:: { anyhow , bail, Result } ;
6
+ use anyhow:: { bail, Result } ;
4
7
use object:: {
5
8
elf, File , Object , ObjectSection , ObjectSymbol , Relocation , RelocationFlags , SectionIndex ,
6
9
SectionKind , Symbol ,
@@ -14,7 +17,7 @@ use unarm::{
14
17
use crate :: {
15
18
arch:: { ObjArch , ProcessCodeResult } ,
16
19
diff:: DiffObjConfig ,
17
- obj:: { ObjInfo , ObjIns , ObjInsArg , ObjInsArgValue , ObjSection , SymbolRef } ,
20
+ obj:: { ObjIns , ObjInsArg , ObjInsArgValue , ObjReloc , ObjSection } ,
18
21
} ;
19
22
20
23
pub struct ObjArchArm {
@@ -50,28 +53,25 @@ impl ObjArchArm {
50
53
impl ObjArch for ObjArchArm {
51
54
fn process_code (
52
55
& self ,
53
- obj : & ObjInfo ,
54
- symbol_ref : SymbolRef ,
56
+ address : u64 ,
57
+ code : & [ u8 ] ,
58
+ section_index : usize ,
59
+ relocations : & [ ObjReloc ] ,
60
+ line_info : & BTreeMap < u64 , u64 > ,
55
61
config : & DiffObjConfig ,
56
62
) -> Result < ProcessCodeResult > {
57
- let ( section, symbol) = obj. section_symbol ( symbol_ref) ;
58
- let section = section. ok_or_else ( || anyhow ! ( "Code symbol section not found" ) ) ?;
59
- let code = & section. data
60
- [ symbol. section_address as usize ..( symbol. section_address + symbol. size ) as usize ] ;
61
-
62
- let start_addr = symbol. address as u32 ;
63
- let end_addr = start_addr + symbol. size as u32 ;
63
+ let start_addr = address as u32 ;
64
+ let end_addr = start_addr + code. len ( ) as u32 ;
64
65
65
66
// Mapping symbols decide what kind of data comes after it. $a for ARM code, $t for Thumb code and $d for data.
66
- let fallback_mappings =
67
- [ DisasmMode { address : symbol. address as u32 , mapping : ParseMode :: Arm } ] ;
67
+ let fallback_mappings = [ DisasmMode { address : start_addr, mapping : ParseMode :: Arm } ] ;
68
68
let mapping_symbols = self
69
69
. disasm_modes
70
- . get ( & SectionIndex ( section . orig_index ) )
70
+ . get ( & SectionIndex ( section_index ) )
71
71
. map ( |x| x. as_slice ( ) )
72
72
. unwrap_or ( & fallback_mappings) ;
73
73
let first_mapping_idx =
74
- match mapping_symbols. binary_search_by_key ( & ( symbol . address as u32 ) , |x| x. address ) {
74
+ match mapping_symbols. binary_search_by_key ( & start_addr , |x| x. address ) {
75
75
Ok ( idx) => idx,
76
76
Err ( idx) => idx - 1 ,
77
77
} ;
@@ -96,10 +96,9 @@ impl ObjArch for ObjArchArm {
96
96
}
97
97
}
98
98
99
- let line = section . line_info . range ( ..=address as u64 ) . last ( ) . map ( |( _, & b) | b) ;
99
+ let line = line_info. range ( ..=address as u64 ) . last ( ) . map ( |( _, & b) | b) ;
100
100
101
- let reloc =
102
- section. relocations . iter ( ) . find ( |r| ( r. address as u32 & !1 ) == address) . cloned ( ) ;
101
+ let reloc = relocations. iter ( ) . find ( |r| ( r. address as u32 & !1 ) == address) . cloned ( ) ;
103
102
104
103
let mut reloc_arg = None ;
105
104
if let Some ( reloc) = & reloc {
0 commit comments