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 --- plugins/warp/src/processor.rs | 2 +- rust/src/function.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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>>, ProcessingError> { let is_function_named = |f: &Guard| { 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| { 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