Skip to content

fix: 32-bit x86 arg passing + guard arch/bits mismatch in unicorn runner - #12

Merged
2akouwu merged 1 commit into
2akouwu:mainfrom
IMGillusion:fix-32bit-arg-passing
Sep 5, 2026
Merged

fix: 32-bit x86 arg passing + guard arch/bits mismatch in unicorn runner#12
2akouwu merged 1 commit into
2akouwu:mainfrom
IMGillusion:fix-32bit-arg-passing

Conversation

@IMGillusion

Copy link
Copy Markdown
Contributor

fix: 32-bit x86 arg passing + guard arch/bits mismatch in unicorn runner

run_function had no 32-bit x86 default register set, so arch='x86' fell
back to 64-bit register names (rdi, rsi, ...). Written into a 32-bit
unicorn instance those are no-ops, so every 32-bit call silently saw
arg=0 and returned 0. Similarly arch='x86_64' + bits=32 mixed a 64-bit
register naming with a 32-bit mode -> same silent no-op.

  • add x86 / x86_ms arg + ret register sets (32-bit cdecl / Microsoft)
  • map arch -> bit width; derive bits from arch when omitted
  • raise ValueError on an explicit arch/bits mismatch (the verifier turns
    that into a clean INCONCLUSIVE instead of a silent wrong 0)

Adds 6 regression tests (32-bit add works, bits derived, 64-bit
regression, mismatch raises, 32-bit behavioral_equiv, equiv mismatch
raises). Full suite: 246 passed.


Fixes a silent arg-dropping bug in the Unicorn behavioral-execution path. No change to the 64-bit default behavior (regression-tested).

run_function had no 32-bit x86 default register set, so arch='x86' fell
back to 64-bit register names (rdi, rsi, ...). Written into a 32-bit
unicorn instance those are no-ops, so every 32-bit call silently saw
arg=0 and returned 0. Similarly arch='x86_64' + bits=32 mixed a 64-bit
register naming with a 32-bit mode -> same silent no-op.

- add x86 / x86_ms arg + ret register sets (32-bit cdecl / Microsoft)
- map arch -> bit width; derive bits from arch when omitted
- raise ValueError on an explicit arch/bits mismatch (the verifier turns
  that into a clean INCONCLUSIVE instead of a silent wrong 0)

Adds 6 regression tests (32-bit add works, bits derived, 64-bit
regression, mismatch raises, 32-bit behavioral_equiv, equiv mismatch
raises). Full suite: 246 passed.
@2akouwu
2akouwu merged commit 9ba2aa1 into 2akouwu:main Sep 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants