fix(relinker): decode ModRM for more two-byte opcodes #18

Closed
franpeza wants to merge 1 commit from upstream-pr/18 into main
franpeza commented 2026-09-26 20:28:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by franpeza on 2026-09-26T20:28:04Z.


The linear-sweep decoder did not know that these two-byte opcodes carry a ModRM byte:

Opcode Instruction
0F 0D prefetchw
0F B8 popcnt
0F BB btc r/m, r
0F C0 xadd r/m8, r8
0F C3 movnti
0F C4 pinsrw (ModRM + imm8)

When one of them appeared, the sweep desynchronised, and a later ModRM byte of 0x64 was reported as an unsupported fs: TLS access, which aborted relinking a commercial eboot.

Both Decode and DecodeInstruction now treat them as ModRM instructions, and pinsrw also as imm8.

Testing: found and verified while relinking on macOS in my fork. With this change the eboot relinks and runs past the point that used to fail. I have not built this branch on Linux or Windows; the change is limited to the decoder tables.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4649477450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18). Originally posted by [franpeza](https://github.com/franpeza) on 2026-09-26T20:28:04Z. --- The linear-sweep decoder did not know that these two-byte opcodes carry a ModRM byte: | Opcode | Instruction | |---|---| | `0F 0D` | `prefetchw` | | `0F B8` | `popcnt` | | `0F BB` | `btc r/m, r` | | `0F C0` | `xadd r/m8, r8` | | `0F C3` | `movnti` | | `0F C4` | `pinsrw` (ModRM + imm8) | When one of them appeared, the sweep desynchronised, and a later ModRM byte of `0x64` was reported as an unsupported `fs:` TLS access, which aborted relinking a commercial eboot. Both `Decode` and `DecodeInstruction` now treat them as ModRM instructions, and `pinsrw` also as imm8. Testing: found and verified while relinking on macOS in my fork. With this change the eboot relinks and runs past the point that used to fail. I have not built this branch on Linux or Windows; the change is limited to the decoder tables.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18
No description provided.