Skip to content

ARM Thumb: disassembly for BL instruction resolves incorrect immediate value. #1935

@rchtsang

Description

@rchtsang

capstone v4.0.2 installed from pip (Mac OSX 12.6 and Ubuntu 20.04)

It seems like the ARM Thumb BL immediate values are being incorrectly decoded.

Manually decoding the instruction b"\xff\xf7\xad\xff" ought to yield bl 0xffffff5a, however, capstone gives the following:

>>> from capstone import *
>>> from capstone.arm_const import *
>>> cs = Cs(CS_ARCH_ARM, CS_MODE_THUMB)
>>> insn = next(cs.disasm(b"\xff\xf7\xad\xff", 4))
>>> insn
<CsInsn 0x4 [fff7adff]: bl #0xffffff62>

I have tried with some other bl instructions and the immediate values are also off by 8.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions