relinker: Windows conversion fails since #2238 on titles with XOP code (decoder has no XOP support) #2559
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?
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T05:35:06Z.
Since #2238 (
ba525633, "root code addresses taken by RIP-relative LEA"), the Windows conversion of three homebrew catalog titles fails:Linux output (
relinker eboot.elf app.elf) still converts them, so Linux-only catalog runs don't show it. Stremio Plus and OpenNOW converted onmainc72d5ce1. Agit bisectofcore/relinkerbetweenc72d5ce1andbc40a6b5points toba525633, and the parent of that commit converts both. (PPSA99420 failed earlier on the now-fixed emptyPT_TLScheck.)Cause. The x86 decoder has no XOP (AMD
8Fescape) support. It reads8F E8 ..asPOP r/mwith a 2-byte length. In Stremio Plus, a CPU-dispatch routine at0x1c135d7stores function pointers withlea r8, [rip+...]to0x1ce4470and0x1ce4560. Those are real function starts, using XOPvpperm(8f e8 f8 a3 4a 10 60,8f e8 c0 a3 ba 70 ff ff ff 30, …). #2238 now roots them, and decoding them loses the instruction boundaries. The walk then lands on the last byte ofvmovdqa %xmm1,0x40(%rdi)at0x1ce450b, and the nextvmovq 0x64(%rsi),%xmm0has a0x64displacement byte, which the overlap check takes for an FS prefix. The XOP paths are never executed on a PS5 (Zen 2 has no XOP), but they have to decode.Fix, ready to cherry-pick.
AchrafReyani:fix/relinker-decode-xop(2253d53d, one commit onbc40a6b5). I can't open it as a PR because of the intake check.X64InstructionDecodertreats8Ffollowed by a map field (low 5 bits) of 8 or more as a three-byte XOP prefix.8Fcan only bePOP r/mwith ModRM.reg = 0, so its next byte's low 5 bits are below 8. The prefix is followed by an opcode and a ModRM operand, plus an 8-bit immediate in map 8 or a 32-bit one in map 0Ah.DecodeInstruction, so XOP RIP-relative operands are reported like VEX ones.amd64_only_convertergains XOP lengths: register, disp8 and disp32 forms, maps 8, 9 and 0Ah, with the two instructions above from the title. It also checks that8F C0,41 8F 07and8F 05 disp32still decode asPOP, and that an XOP RIP-relative operand is reported. Without the decoder change these checks fail ("decoded with the wrong length").Checked on Windows (WinLibs GCC 15.2.0, relinker-only Release build):
ctestpasses 55/55.--windows.mainbc40a6b5and with the branch. These three are the only titles whose result changes.The titles were relinked only, not executed.
Found with Claude Code.
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T06:04:07Z.
Full build of the branch on the fork (run 38027642514) merged into
mainbc40a6b5:guest_video_out_wqhd_detectionwith0xc0000374, the VideoOut heap corruption of #2540.I also relinked the three titles with
--windows --to-intel. They convert with the branch, so the XOP code (CPU-dispatched, never run on a PS5) doesn't trip the AMD-only converter. Onmainthey fail the same way as without--to-intel.