Ignore extern symbols with symbol name lookups

When searching for a symbol by name, only look at
symbols that are defined within the object,
ignoring extern symbols (symbols without section).

Fixes #180
Fixes #181
This commit is contained in:
2025-05-13 22:48:39 -06:00
parent 8e8ab6bef8
commit 07ef93f16a
4 changed files with 15 additions and 26 deletions

View File

@@ -308,6 +308,10 @@ impl Object {
let offset = symbol.address.checked_sub(section.address)?;
section.data.get(offset as usize..offset as usize + symbol.size as usize)
}
pub fn symbol_by_name(&self, name: &str) -> Option<usize> {
self.symbols.iter().position(|symbol| symbol.section.is_some() && symbol.name == name)
}
}
#[derive(Debug, Clone, Eq, PartialEq, Hash)]