Skip to content

fix(relinker): share guest modules between executables that need different system libraries - #5443

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
SandstromPL:fix/relinker-executable-module-host-needed
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
SandstromPL:fix/relinker-executable-module-host-needed

Conversation

@SandstromPL

Copy link
Copy Markdown
Contributor

What

--executable (#4786) converts a title's other executables in the same run. Every guest module must come out byte-identical for each of them. On Linux and macOS that could fail when the executables need different system libraries that the modules do not, or the same ones in another order. In GuestModuleBuilder, every guest module's DT_NEEDED (LC_LOAD_DYLIB on macOS) got the converting executable's own system libraries: hostLibraries starts with the executable's DT_NEEDED. So a module's bytes could depend on which executable converted it.

This is the error in blocker 1 of METAL GEAR SOLID: Peace Walker - Master Collection Version (PPSA18216, #5268) on Linux. relinker --executable mgspw/mgspw.elf fails with Guest modules convert differently for mgspw/mgspw.elf, so it cannot share them with the input executable. The report guesses that the modules each executable needs at start-up differ. On Linux and macOS that changes only the executable's DT_NEEDED, not the modules. On Windows it changes the modules, and it stays an error there, as #4786 describes.

Guest modules now list only the system libraries that the guest modules themselves need, so that list no longer depends on the executable. It is the union of the modules' own dependencies, in the order of the module paths, keeping the existing libSceLibcInternal.prx → libc.prx rule.

  • The executable's own DT_NEEDED is unchanged. It still lists its own system libraries and the modules' ones, so the libraries loaded at start-up are the same.
  • Windows output is unchanged.
  • On macOS, dyld initializes a module's own dependencies before the module. A system library that only the executable lists may now initialize after the guest modules. macOS was not run here.

Two inputs still depend on the executable, and they still give the error:

Tested

Ubuntu 24.04, GCC 13.3, Release with BUILD_TESTING=ON, on main dacd785. Locally, the libusb lines were removed from CMakeLists.txt, because the libusb submodule isn't checked out here.

relinker_executables gains two cases, each converted for Linux, macOS (--macos) and Windows. In both, the input executable needs libScePad.prx and libSceVideoOut.prx, and picker/picker.bin needs either:

  • libScePad.prx only, or
  • the same two libraries in the other order.

Both cases must convert and share one bundled.prx.guest.prx. On Linux, the module's DT_NEEDED must not list the executables' libraries, and each executable must keep its own.

On main, the Linux case fails with FAIL: Guest modules convert differently for picker/picker.bin, so it cannot share them with the input executable.

guest_host_libc gains a case where only a guest module needs libSceLibcInternal.prx. The module must list libSceLibcInternal.prx and libc.prx, but not the executable's libkernel.prx, and the executable keeps all three. On main the module also lists libkernel.prx. With the module-side libc.prx line deleted, the module lists only libSceLibcInternal.prx, and the test fails.

A wider run converted 15 cases with a module that needs no system library: a picker whose list is identical, a subset, a superset, reordered or empty, each for Linux, macOS and Windows. On main, every Linux and macOS case with a differing list fails with that error, and Windows passes. With this change all 15 pass.

Other checks:

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 (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
  • Unblocks: none (blocker 1 of PPSA18216 METAL GEAR SOLID: Peace Walker - Master Collection Version (PPSA18216) #5268, if the system libraries are the only difference there; its blockers 2 and 3 remain)
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code); I reviewed and tested every line

🤖 Generated with Claude Code

…erent system libraries

On Linux and macOS every guest module listed the converting executable's
own DT_NEEDED system libraries, so its bytes could depend on which
executable converted it. --executable then failed with "Guest modules
convert differently" when the executables need different system
libraries that the modules do not, or the same ones in another order.
It is the error METAL GEAR SOLID: Peace Walker (PPSA18216, boykopovar#5268)
reports on Linux for its launcher and mgspw.elf. Guest modules now list
only the system libraries the guest modules themselves need, with the
libSceLibcInternal.prx to libc.prx rule. The executable's own DT_NEEDED
is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneandonlydean oneandonlydean self-assigned this Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

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
#5695 core/relinker/relinker/tests/test_executables.py L73

@oneandonlydean
oneandonlydean merged commit 6f12584 into boykopovar:main Oct 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants