| 20 | #[test] |
| 21 | #[cfg(feature = "mips")] |
| 22 | fn cross_endian_diff() { |
| 23 | let diff_config = diff::DiffObjConfig::default(); |
| 24 | let obj_be = obj::read::parse( |
| 25 | include_object!("data/mips/code_be.o"), |
| 26 | &diff_config, |
| 27 | diff::DiffSide::Base, |
| 28 | ) |
| 29 | .unwrap(); |
| 30 | assert_eq!(obj_be.endianness, object::Endianness::Big); |
| 31 | let obj_le = obj::read::parse( |
| 32 | include_object!("data/mips/code_le.o"), |
| 33 | &diff_config, |
| 34 | diff::DiffSide::Base, |
| 35 | ) |
| 36 | .unwrap(); |
| 37 | assert_eq!(obj_le.endianness, object::Endianness::Little); |
| 38 | let left_symbol_idx = obj_be.symbols.iter().position(|s| s.name == "func_00000000").unwrap(); |
| 39 | let right_symbol_idx = |
| 40 | obj_le.symbols.iter().position(|s| s.name == "func_00000000__FPcPc").unwrap(); |
| 41 | let (left_diff, right_diff) = |
| 42 | diff::code::diff_code(&obj_be, &obj_le, left_symbol_idx, right_symbol_idx, &diff_config) |
| 43 | .unwrap(); |
| 44 | // Although the objects differ in endianness, the instructions should match. |
| 45 | assert_eq!(left_diff.instruction_rows[0].kind, diff::InstructionDiffKind::None); |
| 46 | assert_eq!(right_diff.instruction_rows[0].kind, diff::InstructionDiffKind::None); |
| 47 | assert_eq!(left_diff.instruction_rows[1].kind, diff::InstructionDiffKind::None); |
| 48 | assert_eq!(right_diff.instruction_rows[1].kind, diff::InstructionDiffKind::None); |
| 49 | assert_eq!(left_diff.instruction_rows[2].kind, diff::InstructionDiffKind::None); |
| 50 | assert_eq!(right_diff.instruction_rows[2].kind, diff::InstructionDiffKind::None); |
| 51 | } |
| 52 | |
| 53 | #[test] |
| 54 | #[cfg(feature = "mips")] |