THUMB "half-bl" instruction not supported
See original GitHub issueI am hoping to use Ghidra as a hobbyist to reverse engineer parts of GBA games for modding. Unfortunately, they make extensive use of what is technically unpredictable behaviour: using the second half of a “bl” instruction pair in THUMB code to perform an absolute jump to the address in the link register.
It would be really useful for THUMB disassembly to recognise and support this, maybe as an optional feature as there is no guarantee it works on other processors. The processor in question is the ARM7TDMI, with architecture ARMv4T, little-endian.
Sample of affected code:
0d 4b ldr r3, =procAddr
9e 46 mov lr, r3
00 f8 bl #0
Details of this instruction pair are found on page A7-26 of the ARM Architecture Reference Manual.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error: Thumb does not support conditional execution
I'm using arm-gcc to and it throws two errors. Error: Thumb does not support conditional execution. Error: instruction not allowed in IT block ......
Read more >ARM Architecture Reference Manual Thumb-2 Supplement
THE ARM ARCHITECTURE REFERENCE MANUAL IS PROVIDED "AS IS" WITH NO WARRANTIES. EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO ANY ...
Read more >ARM® and Thumb®-2 Instruction Set Quick Reference Card
<sh> range is 1-32 in the ARM instruction. C2. The optional 2 is available from ARMv5. It provides an alternative operation. Condition codes...
Read more >ARM and Thumb Assembler Instructions
Word-aligned loads are supported for LDRD. A non-word-aligned LDRD generates an alignment fault data abort. If A= 0 and U= 0, then LDR...
Read more >Thumb® Instruction Set Quick Reference Card
All Thumb registers are Lo (R0-R7) except where specified. ... Move NOT. MVN Rd, Rm. N Z. Rd := NOT Rm. Test bits....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you so much for that patch. I’ve managed to tweak it to create a new processor variant so that the changes don’t escape outside the GBA version.
I don’t know how to suitably create a patch for this so I’ll list the steps I used in detail in case it helps anyone else:Update: patch now included.I’m leaving this issue open in case this is a desired modification when Ghidra becomes open source.
This turns out to be a nice exercise in SLEIGH programming, so here we go:
If you apply the patch and restart Ghidra, it should automatically recompile the SLEIGH specification.
I confirmed this disassembled the half-br instruction properly on a test binary, and the decompiler picked it up as a call instruction as expected. (I’m not 100% sure I got the non-zero case right - but hopefully you don’t run into any of those?)