binaryninja-api
binaryninja-api copied to clipboard
Copying a basic block and modifying its predecessor's branch targets can cause confusion in the mapping of instructions to basic blocks.
Version and Platform (required):
- Binary Ninja Version: 4.1.5902-stable
- OS: MacOS
- OS Version: 14.5
- CPU Architecture: M2
Bug Description:
First of all, my purpose is: at 0x26ef0 in the main function of the sample, there is a common sub-basic block (perhaps it should be called a common sub-expression). I want to copy this basic block to each of its predecessor basic blocks, thereby eliminating this "common sub-basic block".
To this end, I developed a simple workflow plug-in. In the main function, execute Plugin->Optimizer->Propagate the Common Sub-BasicBlock (test) to achieve the above functions.
The execution results are as follows. Judging from the CFG alone, the effect of the workflow is in line with expectations.
But if you try to use current_il_instruction.il_basic_block on an instruction in the copied basic block, you will get a strange error like the following:
However, in the SSA form, everything is normal again.
This is my sample and workflow plugin source code. The binja version I use is 4.1.5902-stable
Steps To Reproduce: Please provide all steps required to reproduce the behavior:
- Compile the block_propagate workflow
- Go to the "main" function, Go to address 0x26ef0
- Run Plugin->Optimizer->Propagate the Common Sub-BasicBlock (test)
- Execute current_il_instruction.il_basic_block for the copied block's instruction
- See error
Expected Behavior: Please provide a clear and concise description of what you expected to happen.
Screenshots/Video Recording: If applicable, please add screenshots/video recording here to help explain your problem.
Binary: If applicable, please provide us with the binary to help us work with the issue faster. Here are a few options: sock1_unpacked (1).zip
Workflow Source Code block_propagate.zip
- Directly attach it to this issue in a ZIP archive
- Share a publicly accessible link to it (For malware samples, we do not have access to VirusTotal; Malshare is an option)
- Email it to binaryninja at vector35.com, or join our slack and share with us in private
- We understand sometimes it is not possible to share the binary -- sure, no worries, we can still work with it!
- If your issue is general and not related to a specific binary, then there is no need to attach the binary as well
Additional Information: Please add any other context about the problem here.