From 906de8cf124a6cc74d28c1f82ea9b4883b97efde Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 23 Nov 2025 17:17:11 -0500 Subject: [Rust] Add `Function::defined_symbol` to use when getting the default function symbol is not warranted --- rust/src/function.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'rust/src/function.rs') 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 { 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> { + 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(); -- cgit v1.3.1