Fix logic issue with 0-sized symbols

Fixes #119
This commit is contained in:
Luke Street 2024-10-10 22:20:48 -06:00
parent 741d93e211
commit cbe299e859
1 changed files with 2 additions and 2 deletions

View File

@ -182,14 +182,14 @@ fn symbols_by_section(
result.sort_by(|a, b| a.address.cmp(&b.address).then(a.size.cmp(&b.size))); result.sort_by(|a, b| a.address.cmp(&b.address).then(a.size.cmp(&b.size)));
let mut iter = result.iter_mut().peekable(); let mut iter = result.iter_mut().peekable();
while let Some(symbol) = iter.next() { while let Some(symbol) = iter.next() {
if symbol.kind == ObjSymbolKind::Unknown && symbol.size == 0 { if symbol.size == 0 {
if let Some(next_symbol) = iter.peek() { if let Some(next_symbol) = iter.peek() {
symbol.size = next_symbol.address - symbol.address; symbol.size = next_symbol.address - symbol.address;
} else { } else {
symbol.size = (section.address + section.size) - symbol.address; symbol.size = (section.address + section.size) - symbol.address;
} }
// Set symbol kind if we ended up with a non-zero size // Set symbol kind if we ended up with a non-zero size
if symbol.size > 0 { if symbol.kind == ObjSymbolKind::Unknown && symbol.size > 0 {
symbol.kind = match section.kind { symbol.kind = match section.kind {
ObjSectionKind::Code => ObjSymbolKind::Function, ObjSectionKind::Code => ObjSymbolKind::Function,
ObjSectionKind::Data | ObjSectionKind::Bss => ObjSymbolKind::Object, ObjSectionKind::Data | ObjSectionKind::Bss => ObjSymbolKind::Object,