summaryrefslogtreecommitdiff
path: root/python/function.py
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-11-18 15:45:15 -0800
committerMark Rowe <mark@vector35.com>2026-01-14 09:34:32 -0800
commit6e50ceda4e65e5952e59449fad4953ea6c5aaf37 (patch)
tree3f9defd37d0b2d1b7725b0f876fa474b6301d056 /python/function.py
parent56010d289afa142ebd206db8fc3b22f89d7a4ec0 (diff)
Allow controlling which address is used for instructions created when inlining during analysis
Previously the address of the instruction in the function being inlined was used as the new instruction's address when copying it during inlining. Now there is an additional option: use the address of the call instruction that is being replaced as the new instruction's address. This new mode is useful when inlining thunks or stub functions, but care must be taken if using it beyond that. The benefit is that it ensures that when a function contains multiple calls to the same stub function, each inlined copy ends up with distinct addresses. This ensures that call type adjustments and other overrides that are stored on the function and keyed by address can be applied independently to each callsite that was inlined. The trade-off is that if the function being inlined contains non-trivial logic, all of the inlined instructions sharing an address will limit what type of adjustments can be applied to them. The Objective-C and shared cache workflows are updated to take advantage of this new mode when they enable inlining of stub functions. This will make it possible for multiple calls to the same runtime function within a single function to have separate call type adjustments applied in the future.
Diffstat (limited to 'python/function.py')
-rw-r--r--python/function.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/python/function.py b/python/function.py
index c328ca77..29527f4d 100644
--- a/python/function.py
+++ b/python/function.py
@@ -1667,13 +1667,13 @@ class Function:
return self.view.get_function_parent_components(self)
@property
- def inline_during_analysis(self) -> 'types.BoolWithConfidence':
+ def inline_during_analysis(self) -> 'types.InlineDuringAnalysisWithConfidence':
"""Whether the function's IL should be inlined into all callers' IL"""
- result = core.BNIsFunctionInlinedDuringAnalysis(self.handle)
- return types.BoolWithConfidence(result.value, confidence=result.confidence)
+ result = core.BNGetFunctionInlinedDuringAnalysis(self.handle)
+ return types.InlineDuringAnalysisWithConfidence(result.value, confidence=result.confidence)
@inline_during_analysis.setter
- def inline_during_analysis(self, value: Union[bool, 'types.BoolWithConfidence']):
+ def inline_during_analysis(self, value: Union['types.InlineDuringAnalysis', 'types.InlineDuringAnalysisWithConfidence', bool, 'types.BoolWithConfidence']):
self.set_user_inline_during_analysis(value)
def mark_recent_use(self) -> None:
@@ -3553,23 +3553,26 @@ class Function:
"""
core.BNUnsplitVariable(self.handle, var.to_BNVariable())
- def set_auto_inline_during_analysis(self, value: Union[bool, 'types.BoolWithConfidence']):
- bc = core.BNBoolWithConfidence()
- bc.value = bool(value)
- if isinstance(value, types.BoolWithConfidence):
- bc.confidence = value.confidence
- else:
- bc.confidence = core.max_confidence
- core.BNSetAutoFunctionInlinedDuringAnalysis(self.handle, bc)
+ @classmethod
+ def _inline_during_analysis_with_confidence(cls, value: Union['types.InlineDuringAnalysis', 'types.InlineDuringAnalysisWithConfidence', bool, 'types.BoolWithConfidence']) -> 'types.InlineDuringAnalysisWithConfidence':
+ if isinstance(value, types.InlineDuringAnalysisWithConfidence):
+ return value
- def set_user_inline_during_analysis(self, value: Union[bool, 'types.BoolWithConfidence']):
- bc = core.BNBoolWithConfidence()
- bc.value = bool(value)
if isinstance(value, types.BoolWithConfidence):
- bc.confidence = value.confidence
- else:
- bc.confidence = core.max_confidence
- core.BNSetUserFunctionInlinedDuringAnalysis(self.handle, bc)
+ return core.BNInlineDuringAnalysisWithConfidence(int(value.value), value.confidence)
+
+ if isinstance(value, bool):
+ return core.BNInlineDuringAnalysisWithConfidence(int(value), core.max_confidence)
+
+ return core.BNInlineDuringAnalysisWithConfidence(value, core.max_confidence)
+
+ def set_auto_inline_during_analysis(self, value: Union['types.InlineDuringAnalysis', 'types.InlineDuringAnalysisWithConfidence', bool, 'types.BoolWithConfidence']):
+ value = self._inline_during_analysis_with_confidence(value)
+ core.BNSetAutoFunctionInlinedDuringAnalysis(self.handle, value)
+
+ def set_user_inline_during_analysis(self, value: Union['types.InlineDuringAnalysis', 'types.InlineDuringAnalysisWithConfidence', bool, 'types.BoolWithConfidence']):
+ value = self._inline_during_analysis_with_confidence(value)
+ core.BNSetUserFunctionInlinedDuringAnalysis(self.handle, value)
def toggle_region(self, hash):
"""