summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-11-23 17:17:11 -0500
committerMason Reed <mason@vector35.com>2025-12-15 17:26:10 -0500
commit906de8cf124a6cc74d28c1f82ea9b4883b97efde (patch)
tree1edce1b893262696b81ed9336d0f6806e403d517
parentc35fd93f9ad532387c2732e76838f3347aa9f539 (diff)
[Rust] Add `Function::defined_symbol` to use when getting the default function symbol is not warranted
-rw-r--r--plugins/warp/src/processor.rs2
-rw-r--r--rust/src/function.rs10
2 files changed, 11 insertions, 1 deletions
diff --git a/plugins/warp/src/processor.rs b/plugins/warp/src/processor.rs
index df26f613..693f0852 100644
--- a/plugins/warp/src/processor.rs
+++ b/plugins/warp/src/processor.rs
@@ -837,7 +837,7 @@ impl WarpFileProcessor {
) -> Result<HashMap<Target, Vec<SignatureChunk<'static>>>, ProcessingError> {
let is_function_named = |f: &Guard<BNFunction>| {
self.included_functions == IncludedFunctionsField::All
- || view.symbol_by_address(f.start()).is_some()
+ || f.defined_symbol().is_some()
|| f.has_user_annotations()
};
let is_function_tagged = |f: &Guard<BNFunction>| {
diff --git a/rust/src/function.rs b/rust/src/function.rs
index 29d4fc3c..06da39dc 100644
--- a/rust/src/function.rs
+++ b/rust/src/function.rs
@@ -368,6 +368,9 @@ impl Function {
}
}
+ /// Returns the symbol at the function start address or a default symbol.
+ ///
+ /// NOTE: If you want to only get the symbol if there is actually a symbol, use [`Function::defined_symbol`].
pub fn symbol(&self) -> Ref<Symbol> {
unsafe {
let sym = BNGetFunctionSymbol(self.handle);
@@ -375,6 +378,13 @@ impl Function {
}
}
+ /// Returns the symbol at the function start address or `None` if there is no symbol.
+ ///
+ /// NOTE: If you want to get a default "sub_X" symbol use [`Function::symbol`].
+ pub fn defined_symbol(&self) -> Option<Ref<Symbol>> {
+ self.view().symbol_by_address(self.start())
+ }
+
/// Returns true when the function's symbol binding marks it as exported.
pub fn is_exported(&self) -> bool {
let symbol = self.symbol();