Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if branches on ARM32 switch between THUMB/ARM mode #4

Open
ayrtonm opened this issue Aug 25, 2021 · 2 comments
Open

Check if branches on ARM32 switch between THUMB/ARM mode #4

ayrtonm opened this issue Aug 25, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@ayrtonm
Copy link
Contributor

ayrtonm commented Aug 25, 2021

It might be possible to use binja like in #3 to check this. Basically for branch destinations with 32-bit instructions, we'd try to parse them with binja in both ARM and THUMB mode and see if one case fails. u32s that are valid in both may require a more involved solution (e.g. looking at cpu registers), but using binja would be a good first step.

@ayrtonm ayrtonm added the enhancement New feature or request label Aug 26, 2021
@ayrtonm
Copy link
Contributor Author

ayrtonm commented Oct 22, 2021

It should be straightforward to determine if an insn is ARM/THUMB at translation-time using BinaryNinja. Since the only callback arg is a single u64 which is already used for the branch/target address I could encode the processor state as the LSB of this u64 (similar to how it works in hardware). This avoids the need for dynamic memory allocation and would simplify the plugin design.

@ayrtonm
Copy link
Contributor Author

ayrtonm commented Jun 8, 2022

I updated the simple built-in backend to check for both the ARM and THUMB encodings of the blx with register instruction. The plugin should track whether the CPU is in ARM or THUMB mode because the current solution may print spurious warnings as explained in this commit. I should track the CPU state before adding THUMB support for the binja backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant