fix(relinker): compare guest module directories by identity #6156

Merged
MarcZX10 merged 1 commit from upstream-pr/6156 into main 2026-10-17 05:00:54 +00:00
MarcZX10 commented 2026-10-14 23:45:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T23:45:53Z.


What

Fixes #6136. Compare guest module directories by filesystem identity when checking for duplicate module directories and when rejecting an executable inside one. This catches case aliases on case-insensitive filesystems and symlink aliases, while preserving distinct case-sensitive paths on Linux. Add regression coverage for both checks.

This PR carries Jota's commit from jotitadev:fix/relinker-guest-module-path-identity, retaining Jota as its author. It follows the invitation in #6136 to open the prepared fix.

Tested

Linux x86-64, GCC 12.2, Release, relinker-only build:

  • cmake --build /tmp/anyps5-path-identity-build --parallel 8 passed.
  • ctest --test-dir /tmp/anyps5-path-identity-build -R '^(guest_module_dir|guest_module_identity|relinker_executables)$' --output-on-failure: 3/3 passed. On this case-sensitive filesystem, the tests exercised symlink identity and confirmed different-case paths remain distinct.
  • python3 tools/check_conventions.py --base upstream/main passed.
  • The open-PR overlap check found no overlap.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4866068279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6156). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T23:45:53Z. --- ### What Fixes #6136. Compare guest module directories by filesystem identity when checking for duplicate module directories and when rejecting an executable inside one. This catches case aliases on case-insensitive filesystems and symlink aliases, while preserving distinct case-sensitive paths on Linux. Add regression coverage for both checks. This PR carries Jota's commit from `jotitadev:fix/relinker-guest-module-path-identity`, retaining Jota as its author. It follows the invitation in #6136 to open the prepared fix. ### Tested Linux x86-64, GCC 12.2, Release, relinker-only build: - `cmake --build /tmp/anyps5-path-identity-build --parallel 8` passed. - `ctest --test-dir /tmp/anyps5-path-identity-build -R '^(guest_module_dir|guest_module_identity|relinker_executables)$' --output-on-failure`: 3/3 passed. On this case-sensitive filesystem, the tests exercised symlink identity and confirmed different-case paths remain distinct. - `python3 tools/check_conventions.py --base upstream/main` passed. - The open-PR overlap check found no overlap. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
jotitadev commented 2026-10-15 00:31:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T00:31:41Z.

Review: COMMENTED


Thanks for carrying this. I checked that the diff at 006e17681 is identical to my commit 6e3b80d65 apart from the rebase context (blob ids and hunk offsets), and ran it on the case-insensitive filesystem this fix is for.

