fix(relinker): reject guest modules in SELF containers #2605

Merged
elsi06 merged 1 commit from upstream-pr/2605 into main 2026-10-10 08:52:52 +00:00
elsi06 commented 2026-10-10 08:23:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by elsi06 on 2026-10-10T08:23:32Z.


What

Fixes #2599.

A bundled module in sce_module/, sce_modules/ or prx/ whose file starts with a SELF container magic (4f 15 3d 1d or 54 14 f5 ee) was filtered out like any other non-ELF file. The relink succeeded without it, and the module was missing at run time without any message.

GuestModuleBuilder now throws Guest module is a SELF container, not an ELF: <path> for such a file, the same way ElfReader already rejects a SELF executable (#184, #1317). The check also covers the recursive search for needed modules, where a file is only read when its name matches a missing DT_NEEDED entry. Other non-ELF files in the module directories are still skipped as before.

The relinker is not changed to unwrap SELF containers; it keeps taking decrypted ELF input only (see the closed #28). --exclude-sce-module still drops such a module, but the message does not suggest it because the flag is deprecated.

docs/user/USAGE.md states that a bundled module in a SELF container is an error.

Tested

macOS (Apple Silicon, AppleClang), relinker-only build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON) on main f6af6d11:

  • guest_module_directories gets SELF cases for both magics and for Linux and Windows output: the relink fails with exit code 2, names the module, and writes neither the executable nor app0/; with --exclude-sce-module libc.prx it succeeds and converts only the remaining module.
  • The new cases fail against main's GuestModuleBuilder.cpp and pass with this change.
  • All 89 relinker tests pass; tools/check_conventions.py --base origin/main passes.

Not tested with a real title; PPSA17641 from the issue was not available. Windows and Linux hosts were not run.

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 (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4809868463 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2605). Originally posted by [elsi06](https://github.com/elsi06) on 2026-10-10T08:23:32Z. --- ### What Fixes #2599. A bundled module in `sce_module/`, `sce_modules/` or `prx/` whose file starts with a SELF container magic (`4f 15 3d 1d` or `54 14 f5 ee`) was filtered out like any other non-ELF file. The relink succeeded without it, and the module was missing at run time without any message. `GuestModuleBuilder` now throws `Guest module is a SELF container, not an ELF: <path>` for such a file, the same way `ElfReader` already rejects a SELF executable (#184, #1317). The check also covers the recursive search for needed modules, where a file is only read when its name matches a missing `DT_NEEDED` entry. Other non-ELF files in the module directories are still skipped as before. The relinker is not changed to unwrap SELF containers; it keeps taking decrypted ELF input only (see the closed #28). `--exclude-sce-module` still drops such a module, but the message does not suggest it because the flag is deprecated. `docs/user/USAGE.md` states that a bundled module in a SELF container is an error. ### Tested macOS (Apple Silicon, AppleClang), relinker-only build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`) on `main` f6af6d11: - `guest_module_directories` gets SELF cases for both magics and for Linux and Windows output: the relink fails with exit code 2, names the module, and writes neither the executable nor `app0/`; with `--exclude-sce-module libc.prx` it succeeds and converts only the remaining module. - The new cases fail against `main`'s `GuestModuleBuilder.cpp` and pass with this change. - All 89 relinker tests pass; `tools/check_conventions.py --base origin/main` passes. Not tested with a real title; PPSA17641 from the issue was not available. Windows and Linux hosts were not run. ### 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 (attach them to this PR) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-10 08:23:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T08:23:42Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095645463 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2605#issuecomment-6095645463). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T08:23:42Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
adriadam10 commented 2026-10-10 08:52:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:52:49Z.


Checked the build and guest_module_directories on Linux (relinker scope); the new cases fail without the change and pass with it. Both SELF magics are rejected with the module path, --exclude-sce-module still works, and other non-ELF files are still skipped. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095858845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2605#issuecomment-6095858845). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T08:52:49Z. --- Checked the build and `guest_module_directories` on Linux (relinker scope); the new cases fail without the change and pass with it. Both SELF magics are rejected with the module path, `--exclude-sce-module` still works, and other non-ELF files are still skipped. Merging once CI is green.
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!2605
No description provided.