mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1488] x64_recomp: in/out immediate ports need their imm8 byte (X64-RECOMP-IN-IMM8) #1518
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1518
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1488
Author: @kett1m
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:x64-recomp-in-imm8📝 Commits (1)
2f44dc4x64_recomp: in/out immediate ports need their imm8 byte (X64-RECOMP-IN-IMM8)📊 Changes
3 files changed (+28 additions, -1 deletions)
View changed files
📝
docs/mobile.md(+10 -0)📝
tests/test_x64_recomp.py(+17 -0)📝
tools/x64_recomp.py(+1 -1)📄 Description
The primary table in
tools/x64_recomp.pygivesE4,E5,E6andE7the operand shapesys, so the decoder consumed only the opcode and the instruction came out one byte long. Theseare the immediate-port forms of
inandout:E4 ib=in al, imm8E5 ib=in eax, imm8E6 ib=out imm8, alE7 ib=out imm8, eaxEach takes one immediate byte, so the instruction is two bytes; the walk read the port number as
the next opcode and the rest of the function came out at the wrong offset. The
EC-EFDX-portforms take no immediate and are unchanged.
Measurement
The image is
game_scarlett_master.exe, SHA-256e95020b2fa4a721db3df59fdecf75621730ac559d8835252f6c3b658d5a08993. REA measured the sectionranges with
gnu.objdumpsection_headers, evidenceev_e29cbdffd0dc7c46889b2a1f955011ce9f2795017233c97107ded73f9186dd90:.textVMA0x140001000, file0x400, size0x5f3f966.A per-instruction differential against GNU objdump over
.text: objdump's linear walk and thedecoder's walk read the same bytes and the instruction lengths are compared (26,674,180 objdump
instructions). On
main(b4b7756) it reports 52,638 mismatching instructions; the form is usedtwice, at RVA
0x55f2ed4(in $0x3d,%al) and RVA0x564652c(in $0x73,%al), each one byteshort of objdump's two. With this change the count is 52,636, both of those are gone, and no new
mismatch signature appears. Both sites sit inside
.pdatafunctions (RVAs0x55f2ed0and0x5646250).outwith an immediate port does not occur anywhere in.text, so it is covered bythe unit test rather than by a retail count.
Test
tests/test_x64_recomp.py::DecodeTests::test_in_out_immediate_port_consumes_imm8:E4 3d,E5 73,E6 40andE7 40are two bytes with the operand shapein al, imm8and its three siblings, andEC/ED/EE/EFstay one byte. Against the unfixed decoder the first case decodes to size 1.python -I tests/test_x64_recomp.py: 33 tests OK, 26 skipped (this host has noqemu-system-aarch64).
python -I tests/test_recomp_census.py: 11 tests OK.python3 -m compileall -q make_game.py tools testsexits 0.python -I scripts/check_no_game_data.py tools/x64_recomp.py tests/test_x64_recomp.py docs/mobile.mdexits0 with no output.
The per-function
.pdatawalk is noisy for this change, because the other length defects still onmainleave most functions misaligned, so it is not quoted as an impact figure.docs/mobile.mdrecords the measurement, the two offsets and the evidence ID. No game files, noGPU, nothing online. Tested on Linux (openSUSE Tumbleweed, Python 3.13.18, binutils 2.47), 12
cores.
AI-assisted (DeepSeek V4.1 Flash).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.