@@ -10,7 +10,7 @@ use similar::{capture_diff_slices_deadline, Algorithm};
1010use crate :: {
1111 diff:: {
1212 editops:: { editops_find, LevEditType } ,
13- DiffAlg , ProcessCodeResult ,
13+ DiffAlg , DiffObjConfig , ProcessCodeResult ,
1414 } ,
1515 obj:: {
1616 mips, ppc, ObjArchitecture , ObjInfo , ObjInsArg , ObjInsArgDiff , ObjInsBranchFrom ,
@@ -49,7 +49,7 @@ pub fn no_diff_code(
4949
5050#[ allow( clippy:: too_many_arguments) ]
5151pub fn diff_code (
52- alg : DiffAlg ,
52+ config : & DiffObjConfig ,
5353 arch : ObjArchitecture ,
5454 left_data : & [ u8 ] ,
5555 right_data : & [ u8 ] ,
@@ -89,7 +89,7 @@ pub fn diff_code(
8989
9090 let mut left_diff = Vec :: < ObjInsDiff > :: new ( ) ;
9191 let mut right_diff = Vec :: < ObjInsDiff > :: new ( ) ;
92- match alg {
92+ match config . code_alg {
9393 DiffAlg :: Levenshtein => {
9494 diff_instructions_lev (
9595 & mut left_diff,
@@ -134,7 +134,7 @@ pub fn diff_code(
134134
135135 let mut diff_state = InsDiffState :: default ( ) ;
136136 for ( left, right) in left_diff. iter_mut ( ) . zip ( right_diff. iter_mut ( ) ) {
137- let result = compare_ins ( left, right, & mut diff_state) ?;
137+ let result = compare_ins ( config , left, right, & mut diff_state) ?;
138138 left. kind = result. kind ;
139139 right. kind = result. kind ;
140140 left. arg_diff = result. left_args_diff ;
@@ -322,13 +322,20 @@ fn address_eq(left: &ObjSymbol, right: &ObjSymbol) -> bool {
322322 left. address as i64 + left. addend == right. address as i64 + right. addend
323323}
324324
325- fn reloc_eq ( left_reloc : Option < & ObjReloc > , right_reloc : Option < & ObjReloc > ) -> bool {
325+ fn reloc_eq (
326+ config : & DiffObjConfig ,
327+ left_reloc : Option < & ObjReloc > ,
328+ right_reloc : Option < & ObjReloc > ,
329+ ) -> bool {
326330 let ( Some ( left) , Some ( right) ) = ( left_reloc, right_reloc) else {
327331 return false ;
328332 } ;
329333 if left. kind != right. kind {
330334 return false ;
331335 }
336+ if config. relax_reloc_diffs {
337+ return true ;
338+ }
332339
333340 let name_matches = left. target . name == right. target . name ;
334341 match ( & left. target_section , & right. target_section ) {
@@ -346,6 +353,7 @@ fn reloc_eq(left_reloc: Option<&ObjReloc>, right_reloc: Option<&ObjReloc>) -> bo
346353}
347354
348355fn arg_eq (
356+ config : & DiffObjConfig ,
349357 left : & ObjInsArg ,
350358 right : & ObjInsArg ,
351359 left_diff : & ObjInsDiff ,
@@ -359,13 +367,15 @@ fn arg_eq(
359367 ObjInsArg :: Reloc => {
360368 matches ! ( right, ObjInsArg :: Reloc )
361369 && reloc_eq (
370+ config,
362371 left_diff. ins . as_ref ( ) . and_then ( |i| i. reloc . as_ref ( ) ) ,
363372 right_diff. ins . as_ref ( ) . and_then ( |i| i. reloc . as_ref ( ) ) ,
364373 )
365374 }
366375 ObjInsArg :: RelocWithBase => {
367376 matches ! ( right, ObjInsArg :: RelocWithBase )
368377 && reloc_eq (
378+ config,
369379 left_diff. ins . as_ref ( ) . and_then ( |i| i. reloc . as_ref ( ) ) ,
370380 right_diff. ins . as_ref ( ) . and_then ( |i| i. reloc . as_ref ( ) ) ,
371381 )
@@ -398,6 +408,7 @@ struct InsDiffResult {
398408}
399409
400410fn compare_ins (
411+ config : & DiffObjConfig ,
401412 left : & ObjInsDiff ,
402413 right : & ObjInsDiff ,
403414 state : & mut InsDiffState ,
@@ -416,7 +427,7 @@ fn compare_ins(
416427 state. diff_count += 1 ;
417428 }
418429 for ( a, b) in left_ins. args . iter ( ) . zip ( & right_ins. args ) {
419- if arg_eq ( a, b, left, right) {
430+ if arg_eq ( config , a, b, left, right) {
420431 result. left_args_diff . push ( None ) ;
421432 result. right_args_diff . push ( None ) ;
422433 } else {
0 commit comments