Machine: Apple M2 Max, macOS 27.2, APFS (case-insensitive), Xcode 27 toolchain, relinker-only Release build.
Head: 006e17681. Base: main @ ab9a47684 (the PR's files are unchanged on main since its base 2559e9623).

Build Tests only (base code) With the fix
arm64, Python 3.14 guest_module_dir and relinker_executables fail 3/3 pass
x86_64 under Rosetta, /usr/bin/python3 3.9.6 same two fail 3/3 pass

(guest_module_dir, guest_module_directories, relinker_executables.)

Without the fix, on APFS the case-alias branches are the ones that fail, which is the point of the PR:

  • guest_module_dir: --module-dir SCE_MODULE next to the default sce_module is accepted instead of rejected as Duplicate guest module directory.
  • relinker_executables: --module-dir Picker --executable picker/picker.bin is not refused as in a guest module directory; the relinker goes on to convert the module as an executable.

So the insensitive paths of both tests do run and catch the regression on macOS; on Linux only the symlink paths can.

Full relinker-only suite with the PR: arm64 163/163; x86_64 + Python 3.9.6 159/163, with the same 4 failures as main (pr_overlap_encoding, stubgen_stdout_newlines, release_package, linux_fixed_base).

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5526480062 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6156#pullrequestreview-5526480062). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-15T00:31:41Z. **Review:** COMMENTED --- Thanks for carrying this. I checked that the diff at `006e17681` is identical to my commit `6e3b80d65` apart from the rebase context (blob ids and hunk offsets), and ran it on the case-insensitive filesystem this fix is for. **Machine:** Apple M2 Max, macOS 27.2, APFS (case-insensitive), Xcode 27 toolchain, relinker-only Release build. **Head:** `006e17681`. **Base:** `main` @ `ab9a47684` (the PR's files are unchanged on `main` since its base `2559e9623`). | Build | Tests only (base code) | With the fix | |---|---|---| | arm64, Python 3.14 | `guest_module_dir` and `relinker_executables` fail | 3/3 pass | | x86_64 under Rosetta, `/usr/bin/python3` 3.9.6 | same two fail | 3/3 pass | (`guest_module_dir`, `guest_module_directories`, `relinker_executables`.) Without the fix, on APFS the case-alias branches are the ones that fail, which is the point of the PR: - `guest_module_dir`: `--module-dir SCE_MODULE` next to the default `sce_module` is accepted instead of rejected as `Duplicate guest module directory`. - `relinker_executables`: `--module-dir Picker --executable picker/picker.bin` is not refused as `in a guest module directory`; the relinker goes on to convert the module as an executable. So the insensitive paths of both tests do run and catch the regression on macOS; on Linux only the symlink paths can. Full relinker-only suite with the PR: arm64 163/163; x86_64 + Python 3.9.6 159/163, with the same 4 failures as `main` (`pr_overlap_encoding`, `stubgen_stdout_newlines`, `release_package`, `linux_fixed_base`). Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
ideabsassistenza commented 2026-10-15 06:55:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ideabsassistenza on 2026-10-15T06:55:55Z.


Independent Windows validation of head 006e1768128d23f491e78d51c709ecf58d97ed2c, compared with its parent 2559e96233b2c83bc412a621904a8d87e9e456f9.

Windows 11 x64 (build 22631), case-insensitive filesystem, WinLibs GCC 15.2.0 UCRT r7, CMake 4.4.4/Ninja, CPython 3.12.14; Release relinker-only build.

  • With the PR: guest_module_dir, relinker_executables and guest_module_identity pass, 3/3, in 28.10 s total (slowest group 22.27 s).
  • Negative control: keep the exact PR tests and restore the three changed production files from the parent. guest_module_dir fails at the SCE_MODULE duplicate assertion; relinker_executables fails at --module-dir Picker --executable picker/picker.bin, reaching Invalid string or symbol table instead of the intended directory guard. guest_module_identity still passes.
  • An additional CLI matrix exercises both ELF and Windows output: default/custom case-alias duplicates, both case spellings of the executable parent, directory symlinks, Windows junctions, exact-spelling rejection controls and distinct-directory acceptance. All 22/22 checks pass with the PR, with no skips. The parent misses the expected guards in all 16 alias checks; the six ordinary-path controls pass on both versions. Directory symlink/junction identity was checked with os.path.samefile; these checks supplement the symlink branches the PR tests skip on Windows.

Only the relinker was built. The upstream focused tests execute their tiny generated Windows fixtures; the additional matrix only converts/inspects files. No full-library build, full test suite, game/homebrew, GPU, Linux/macOS execution or current-main composition was tested. windows_fixed_base was not run.

AI-assisted testing and reporting: OpenAI Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6186360965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6156#issuecomment-6186360965). Originally posted by [ideabsassistenza](https://github.com/ideabsassistenza) on 2026-10-15T06:55:55Z. --- Independent Windows validation of head `006e1768128d23f491e78d51c709ecf58d97ed2c`, compared with its parent `2559e96233b2c83bc412a621904a8d87e9e456f9`. Windows 11 x64 (build 22631), case-insensitive filesystem, WinLibs GCC 15.2.0 UCRT r7, CMake 4.4.4/Ninja, CPython 3.12.14; Release relinker-only build. - With the PR: `guest_module_dir`, `relinker_executables` and `guest_module_identity` pass, **3/3**, in 28.10 s total (slowest group 22.27 s). - Negative control: keep the exact PR tests and restore the three changed production files from the parent. `guest_module_dir` fails at the `SCE_MODULE` duplicate assertion; `relinker_executables` fails at `--module-dir Picker --executable picker/picker.bin`, reaching `Invalid string or symbol table` instead of the intended directory guard. `guest_module_identity` still passes. - An additional CLI matrix exercises both ELF and Windows output: default/custom case-alias duplicates, both case spellings of the executable parent, directory symlinks, Windows junctions, exact-spelling rejection controls and distinct-directory acceptance. All **22/22** checks pass with the PR, with no skips. The parent misses the expected guards in all 16 alias checks; the six ordinary-path controls pass on both versions. Directory symlink/junction identity was checked with `os.path.samefile`; these checks supplement the symlink branches the PR tests skip on Windows. Only the relinker was built. The upstream focused tests execute their tiny generated Windows fixtures; the additional matrix only converts/inspects files. No full-library build, full test suite, game/homebrew, GPU, Linux/macOS execution or current-main composition was tested. `windows_fixed_base` was not run. AI-assisted testing and reporting: OpenAI Codex.
github-actions[bot] commented 2026-10-15 11:13:42 +00:00 (Migrated from github.com)

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


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
PR 6314 core/relinker/main.cpp L208-217
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6190720945 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6156#issuecomment-6190720945). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T11:13:42Z. --- <!-- 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 | |---|---|---|---| | [PR 6314](https://www.github.com/boykopovar/AnyPS5/pull/6314) | `core/relinker/main.cpp` [L208-217](https://github.com/boykopovar/AnyPS5/blob/db7176f8a8fd9be128e556c261ce6c84e2699eed/core/relinker/main.cpp#L208-L217) | | |
MarcZX10 commented 2026-10-16 15:34:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:34:23Z.


Thanks for the independent Windows 11 validation. The comparison against the parent confirms the module-directory identity change on Windows as well.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218948671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6156#issuecomment-6218948671). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:34:23Z. --- Thanks for the independent Windows 11 validation. The comparison against the parent confirms the module-directory identity change on Windows as well.
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!6156
No description provided.