Skip to content

Commit 4f34dfa

Browse files
committed
Don't infer sizes for labels within another symbol
1 parent ae6d37a commit 4f34dfa

File tree

10 files changed

+3785
-9
lines changed

10 files changed

+3785
-9
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ strip = "debuginfo"
1414
codegen-units = 1
1515

1616
[workspace.package]
17-
version = "3.0.0-alpha.2"
17+
version = "3.0.0-alpha.3"
1818
authors = ["Luke Street <[email protected]>"]
1919
edition = "2021"
2020
license = "MIT OR Apache-2.0"

objdiff-core/src/obj/read.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,22 @@ fn infer_symbol_sizes(symbols: &mut [Symbol], sections: &[Section]) {
151151

152152
// Set symbol sizes based on the next symbol's address
153153
let mut iter_idx = 0;
154+
let mut last_end = (0, 0);
154155
while iter_idx < symbols_with_section.len() {
155156
let symbol_idx = symbols_with_section[iter_idx];
156157
let symbol = &symbols[symbol_idx];
158+
let section_idx = symbol.section.unwrap();
157159
iter_idx += 1;
158160
if symbol.size != 0 {
161+
if symbol.kind != SymbolKind::Section {
162+
last_end = (section_idx, symbol.address + symbol.size);
163+
}
164+
continue;
165+
}
166+
// Skip over symbols that are contained within the previous symbol
167+
if last_end.0 == section_idx && last_end.1 > symbol.address {
159168
continue;
160169
}
161-
let section_idx = symbol.section.unwrap();
162170
let next_symbol = match symbol.kind {
163171
// For function/object symbols, find the next function/object symbol (in other words:
164172
// skip over labels)

objdiff-core/tests/arch_arm.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
use objdiff_core::{diff, obj};
2+
3+
mod common;
4+
5+
#[test]
6+
#[cfg(feature = "arm")]
7+
fn read_arm() {
8+
let diff_config = diff::DiffObjConfig { mips_register_prefix: true, ..Default::default() };
9+
let obj = obj::read::parse(include_object!("data/arm/LinkStateItem.o"), &diff_config).unwrap();
10+
insta::assert_debug_snapshot!(obj);
11+
let symbol_idx = obj.symbols.iter().position(|s| s.name == "_ZN13LinkStateItem12OnStateLeaveEi").unwrap();
12+
let diff = diff::code::no_diff_code(&obj, symbol_idx, &diff_config).unwrap();
13+
insta::assert_debug_snapshot!(diff.instruction_rows);
14+
let output = common::display_diff(&obj, &diff, symbol_idx, &diff_config);
15+
insta::assert_snapshot!(output);
16+
}
4.72 KB
Binary file not shown.

0 commit comments

Comments
 (0)