Skip to content

Support .callers and other Function methods for extern functions #6722

@saruman9

Description

@saruman9

What is the feature you'd like to have?
I'd like extern (imported) functions to be fully represented as Function objects (or at least to have a wrapper/interface that behaves similarly), so that I can use standard API methods and properties like .callers, .caller_sites, etc. For example, I'd expect bv.get_functions_by_name("strcpy") to return the extern function if it's present in the binary.

Is your feature request related to a problem?
Yes. Currently, extern functions (such as those from standard libraries) are represented differently in the MLIL (e.g., as MediumLevelILExternPtr in the dest field of MediumLevelILCall). Because of this, I cannot interact with them using the same APIs available for regular functions. As a result, methods like .callers and .caller_sites do not work for them. There also seems to be no straightforward way to get call sites to extern functions without iterating through all IL instructions in all functions manually.

Are any alternative solutions acceptable?
If exposing extern functions as regular Function objects is not feasible, I would appreciate an alternative API that allows querying for call sites to extern functions by name or address, without needing to manually walk through every function's IL.

Additional Information:
This feature would improve the developer experience when writing plugins or analyses that rely on detecting uses of unsafe or critical extern functions like strcpy, malloc, or system.

This might be related to or similar to issue #2663.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: APIIssue needs changes to the APIEffort: LowIssue should take < 1 weekImpact: LowIssue is a papercut or has a good, supported workaround

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions