From f58616b6dd6fcf7fa0047105a84bf1540eab9d35 Mon Sep 17 00:00:00 2001 From: Ryan Burns <52847440+r-burns@users.noreply.github.com> Date: Fri, 30 May 2025 14:00:02 -0700 Subject: [PATCH] Use symbol name when comparing against an externed reloc (#214) * Use symbol name when comparing against an externed reloc For partial matching files, often a symbol is externed even though it should exist in the target object. We can still compare the symbol name, instead of always returning a mismatch. * Combine cases, and apply change reloc_eq in code.rs --- objdiff-core/src/diff/code.rs | 3 +-- objdiff-core/src/diff/data.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/objdiff-core/src/diff/code.rs b/objdiff-core/src/diff/code.rs index e0d74d7..f5ceb45 100644 --- a/objdiff-core/src/diff/code.rs +++ b/objdiff-core/src/diff/code.rs @@ -325,12 +325,11 @@ fn reloc_eq( || display_ins_data_literals(left_obj, left_ins) == display_ins_data_literals(right_obj, right_ins)) } - (Some(_), None) => false, (None, Some(_)) => { // Match if possibly stripped weak symbol symbol_name_addend_matches && right_reloc.symbol.flags.contains(SymbolFlag::Weak) } - (None, None) => symbol_name_addend_matches, + (Some(_), None) | (None, None) => symbol_name_addend_matches, } } diff --git a/objdiff-core/src/diff/data.rs b/objdiff-core/src/diff/data.rs index 514287f..a47474f 100644 --- a/objdiff-core/src/diff/data.rs +++ b/objdiff-core/src/diff/data.rs @@ -53,12 +53,11 @@ fn reloc_eq( section_name_eq(left_obj, right_obj, sl, sr) && (symbol_name_addend_matches || address_eq(left, right)) } - (Some(_), None) => false, (None, Some(_)) => { // Match if possibly stripped weak symbol symbol_name_addend_matches && right.symbol.flags.contains(SymbolFlag::Weak) } - (None, None) => symbol_name_addend_matches, + (Some(_), None) | (None, None) => symbol_name_addend_matches, } }