Skip to content

arm64: missing register in regs_access() for ldr instruction #2137

@find0x90

Description

@find0x90

The regs_access() function is missing the read register for the ldr instruction.

Below is a small script that reproduces the issue between version 4.0.2 and the most recent commit as of this comment.

#! /usr/bin/env python3
# cs_test.py

from capstone import *

md = Cs(CS_ARCH_ARM64, CS_MODE_ARM | CS_MODE_LITTLE_ENDIAN)
md.detail = True

instruction_bytes = b"\x00\x05\x45\xf9"

inst = list(md.disasm(instruction_bytes, offset=0x0, count=1))[0]

print(inst)

regs_read, regs_written = inst.regs_access()
regs_read = [inst.reg_name(r) for r in regs_read]
regs_written = [inst.reg_name(r) for r in regs_written]

print(regs_read, regs_written)

4.0.2:

$ ./cs_test.py
<CsInsn 0x0 [000545f9]: ldr x0, [x8, #0xa08]>
['x8'] ['x0']

next branch: 36c5eef

> ./cs_test.py
<CsInsn 0x0 [000545f9]: ldr x0, [x8, #0xa08]>
[] ['x0']

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