feat(relinker): support Intel trampolines in guest modules #151

Merged
MartinCajiao merged 1 commit from upstream-pr/151 into main 2026-09-30 16:24:47 +00:00
MartinCajiao commented 2026-09-29 16:10:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MartinCajiao on 2026-09-29T16:10:02Z.


What

Allow --to-intel to emit out-of-line trampolines for supported AMD-only instructions in guest PRX modules from sce_module or sce_modules. Windows reuses the executable PE trampoline builder; Linux appends stubs to the guest module's executable PT_LOAD segment. Both paths validate instruction bytes and rel32 jump ranges before patching.

This fixes the previous failure where the relinker rejected any guest module that needed a trampoline. It does not add support for AMD-only instructions that the converter cannot lower.

Tested

  • Windows 11, MSVC 2022: built the relinker target from current main.
  • ctest -R 'amd64_only|guest_intel' --output-on-failure: 3/3 passed.
  • New synthetic integration test relinks a guest PRX with two trampoline sites for both Windows PE and Linux ELF output. It checks executable placement, patched jumps, and return addresses; it also covers a guest PRX with no trampoline sites.
  • No real PS5 game was tested. Linux output was inspected by the integration test on Windows; it was not executed on Linux.

Checklist

  • Based on current main; no other open PR implements this guest PRX trampoline path
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths still throw
  • No notes, investigation .md files or images added
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4679634981 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/151). Originally posted by [MartinCajiao](https://github.com/MartinCajiao) on 2026-09-29T16:10:02Z. --- ### What Allow `--to-intel` to emit out-of-line trampolines for supported AMD-only instructions in guest PRX modules from `sce_module` or `sce_modules`. Windows reuses the executable PE trampoline builder; Linux appends stubs to the guest module's executable PT_LOAD segment. Both paths validate instruction bytes and rel32 jump ranges before patching. This fixes the previous failure where the relinker rejected any guest module that needed a trampoline. It does not add support for AMD-only instructions that the converter cannot lower. ### Tested - Windows 11, MSVC 2022: built the `relinker` target from current `main`. - `ctest -R 'amd64_only|guest_intel' --output-on-failure`: 3/3 passed. - New synthetic integration test relinks a guest PRX with two trampoline sites for both Windows PE and Linux ELF output. It checks executable placement, patched jumps, and return addresses; it also covers a guest PRX with no trampoline sites. - No real PS5 game was tested. Linux output was inspected by the integration test on Windows; it was not executed on Linux. ### Checklist - [x] Based on current `main`; no other open PR implements this guest PRX trampoline path - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths still throw - [x] No notes, investigation `.md` files or images added - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-09-30 16:12:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-30T16:12:57Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#183 core/relinker/CMakeLists.txt L159
#184 core/relinker/CMakeLists.txt L159
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5915145198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/151#issuecomment-5915145198). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-30T16:12:57Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #183 | `core/relinker/CMakeLists.txt` [L159](https://github.com/boykopovar/AnyPS5/blob/d2754f6f564aa4fd25e8cdec3d6535abd18b6f49/core/relinker/CMakeLists.txt#L159) | | | | #184 | `core/relinker/CMakeLists.txt` [L159](https://github.com/boykopovar/AnyPS5/blob/d2754f6f564aa4fd25e8cdec3d6535abd18b6f49/core/relinker/CMakeLists.txt#L159) | | |
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!151
No description provided.