Skip to content

Commit f4c140c

Browse files
committed
Fix text sections not having their size zeroed out
1 parent c7cf54f commit f4c140c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

objdiff-core/src/obj/read.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ fn map_symbol(
5252

5353
let section_kind = map_section_kind(&section);
5454
if section_kind == SectionKind::Data {
55-
// For section symbols, the size would normally be zero and excluded from the diff.
56-
// Instead we make them the size of all the data in the section so that the user can diff
57-
// entire sections by clicking on the section symbol at the top of the section.
55+
// For data section symbols, the size would normally be zero and excluded from the diff.
56+
// Instead we make them the size of all the data in the section so that the user can
57+
// diff entire sections by clicking on the section symbol at the top of the section.
5858
// We only do this for data sections, as there would be no point for code or bss sections.
5959
if let Some(last_symbol) = file
6060
.symbols()
@@ -72,6 +72,13 @@ fn map_symbol(
7272
// so only fall back to it if there are no symbols to look at.
7373
size = section.size();
7474
}
75+
} else {
76+
// For non-data section symbols, set the size to zero. If the size is non-zero, it will
77+
// be included in the diff. Most of the time, this is duplicative, given that we'll have
78+
// function or object symbols that cover the same range. In the case of an empty
79+
// section, the size inference logic below will set the size back to the section size,
80+
// thus acting as a placeholder symbol.
81+
size = 0;
7582
}
7683
}
7784

0 commit comments

Comments
 (0)