summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-09-03 16:57:00 -0400
committerMason Reed <mason@vector35.com>2025-10-23 17:22:48 -0400
commit2897f797ebb4afa4bd4c57b7ba0835576308bc6c (patch)
tree233e7901839d2aaf0cb0b2c38348f03069910868
parent0151725f8b0cf1262fd0242434f029b0040fbe73 (diff)
Fix imported functions being ignored when building call sites, and fix python callers listing referenced calls
Fixes https://github.com/Vector35/binaryninja-api/issues/7308
-rw-r--r--python/function.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/python/function.py b/python/function.py
index 44043815..b56327e1 100644
--- a/python/function.py
+++ b/python/function.py
@@ -3242,6 +3242,7 @@ class Function:
"""
``callees`` returns a list of functions that this function calls
This does not include the address of those calls, rather just the function objects themselves. Use :py:meth:`call_sites` to identify the location of these calls.
+ This does not include calls to imported functions, as they do not have a function object, use :py:meth:`callee_addresses` for that.
:return: List of Functions that this function calls
:rtype: list(Function)
@@ -3259,7 +3260,7 @@ class Function:
@property
def callee_addresses(self) -> List[int]:
"""
- ``callee_addressses`` returns a list of start addresses for functions that this function calls.
+ ``callee_addresses`` returns a list of start addresses for functions that this function calls.
Does not point to the actual address where the call occurs, just the start of the function that contains the reference.
:return: List of start address for functions that this function calls
@@ -3280,7 +3281,7 @@ class Function:
:rtype: list(Function)
"""
functions = []
- for ref in self.view.get_code_refs(self.start):
+ for ref in self.caller_sites:
if ref.function is not None:
functions.append(ref.function)
return functions
@@ -3289,15 +3290,12 @@ class Function:
def caller_sites(self) -> Generator['binaryview.ReferenceSource', None, None]:
"""
``caller_sites`` returns a list of ReferenceSource objects corresponding to the addresses
- in functions which reference this function
+ in functions which call this function
:return: List of ReferenceSource objects of the call sites to this function
:rtype: list(ReferenceSource)
"""
- for site in self.view.get_code_refs(self.start):
- for llil in site.llils:
- if isinstance(llil, Localcall) and llil.dest.value == self.start:
- yield site
+ return self.view.get_callers(self.start)
@property
def workflow(self):