Skip to content

AArch64: fix Rt operand of the integer STLUR forms - #3046

Merged
Rot127 merged 1 commit into
capstone-engine:nextfrom
gaul:aarch64-stlur-operand-mapping
Aug 31, 2026
Merged

AArch64: fix Rt operand of the integer STLUR forms#3046
Rot127 merged 1 commit into
capstone-engine:nextfrom
gaul:aarch64-stlur-operand-mapping

Conversation

@gaul

@gaul gaul commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

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

STLURB, STLURH and the two STLUR integer forms were generated with CS_OP_MEM set on their Rt data operand and CS_AC_WRITE for its access. Both are wrong: Rt is a plain source register, exactly as in the STUR forms these mirror.

The stray CS_OP_MEM made the mapping fold Rt into the memory operand, so the data register became mem.base, the real base became mem.index, and the displacement started a second MEM operand -- leaving the instruction with no register operand at all:

  stlur x10, [x8, #8]
  op_count: 2
    operands[0].type: MEM  base: x10  index: x8  access: WRITE
    operands[1].type: MEM  disp: 0x8            access: WRITE

against STUR's correct

  stur x10, [x8, #8]
  op_count: 2
    operands[0].type: REG = x10                 access: READ
    operands[1].type: MEM  base: x8  disp: 0x8  access: WRITE

A consumer walking the operand list therefore saw neither the value being stored nor the address it is stored to. cs_regs_access() happened to report both registers, which is why this survived: only the operand view was broken.

The five SIMD&FP STLUR forms (STLURbi/di/hi/qi/si) were already correct and are untouched; LDAPUR, the load half, was correct too.

Test plan

Adds the correction to suite/auto-sync/inc_patches so it survives regeneration, and regression cases for all four fixed forms plus one SIMD&FP form as the unchanged control.

Closing issues

STLURB, STLURH and the two STLUR integer forms were generated with
CS_OP_MEM set on their Rt data operand and CS_AC_WRITE for its access.
Both are wrong: Rt is a plain source register, exactly as in the STUR
forms these mirror.

The stray CS_OP_MEM made the mapping fold Rt into the memory operand,
so the data register became mem.base, the real base became mem.index,
and the displacement started a second MEM operand -- leaving the
instruction with no register operand at all:

  stlur x10, [x8, capstone-engine#8]
  op_count: 2
    operands[0].type: MEM  base: x10  index: x8  access: WRITE
    operands[1].type: MEM  disp: 0x8            access: WRITE

against STUR's correct

  stur x10, [x8, capstone-engine#8]
  op_count: 2
    operands[0].type: REG = x10                 access: READ
    operands[1].type: MEM  base: x8  disp: 0x8  access: WRITE

A consumer walking the operand list therefore saw neither the value
being stored nor the address it is stored to. cs_regs_access() happened
to report both registers, which is why this survived: only the operand
view was broken.

The five SIMD&FP STLUR forms (STLURbi/di/hi/qi/si) were already
correct and are untouched; LDAPUR, the load half, was correct too.

Adds the correction to suite/auto-sync/inc_patches so it survives
regeneration, and regression cases for all four fixed forms plus one
SIMD&FP form as the unchanged control.
@gaul
gaul force-pushed the aarch64-stlur-operand-mapping branch from 2b38fa3 to e260d4f Compare August 28, 2026 15:43

@Rot127 Rot127 left a comment

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.

Thanks!
Here you can keep the patch file.
Couldn't see an easy fix in our LLVM branch. So need to debug later.

@Rot127
Rot127 merged commit d82c726 into capstone-engine:next Aug 31, 2026
65 of 66 checks passed
@gaul
gaul deleted the aarch64-stlur-operand-mapping branch August 31, 2026 16:16
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.

2 participants