Skip to content

Commit 906de8c

Browse files
committed
[Rust] Add Function::defined_symbol to use when getting the default function symbol is not warranted
1 parent c35fd93 commit 906de8c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

plugins/warp/src/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ impl WarpFileProcessor {
837837
) -> Result<HashMap<Target, Vec<SignatureChunk<'static>>>, ProcessingError> {
838838
let is_function_named = |f: &Guard<BNFunction>| {
839839
self.included_functions == IncludedFunctionsField::All
840-
|| view.symbol_by_address(f.start()).is_some()
840+
|| f.defined_symbol().is_some()
841841
|| f.has_user_annotations()
842842
};
843843
let is_function_tagged = |f: &Guard<BNFunction>| {

rust/src/function.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,23 @@ impl Function {
368368
}
369369
}
370370

371+
/// Returns the symbol at the function start address or a default symbol.
372+
///
373+
/// NOTE: If you want to only get the symbol if there is actually a symbol, use [`Function::defined_symbol`].
371374
pub fn symbol(&self) -> Ref<Symbol> {
372375
unsafe {
373376
let sym = BNGetFunctionSymbol(self.handle);
374377
Symbol::ref_from_raw(sym)
375378
}
376379
}
377380

381+
/// Returns the symbol at the function start address or `None` if there is no symbol.
382+
///
383+
/// NOTE: If you want to get a default "sub_X" symbol use [`Function::symbol`].
384+
pub fn defined_symbol(&self) -> Option<Ref<Symbol>> {
385+
self.view().symbol_by_address(self.start())
386+
}
387+
378388
/// Returns true when the function's symbol binding marks it as exported.
379389
pub fn is_exported(&self) -> bool {
380390
let symbol = self.symbol();

0 commit comments

Comments
 (0)