Fix Thumb2 conditinal branch - #601
Conversation
kstool thumb 'bne.w 0x680168E0' 0x68016578 should generate '40 F0 B2 81' that is the same as the one from capstone/IDA-Pro '0x68016578: 40 F0 B2 81 BNE.W loc_680168E0'
|
Confirming this fix independently — I hit the same bug via #451 and arrived at the same root cause before finding this PR. I've closed my duplicate (#607) in favor of this one, which is the better patch. For maintainers weighing it up, some verification that may help move it along: The diagnosis here is correct, and notably it is not what #451 proposed. That issue blamed the The one-line change is safe despite the helper having 16 callers. I checked each one: every other caller guards with Test results on top of
Two details worth noting beyond the report: the bug affects every wide conditional branch, including This resolves #451. |
kstool thumb "bne.w 0x680168E0" 0x68016578
should generate '40 F0 B2 81' which is the same as the one
from IDA-Pro "0x68016578: 40 F0 B2 81 BNE.W loc_680168E0"
or
capstone.Cs(CS_ARCH_ARM,CS_MODE_THUMB).disasm(the-generate-bytes,0x8016578) should match the raw-asm "bne.w 0x680168E0"
the bug code generate the wrong result: [ 56 f0 6e 84 ] which capstone can not disasm out the raw-asm