@@ -14,3 +14,26 @@ fn read_mips() {
1414 let output = common:: display_diff ( & obj, & diff, symbol_idx, & diff_config) ;
1515 insta:: assert_snapshot!( output) ;
1616}
17+
18+ #[ test]
19+ #[ cfg( feature = "mips" ) ]
20+ fn cross_endian_diff ( ) {
21+ let diff_config = diff:: DiffObjConfig :: default ( ) ;
22+ let obj_be = obj:: read:: parse ( include_object ! ( "data/mips/code_be.o" ) , & diff_config) . unwrap ( ) ;
23+ assert_eq ! ( obj_be. endianness, object:: Endianness :: Big ) ;
24+ let obj_le = obj:: read:: parse ( include_object ! ( "data/mips/code_le.o" ) , & diff_config) . unwrap ( ) ;
25+ assert_eq ! ( obj_le. endianness, object:: Endianness :: Little ) ;
26+ let left_symbol_idx = obj_be. symbols . iter ( ) . position ( |s| s. name == "func_00000000" ) . unwrap ( ) ;
27+ let right_symbol_idx =
28+ obj_le. symbols . iter ( ) . position ( |s| s. name == "func_00000000__FPcPc" ) . unwrap ( ) ;
29+ let ( left_diff, right_diff) =
30+ diff:: code:: diff_code ( & obj_be, & obj_le, left_symbol_idx, right_symbol_idx, & diff_config)
31+ . unwrap ( ) ;
32+ // Although the objects differ in endianness, the instructions should match.
33+ assert_eq ! ( left_diff. instruction_rows[ 0 ] . kind, diff:: InstructionDiffKind :: None ) ;
34+ assert_eq ! ( right_diff. instruction_rows[ 0 ] . kind, diff:: InstructionDiffKind :: None ) ;
35+ assert_eq ! ( left_diff. instruction_rows[ 1 ] . kind, diff:: InstructionDiffKind :: None ) ;
36+ assert_eq ! ( right_diff. instruction_rows[ 1 ] . kind, diff:: InstructionDiffKind :: None ) ;
37+ assert_eq ! ( left_diff. instruction_rows[ 2 ] . kind, diff:: InstructionDiffKind :: None ) ;
38+ assert_eq ! ( right_diff. instruction_rows[ 2 ] . kind, diff:: InstructionDiffKind :: None ) ;
39+ }
0 commit comments