Skip to content

Loongarch ld instructions have incorrect registers modified #2700

@OBarronCS

Description

@OBarronCS

Work environment

Questions Answers
Capstone module affected loongarch
Source of Capstone pip install capstone==6.0.0a4
Version/git commit 6.0.0 alpha 4

Various Loongarch memory load instructions do not indicate the register written in the regs_access() API.

This is the case for

ld.b
ld.h
ld.w
ld.d
ld.bu
ld.hu
ld.wu
cstool -d loongarch64 "0cfe3f2a"
 0  0c fe 3f 2a  ld.bu	$t0, $t4, -1
	ID: 349 (ld_bu)
	op_count: 2
		operands[0].type: REG = t0
		operands[0].access: READ
		operands[1].type: MEM
			operands[1].mem.base: REG = t4
			operands[1].mem.disp: 0xffffffffffffffff
		operands[1].access: READ
	Registers read: t0 t4

Expected behavior

Expected that the first operand is in the Registers modified list. In the case above, this means $t0.

These definitions can be found in LoongArchGenCSMappingInsnOp.inc here: https://github.com/capstone-engine/capstone/blob/fc525c7326a82880e86248d9d1d3a6e9fc6f8750/arch/LoongArch/LoongArchGenCSMappingInsnOp.inc#L3384-L3432
For each of these, the rd (the first) element of the definitions contains CS_AC_READ instead of CS_AC_WRITE

Metadata

Metadata

Assignees

No one assigned

    Labels

    LoongArchArchbugSomething is not working as it should

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions