fix(relinker): bind Linux guest imports by declared module identity #2212

Merged
exefer merged 2 commits from upstream-pr/2212 into main 2026-10-11 08:44:27 +00:00
exefer commented 2026-10-09 11:45:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by exefer on 2026-10-09T11:45:08Z.


What

On Linux, any executable import or guest-module import whose NID two bundled modules export is a hard error, even when the import declares one of them. Windows already binds such imports to their declared module (#684).

Executable imports shared between providers bind when exactly one provider's filename or SONAME is in the executable's DT_NEEDED list. Guest-module imports shared between providers bind when the declared library resolves to one of the providers, on both platforms (the Windows-only filter already did this on Windows). Anything else still throws as before: undeclared, host-declared and multiply-declared imports are unchanged.

Demonstrated by Wobbly Life (PPSA29413, Unity; bring-up: #2211): its executable imports M4YYbSFfJ8g declared from the needed Il2cppUserAssemblies.prx while Media/Plugins/kitt_support-PS5-shipping.prx incidentally exports the same NID, and kitt_webkit-PS5-shipping.prx imports smbQukfxYJM declared from kitt_support.prx while Il2cppUserAssemblies.prx exports it too.

Tested

  • Linux (CachyOS), GCC 16.2.1, Intel i5-12400 + NVIDIA RTX 3060 Ti (615.71.09), ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON: 110/110 relinker tests pass, including the existing ambiguity regressions (fixtures declare nothing, so they still throw).
  • PPSA29413 relinked with --registry --module-dir Media/Plugins --module-dir Media/Modules --to-intel: converts all bundled, needed and plugin modules (was: hard error). Note: current main no longer discovers needed modules outside the module directories (41126bfa), so Media/Modules is now passed explicitly like Media/Plugins.

Checklist

  • Based on current main; no other open PR implements the same functions (checked: #684 is Windows-only, #1529 covers host-vs-guest, #1503 covers identities, none binds Linux guest-vs-guest by declared module)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799952865 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2212). Originally posted by [exefer](https://github.com/exefer) on 2026-10-09T11:45:08Z. --- ### What On Linux, any executable import or guest-module import whose NID two bundled modules export is a hard error, even when the import declares one of them. Windows already binds such imports to their declared module (#684). Executable imports shared between providers bind when exactly one provider's filename or SONAME is in the executable's `DT_NEEDED` list. Guest-module imports shared between providers bind when the declared library resolves to one of the providers, on both platforms (the Windows-only filter already did this on Windows). Anything else still throws as before: undeclared, host-declared and multiply-declared imports are unchanged. Demonstrated by Wobbly Life (PPSA29413, Unity; bring-up: #2211): its executable imports `M4YYbSFfJ8g` declared from the needed `Il2cppUserAssemblies.prx` while `Media/Plugins/kitt_support-PS5-shipping.prx` incidentally exports the same NID, and `kitt_webkit-PS5-shipping.prx` imports `smbQukfxYJM` declared from `kitt_support.prx` while `Il2cppUserAssemblies.prx` exports it too. ### Tested - Linux (CachyOS), GCC 16.2.1, Intel i5-12400 + NVIDIA RTX 3060 Ti (615.71.09), `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`: **110/110 relinker tests pass**, including the existing ambiguity regressions (fixtures declare nothing, so they still throw). - PPSA29413 relinked with `--registry --module-dir Media/Plugins --module-dir Media/Modules --to-intel`: converts all bundled, needed and plugin modules (was: hard error). Note: current `main` no longer discovers needed modules outside the module directories (41126bfa), so `Media/Modules` is now passed explicitly like `Media/Plugins`. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (checked: #684 is Windows-only, #1529 covers host-vs-guest, #1503 covers identities, none binds Linux guest-vs-guest by declared module) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
rmz-24 commented 2026-10-09 12:45:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-09T12:45:31Z.


Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON, full build plus libs. ea73d5ed cherry-picked onto current main d70b8998 (applies cleanly).

  • guest_module_identity, guest_symbol_names, guest_module_dir and guest_module_directories pass, with their Windows PE execution branches.
  • Full ctest: 512/512.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081157609 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2212#issuecomment-6081157609). Originally posted by [rmz-24](https://github.com/rmz-24) on 2026-10-09T12:45:31Z. --- Windows run: Windows 11 Pro 25H2 (10.0.26200.9457), RTX 5060 Ti (NVIDIA 617.42), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `-DANYPS5_ENABLE_SPIRV_TOOLS=ON`, full build plus `libs`. ea73d5ed cherry-picked onto current `main` d70b8998 (applies cleanly). - `guest_module_identity`, `guest_symbol_names`, `guest_module_dir` and `guest_module_directories` pass, with their Windows PE execution branches. - Full ctest: 512/512. AI-assisted: yes
SleglJan commented 2026-10-09 19:35:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-09T19:35:06Z.


A second title for this, on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1): Until Dawn (PPSA15421 v01.005.000, Unreal, 7 Sony modules in sce_module/ and 28 Wwise plugins in prx/), relinker --registry on the unwrapped executable in all three cases:

  • main f8c2f072: refused with Ambiguous guest import BfBDZGbti7A (sceAgcGetIsTrinityMode, declared from libSceAgc), exported by both bundled libSceFontGsm.prx and libSceJobManager.prx: the host-declared case #1529 covers.
  • The carried #846, #1503 and #1529 on d70b8998 without the last commit (2d262e84, a relinker-only build): refused with Ambiguous guest import P330P3dFF68 (Need_sceLibc, declared from libc.prx), exported by libc.prx and all 27 ak*/auro/masteringsuite plugins in prx/; only libc.prx is among the executable's DT_NEEDED entries, which is the rule this PR adds.
  • ea73d5ed (Release build, full): relinks with all 35 guest modules (prx/ is scanned as on main; passing --module-dir prx as well is refused as a duplicate directory), 644 imports implemented, 54 throwing stubs, 1 absent import. Given 8 s in a bubblewrap sandbox, the host loader stops at that absent import, sceAudioPropagationSourceSetAudioPath (tKSmk2JsMAA, the export #1947 adds), so both ambiguities are gone.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6087906485 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2212#issuecomment-6087906485). Originally posted by [SleglJan](https://github.com/SleglJan) on 2026-10-09T19:35:06Z. --- A second title for this, on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1): Until Dawn (PPSA15421 v01.005.000, Unreal, 7 Sony modules in `sce_module/` and 28 Wwise plugins in `prx/`), `relinker --registry` on the unwrapped executable in all three cases: - `main` f8c2f072: refused with `Ambiguous guest import BfBDZGbti7A` (`sceAgcGetIsTrinityMode`, declared from `libSceAgc`), exported by both bundled `libSceFontGsm.prx` and `libSceJobManager.prx`: the host-declared case #1529 covers. - The carried #846, #1503 and #1529 on d70b8998 without the last commit (2d262e84, a relinker-only build): refused with `Ambiguous guest import P330P3dFF68` (`Need_sceLibc`, declared from `libc.prx`), exported by `libc.prx` and all 27 `ak*`/`auro`/`masteringsuite` plugins in `prx/`; only `libc.prx` is among the executable's `DT_NEEDED` entries, which is the rule this PR adds. - ea73d5ed (Release build, full): relinks with all 35 guest modules (`prx/` is scanned as on `main`; passing `--module-dir prx` as well is refused as a duplicate directory), 644 imports implemented, 54 throwing stubs, 1 absent import. Given 8 s in a bubblewrap sandbox, the host loader stops at that absent import, `sceAudioPropagationSourceSetAudioPath` (`tKSmk2JsMAA`, the export #1947 adds), so both ambiguities are gone. AI-assisted: yes (Claude Code).
adriadam10 commented 2026-10-11 08:42:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T08:42:02Z.


Checked on Linux, merged onto current main: relinker build and ctest 99/99 pass. Windows 512/512 and a second title (Until Dawn) are reported above.

The PR had no test, so I added one commit on top:

  • test_guest_symbol_names.py: two guest modules export the same NID. With only one in DT_NEEDED and the import declared from it, the relink succeeds and the import becomes NID#guest. With both in DT_NEEDED, it still throws Ambiguous guest import. The test fails with the GuestModuleBuilder.cpp change reverted.

Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107234198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2212#issuecomment-6107234198). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T08:42:02Z. --- Checked on Linux, merged onto current main: relinker build and ctest 99/99 pass. Windows 512/512 and a second title (Until Dawn) are reported above. The PR had no test, so I added one commit on top: - `test_guest_symbol_names.py`: two guest modules export the same NID. With only one in `DT_NEEDED` and the import declared from it, the relink succeeds and the import becomes `NID#guest`. With both in `DT_NEEDED`, it still throws `Ambiguous guest import`. The test fails with the `GuestModuleBuilder.cpp` change reverted. 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!2212
No description provided.