feat(relinker): trap exact SDK syscall stubs on request #3804

Merged
MarcZX10 merged 1 commit from upstream-pr/3804 into main 2026-10-11 22:05:38 +00:00
MarcZX10 commented 2026-10-11 16:54:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T16:54:43Z.


What

Add an opt-in --trap-sdk-syscall-stubs mode for the exact numbered and generic syscall wrapper byte patterns used by ps5-payload-dev SDK libc. In executable segments and bundled guest modules, the mode replaces only each recognized syscall instruction with UD2. All unrecognized syscall instructions remain relink errors, and the existing default scanner remains strict. The option cannot be combined with --skip-syscall-check.

This lets unused SDK wrappers pass relinking while preserving a runtime illegal-instruction failure if one is reached. It does not implement FreeBSD syscalls. The mode is documented as debugging-only.

Resolves #2136.

Tested

  • Linux x86_64, relinker-only Release build.
  • Full relinker-only CTest suite: 115/115 passed.
  • Focused CLI, scanner and bundled guest-module trap tests: 3/3 passed after the final build.
  • python3 tools/check_conventions.py --base upstream/main passed; git diff --check passed.
  • No catalog title was run as part of this change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820720616 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3804). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T16:54:43Z. --- ### What Add an opt-in `--trap-sdk-syscall-stubs` mode for the exact numbered and generic syscall wrapper byte patterns used by ps5-payload-dev SDK libc. In executable segments and bundled guest modules, the mode replaces only each recognized `syscall` instruction with `UD2`. All unrecognized syscall instructions remain relink errors, and the existing default scanner remains strict. The option cannot be combined with `--skip-syscall-check`. This lets unused SDK wrappers pass relinking while preserving a runtime illegal-instruction failure if one is reached. It does not implement FreeBSD syscalls. The mode is documented as debugging-only. Resolves #2136. ### Tested - Linux x86_64, relinker-only Release build. - Full relinker-only CTest suite: 115/115 passed. - Focused CLI, scanner and bundled guest-module trap tests: 3/3 passed after the final build. - `python3 tools/check_conventions.py --base upstream/main` passed; `git diff --check` passed. - No catalog title was run as part of this change. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-11 22:05:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T22:05:34Z.


Checked build and the relinker ctest suite (102/102) on the PR merged onto main; the new CLI, scanner and guest-module trap tests fail without the change. Unknown syscalls still fail, the default scanner is unchanged, patches go through result.Patches and are bounds-checked. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114353524 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3804#issuecomment-6114353524). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T22:05:34Z. --- Checked build and the relinker ctest suite (102/102) on the PR merged onto main; the new CLI, scanner and guest-module trap tests fail without the change. Unknown syscalls still fail, the default scanner is unchanged, patches go through `result.Patches` and are bounds-checked. Merging.
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!3804
No description provided.