diff --git a/objdiff-cli/src/views/function_diff.rs b/objdiff-cli/src/views/function_diff.rs index 2ec6215..c6921a5 100644 --- a/objdiff-cli/src/views/function_diff.rs +++ b/objdiff-cli/src/views/function_diff.rs @@ -3,7 +3,7 @@ use crossterm::event::{Event, KeyCode, KeyEventKind, KeyModifiers, MouseButton, use objdiff_core::{ diff::{ display::{display_diff, DiffText, HighlightKind}, - ObjDiff, ObjInsDiffKind, ObjSymbolDiff, + FunctionDataDiffs, ObjDiff, ObjInsDiffKind, ObjSymbolDiff, }, obj::{ObjInfo, ObjSectionKind, ObjSymbol, SymbolRef}, }; @@ -375,10 +375,14 @@ impl UiView for FunctionDiffUi { result.redraw = true; return EventControlFlow::Reload; } - // Toggle relax shifted data diffs + // Cycle through function data diff mode KeyCode::Char('s') => { - state.diff_obj_config.relax_shifted_data_diffs = - !state.diff_obj_config.relax_shifted_data_diffs; + state.diff_obj_config.function_data_diffs = + match state.diff_obj_config.function_data_diffs { + FunctionDataDiffs::AddressOnly => FunctionDataDiffs::ValueOnly, + FunctionDataDiffs::ValueOnly => FunctionDataDiffs::All, + FunctionDataDiffs::All => FunctionDataDiffs::AddressOnly, + }; result.redraw = true; return EventControlFlow::Reload; } diff --git a/objdiff-core/config-schema.json b/objdiff-core/config-schema.json index 72c0eb4..d1bab40 100644 --- a/objdiff-core/config-schema.json +++ b/objdiff-core/config-schema.json @@ -8,11 +8,25 @@ "description": "Ignores differences in relocation targets. (Address, name, etc)" }, { - "id": "relaxShiftedDataDiffs", - "type": "boolean", - "default": false, - "name": "Relax shifted data diffs", - "description": "Ignores differences in addresses for symbols with matching data." + "id": "functionDataDiffs", + "type": "choice", + "default": "address_only", + "name": "Function data diffs", + "description": "How data relocations will be diffed in the function view.", + "items": [ + { + "value": "address_only", + "name": "Address only" + }, + { + "value": "value_only", + "name": "Value only" + }, + { + "value": "all", + "name": "Value and address" + } + ] }, { "id": "spaceBetweenArgs", @@ -201,7 +215,7 @@ "name": "General", "properties": [ "relaxRelocDiffs", - "relaxShiftedDataDiffs", + "functionDataDiffs", "spaceBetweenArgs", "combineDataSections" ] diff --git a/objdiff-core/src/diff/code.rs b/objdiff-core/src/diff/code.rs index 661ec52..2ba65ae 100644 --- a/objdiff-core/src/diff/code.rs +++ b/objdiff-core/src/diff/code.rs @@ -3,6 +3,7 @@ use std::{cmp::max, collections::BTreeMap}; use anyhow::{anyhow, Result}; use similar::{capture_diff_slices_deadline, Algorithm}; +use super::FunctionDataDiffs; use crate::{ arch::ProcessCodeResult, diff::{ @@ -241,8 +242,9 @@ fn reloc_eq( section_name_eq(left_obj, right_obj, *sl, *sr) && (symbol_name_matches || address_eq(left, right) - || config.relax_shifted_data_diffs) - && (left.target.kind != ObjSymbolKind::Object + || config.function_data_diffs == FunctionDataDiffs::ValueOnly) + && (config.function_data_diffs == FunctionDataDiffs::AddressOnly + || left.target.kind != ObjSymbolKind::Object || left_obj.arch.display_ins_data(left_ins) == left_obj.arch.display_ins_data(right_ins)) }