defaultarch: handle caller-set return addresses when inlining calls#8246
defaultarch: handle caller-set return addresses when inlining calls#8246appleflyerv3 wants to merge 1 commit into
Conversation
detect registers that are set to the caller's next addr before a call is inlined, and therefore treat the jumps to those regs in the callee IL as returns to the call label.
|
This fix allows Binary Ninja to recognize during function inlining when an inlined function returns by jumping to a register that was set to the caller’s fallthrough address. (lifted via LLIL_JUMP) For example, this is used by RISC-V LLVM outlined functions such as Example: sub_function:
jal t0, OUTLINED_FUNCTION_1
...
jal t0, OUTLINED_FUNCTION_2
OUTLINED_FUNCTION_1:
addi sp, sp, -0x10
sw ra, 0xc(sp)
sw s0, 0x8(sp)
sw s1, 0x4(sp)
sw s2, 0x0(sp)
jr t0
OUTLINED_FUNCTION_2:
lw ra, 0xc(sp)
lw s0, 0x8(sp)
lw s1, 0x4(sp)
lw s2, 0x0(sp)
addi sp, sp, 0x10
jr t0 |
|
I have reviewed/tested this PR and added the following commits to the test_pr_8246 branch:
|
| } | ||
|
|
||
|
|
||
| static bool IsConstantPointer(LowLevelILInstruction expr, uint64_t value) |
There was a problem hiding this comment.
the function name?
what would be a more suitable name for this, then?
There was a problem hiding this comment.
I changed the function name to ConstantCompare since it's not only checking that the expression is a constant, it's also checking if it is equal to value
detect registers that are set to the caller's next addr before a call is inlined, and therefore treat the jumps to those regs in the callee IL as returns to the call label.