Skip to content

Fix RISCV aliases#2891

Merged
Rot127 merged 5 commits intocapstone-engine:nextfrom
slate5:fix/missing-alias
Apr 10, 2026
Merged

Fix RISCV aliases#2891
Rot127 merged 5 commits intocapstone-engine:nextfrom
slate5:fix/missing-alias

Conversation

@slate5
Copy link
Copy Markdown
Contributor

@slate5 slate5 commented Apr 7, 2026

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

Fixing alias detection from issue #2861.

Test plan

$ cstool -dr riscv32 "0x67, 0x80, 0x50, 0x00"
 0  67 80 50 00  jr	5(ra)
	ID: 31 (jalr)
	Is alias: 1696 (jr) with REAL operand set
	op_count: 3
		operands[0].type: REG = zero
		operands[0].access: WRITE
		operands[1].type: REG = ra
		operands[1].access: READ
		operands[2].type: IMM = 0x5
		operands[2].access: READ

	Groups: jump 

$ cstool -d riscv64 "e780604c"
 0  e7 80 60 4c  jalr	0x4c6(ra)
	ID: 31 (jalr)
	Is alias: 1697 (jalr) with REAL operand set
	op_count: 2
		operands[0].type: REG = ra
		operands[0].access: READ
		operands[1].type: IMM = 0x4c6
		operands[1].access: READ

	Groups: jump 

$ cstool -d riscv32+corev 0x5BD5C540
 0  5b d5 c5 40  cv.mulhhu	a0, a1, a2
	ID: 395 (cv_mulhhun)
	Is alias: 1762 (cv.mulhhu) with REAL operand set
	op_count: 3
		operands[0].type: REG = a0
		operands[0].access: WRITE
		operands[1].type: REG = a1
		operands[1].access: READ
		operands[2].type: REG = a2
		operands[2].access: READ

	Groups: HasVendorXCVmac IsRV32 

Depends-on

The third example (cv.mulhhu) depends on capstone-engine/llvm-capstone#91.

Closing issues

closes #2861

@github-actions github-actions bot added RISCV Arch CS-core-files auto-sync labels Apr 7, 2026
@Rot127 Rot127 changed the title Fix aliases Fix RISCV aliases Apr 7, 2026
Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the updated RISCVGenCSAliasMnemMap.inc and the test cases to tests/issues/issues.yaml

@Rot127
Copy link
Copy Markdown
Collaborator

Rot127 commented Apr 7, 2026

cc @moste00

Copy link
Copy Markdown
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks.
Please fix those tests and we are good to go when green.

-
asm_text: "zip a0, a1"
id: RISCV_INS_ZIP
is_alias: 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_alias: 0
is_alias: -1

@Rot127 Rot127 merged commit fedc9b4 into capstone-engine:next Apr 10, 2026
35 checks passed
@slate5 slate5 deleted the fix/missing-alias branch April 10, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing or incorrect alias and id info of jlar

3 participants