summaryrefslogtreecommitdiff
path: root/rust/src/function.rs
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 /rust/src/function.rs
parentc35fd93f9ad532387c2732e76838f3347aa9f539 (diff)
[Rust] Add `Function::defined_symbol` to use when getting the default function symbol is not warranted
Diffstat (limited to 'rust/src/function.rs')
-rw-r--r--rust/src/function.rs10
1 files changed, 10 insertions, 0 deletions
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();