mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 15:13:47 +00:00
Omit match % for right sections, improve multi-section diffing
Fixes #120
This commit is contained in:
parent
8b5bf21f38
commit
3db0727469
@ -274,7 +274,6 @@ pub fn diff_data_section(
|
||||
// We only do this when all relocations on the left side match.
|
||||
if left_section_diff.match_percent.unwrap_or(-1.0) < match_percent {
|
||||
left_section_diff.match_percent = Some(match_percent);
|
||||
right_section_diff.match_percent = Some(match_percent);
|
||||
}
|
||||
}
|
||||
Ok((left_section_diff, right_section_diff))
|
||||
@ -413,7 +412,7 @@ pub fn diff_generic_section(
|
||||
};
|
||||
Ok((
|
||||
SectionDiff { match_percent: Some(match_percent), data_diff: vec![], reloc_diff: vec![] },
|
||||
SectionDiff { match_percent: Some(match_percent), data_diff: vec![], reloc_diff: vec![] },
|
||||
SectionDiff { match_percent: None, data_diff: vec![], reloc_diff: vec![] },
|
||||
))
|
||||
}
|
||||
|
||||
@ -454,7 +453,7 @@ pub fn diff_bss_section(
|
||||
|
||||
Ok((
|
||||
SectionDiff { match_percent: Some(match_percent), data_diff: vec![], reloc_diff: vec![] },
|
||||
SectionDiff { match_percent: Some(match_percent), data_diff: vec![], reloc_diff: vec![] },
|
||||
SectionDiff { match_percent: None, data_diff: vec![], reloc_diff: vec![] },
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -600,9 +600,7 @@ fn symbol_matches_filter(
|
||||
return false;
|
||||
}
|
||||
if !show_hidden_symbols
|
||||
&& (symbol.size == 0
|
||||
|| symbol.flags.contains(SymbolFlag::Hidden)
|
||||
|| symbol.flags.contains(SymbolFlag::Ignored))
|
||||
&& (symbol.size == 0 || symbol.flags.contains(SymbolFlag::Hidden | SymbolFlag::Ignored))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -658,7 +658,11 @@ fn find_symbol(
|
||||
|
||||
/// Find matching sections between each object.
|
||||
fn matching_sections(left: Option<&Object>, right: Option<&Object>) -> Result<Vec<SectionMatch>> {
|
||||
let mut matches = Vec::new();
|
||||
let mut matches = Vec::with_capacity(
|
||||
left.as_ref()
|
||||
.map_or(0, |o| o.sections.len())
|
||||
.max(right.as_ref().map_or(0, |o| o.sections.len())),
|
||||
);
|
||||
if let Some(left) = left {
|
||||
for (section_idx, section) in left.sections.iter().enumerate() {
|
||||
if section.kind == SectionKind::Unknown {
|
||||
@ -666,7 +670,7 @@ fn matching_sections(left: Option<&Object>, right: Option<&Object>) -> Result<Ve
|
||||
}
|
||||
matches.push(SectionMatch {
|
||||
left: Some(section_idx),
|
||||
right: find_section(right, §ion.name, section.kind),
|
||||
right: find_section(right, §ion.name, section.kind, &matches),
|
||||
section_kind: section.kind,
|
||||
});
|
||||
}
|
||||
@ -689,6 +693,13 @@ fn matching_sections(left: Option<&Object>, right: Option<&Object>) -> Result<Ve
|
||||
Ok(matches)
|
||||
}
|
||||
|
||||
fn find_section(obj: Option<&Object>, name: &str, section_kind: SectionKind) -> Option<usize> {
|
||||
obj?.sections.iter().position(|s| s.kind == section_kind && s.name == name)
|
||||
fn find_section(
|
||||
obj: Option<&Object>,
|
||||
name: &str,
|
||||
section_kind: SectionKind,
|
||||
matches: &[SectionMatch],
|
||||
) -> Option<usize> {
|
||||
obj?.sections.iter().enumerate().position(|(i, s)| {
|
||||
s.kind == section_kind && s.name == name && !matches.iter().any(|m| m.right == Some(i))
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user