fix(relinker): preserve weak imports in guest module registries #6240
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6240"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-15T06:41:12Z.
What
Guest-module registries dropped the ELF weak binding even though executable registries already preserved it. Carry the binding into each relocation record and emit
"weak": truefor weak imports. Strong records retain their existing shape. This corrects diagnostic metadata; it does not change guest runtime resolution.Tested
Windows 11 x64 (build 26200), WinLibs MinGW-w64 GCC 15.2.0 r7, CMake 4.3.1, Ninja 1.13.2, Python 3.13.7. Baseline:
d92a8dad390af1807cc91622b924252141816a5a. Branch:fix/guest-registry-weak-imports. Commit:96f506f8707ce1cd3cb4beebd56de44227f16990. Committed-object conventions check passed.The modified
test_guest_registry.pyfails on unchanged main because the weak field is absent, and passes fixed for Linux and Windows output, including GLOB_DAT/JUMP_SLOT records and strong imports. The full relinker CTest directory passed 126 tests with onelong_pathsskip. After preserving the old strong-record shape, the affectedguest_registry,call_registryandrelinker_conversionchecks passed again, and the real homebrew registry comparison was rerun.input_magicand other Python-backed tests were registered. Native Linux/macOS and full-library tests were not run locally.Documentation follow-up:
00c704697b00e28bf8ed8b84b379cf2e4fb6da19moves the weak-import paragraph below the class table without changing its wording. Windows x64 content checks andgit diff --checkpass;python tools/check_conventions.py --base origin/mainpasses on this commit. Runtime regression testing is not applicable to this paragraph relocation; the behavioral results above remain tied to96f506f8707ce1cd3cb4beebd56de44227f16990.Homebrew evidence
Converted the real Mari0 bundle with baseline and fixed relinkers using
--windows --registry --trap-sdk-syscall-stubs --module-dir .. Both used a separate, otherwise byte-identical copy with an added emptysce_moduledirectory; this comparison does not depend on the explicit-directory fix. Both conversions exit 0.Read the shipped
libOSMesa.so.8dynamic symbol table as the binding oracle. The baseline module registry omits weak metadata; the fixed registry correctly marks all ten weak-import relocation records, includingkernel_mprotect,__dlopen,__dlsym,__dladdr,__dlclose,__dlerrorand the fourZSTD_trace_*imports. All other registry fields remain identical, and strong records retain their old shape. This proves a diagnostic metadata correction, not improved module loading.Package: Mari0 1.6.2 from websrv v0.34. Original layout and input hashes were checked before and after conversion; all inputs remained unchanged.
e0331ed5a22e7fe72843d268cd2c8b297d761a75b7c83d828f5cc58a82a72ce354bcc91670fd759bbd3488284dce351b6421cb83016e9ad8da6b5186da067a39128d2ab20b980b96decb1f20a9ed57d10cc922605259666b63efa52963920f0aNo generated homebrew executable was run. No game startup, gameplay, GPU, commercial-title, or physical-PS5 result is claimed. Synthetic regression tests additionally execute their existing small Windows fixtures; that is separate from homebrew conversion evidence.
Baseline relinker SHA-256:
a249e5a38abe9f338f09d6ea09182b5a39cd156dada6771984b85e315fda67c5. Tested fixed relinker SHA-256:8b405bc0bb19048234375d53cad08db350828f2b14432e40ba6ac57736e2f3a8.Local logs, exact argv, per-file hashes, source patches, before/after failures and JSON results:
C:/Users/arjen/AppData/Local/Temp/anyps5-three-homebrew-20261014(homebrew-report.json, regression logs and CTest logs). The commands and decisive results are included above so this report does not depend on access to that local folder.Open PR comparison
Complete paginated inventory: 544 open PRs; main
d92a8dad390af1807cc91622b924252141816a5a. Complete changed-file lists and tree-only merge previews used that main as the explicit common base. This change merges with main and both other proposed changes. 21 relevant comparisons merge cleanly; 23 remain inconclusive because the other PR already conflicts with main. No conflict-free claim is made for those PRs.Exact compared heads and shared-file results
f9f6872b8d293ee0353e2f2dd95c49840da209addocs/user/USAGE.md1800d3892bec857b254ca8c55e912e325e1c6711docs/user/USAGE.md09afe38730d7b9d40d57b8aa9e13777012d170a3docs/user/USAGE.md657f16ea286035a8615e2d56614a354cd4559e31docs/user/USAGE.mdc690012ce1b6f73ab985c061509e7cbfb41127c2docs/user/USAGE.md78b906fb67a8edff3969f60d26ced129f981139ecore/relinker/relinker/src/guest/GuestModuleBuilder.cpp62022e9362a27432e007cea132ecd9ca0909bb2bdocs/user/USAGE.md8997cac1b840998182bfc6afc32f70c91f5f3d56core/relinker/relinker/src/guest/GuestModuleBuilder.cpp1f98703dd07a6257c84ea485594d92f5a8e84fbadocs/user/USAGE.md3339ddd3af77cfc336148966657c0d14e87b6ae1docs/user/USAGE.md569ff84ea2589a9c886dca37b5c9ddcea70049bddocs/user/USAGE.mde4036135ed0823b866969e6e7e688712b0f57fccdocs/user/USAGE.md9acd5dcc07d8149020bf50fbd5e09f7633a2613fdocs/user/USAGE.mdacc228ab4a54fbdc0c816c22b52b82968e42649bdocs/user/USAGE.md0b10e2467adb8f780005793b04be71fce4ce36b3core/relinker/relinker/src/guest/GuestModuleBuilder.cpp48685f40e1ff769f4fbbe46d63d0170fcbf680eecore/relinker/relinker/src/guest/GuestModuleBuilder.cpp,core/relinker/relinker/tests/test_guest_registry.py2d14128a29ec22d25e0cb308777dd46894a73170docs/user/USAGE.mda38314933da4209c8ee36faafa3e7c6a8f7976eacore/relinker/relinker/src/guest/GuestModuleBuilder.cppd4fa8367daa0fd826853f440d23c3a604af43449docs/user/USAGE.md01f2073d06385ca2adb537d4996ad61e8255bd2edocs/user/USAGE.mdab0e383aca0fd9c8d873293ec0ffa170d750baa4docs/user/USAGE.md82de94cbedc5461de6af731b2a5a9838aca66e48docs/user/USAGE.mdb05e5cf8ecf4f410750c38a6f281f273babb816ddocs/user/USAGE.md2d6b8ef4341e21d78686bfba9da9a5c6bb14d629docs/user/USAGE.md1263d7065489fd6b7a15ebbecb1fcf0ee72d21f9docs/user/USAGE.md07713af3078fcb4e24a15c96bf15c3df4e2b071adocs/user/USAGE.mdbeb1ba79f2b3a2fc3882bf9d65553e4e754fc03ddocs/user/USAGE.mde4b37aa2e22c15e0e07341a7d8c18100cbae55c2docs/user/USAGE.md8c49e6d6960021ef72e1382d78b9b83914cc7f31docs/user/USAGE.md16b602cbfb29dcf3fc89b4ed67f228d65a27b20bdocs/user/USAGE.md66c8f11a47d64c2db6f514e409e94e91f5ac5309docs/user/USAGE.md92b12559c64489b556179b651ab4d966c29314ecdocs/user/USAGE.md67f9e72d1c663dbc8811cdb6c85753844be02381docs/user/USAGE.mdb339b4f6ca25b1b274555394e73a26f8c8d98347docs/user/USAGE.mdb447062d71dc1748d60edfdc0ec437aa597a5b7ddocs/user/USAGE.mdbad53434ecca2bf92ee67c43952598c6a108941edocs/user/USAGE.mdf9b136024e27d1463a70edee4952553628e5f289docs/user/USAGE.md5e296b79d94a6312c385890352d7f76e9a0d4380docs/user/USAGE.mdeb34b754de4b65b11c1f7d9beafe58a0d057c45ddocs/user/USAGE.mda6cb0cb5f277da258a661bb11792e04941f4c790docs/user/USAGE.md48bc3322b68ee855d9188f4eefd701e8007dd21bdocs/user/USAGE.md2636a486c2f71d880b69cadb706eac719f9cc670docs/user/USAGE.md67f94df827623df9210738a5ba3275b9a59f1c8bdocs/user/USAGE.md7b75adc8685edbffaa771e0d436543eaae694b8fdocs/user/USAGE.mdSource comparisons: #5598 includes declared host imports, #6106/#5559 change dependency selection, #5994 changes syscall scanning, and #5681 validates bounds. None preserves weak registry bindings. Emitting the extra field only for weak imports retains the strong-record shape expected by #5598; combined runtime behavior was not tested.
Checklist
main; no other open PR implements the same fix (overlapping changes listed above)Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T09:16:17Z.
Cross-check on Windows: #6240 head
96f506f87onmaind92a8dad3(fast-forward, no conflict).Host: Windows 11 Pro 26220, Ryzen 7 5700X, RTX 4070 (driver 596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release.
libsboth succeed, with no new warnings.ctest --test-dir build/core/relinker --repeat until-fail:3passes all 127 relinker tests 3/3, 381 of 381 runs. That includesguest_registry,call_registry,relinker_conversion,weak_importsandguest_module_dir(ectories).long_pathsruns and passes on this host.test_guest_registry.pyagainstmain's relinker fails:ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip': 814 tests, and 813 pass, including the 2 skipped.hardware_oracle_comparehit its own 20 s timeout under load.tools/hw-oraclescript that this PR does not touch.check_conventions.pyandgit diff --checkare clean.All 51 local catalog ELFs, relinked with
main's and with this PR's relinker. Each title used its usual flags:--windows --registry unused-filter=0;--trap-sdk-syscall-stubsfor 8 titles and--windows-fixed-base 0x400000for 3;--module-dirfor PPSA28319 and PPSA99995, and--executable picker/picker.binfor PPSA99169.main's relinker is deterministic here: relinking 4 titles a second time gave identical bytes.ntdll.prxTLS refusal (#6102). Without--module-dir, its outputs are identical.app.libc.prx.guest.prx.registry.json, where two records gain"weak": true. Everyapp.exe,.prx,app.registry.jsonand.needed.jsonis identical.libc.prxbuild"weak": true83ae42e8...kbw4UHHSYy0(__pthread_cxa_finalize, libkernel.prx), 2 relocations933e7f29...933e7f29...933e7f29...The 51 titles ship four
libc.prxbuilds. I read each module's own dynamic symbol table with a separate parser, not the relinker:kbw4UHHSYy0#A#BisSTB_WEAK.GLOBAL.libc.prx, plus PPSA28319'sIl2CppUserAssemblies.prx,PS5Util.prxandlib_burst_generated.prx), the 8 records marked weak are exactly the 8STB_WEAKimports. No weak import is unmarked, and no strong one is marked.tools/import_audit.pyprints the same report for the old and new registries of these four titles.__pthread_cxa_finalizeis implemented, soCurrent stopisnoneeither way.The four titles that differ, 60 s each with the display on. Each was run once with each relinker's output and
main's libraries:mainrelinkerNo run has a stop line. The executables are byte-identical and nothing in
core/libsreads*.registry.json, so this matches the PR's statement that runtime resolution does not change.One doc nit: in
docs/user/USAGE.mdthe new paragraph sits between "…every reference lands in exactly one class:" and the class table it introduces. Below the table would read better.Verdict: confirmed, diagnostic metadata only. On the local catalog, the change marks exactly the
STB_WEAKimports of the module registries and changes nothing else.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-15T11:45:12Z.
Moved the weak-import paragraph below the class table in
00c704697b00e28bf8ed8b84b379cf2e4fb6da19, preserving its wording. On Windows x64, verified that the table immediately follows its introduction, all original lines are preserved,git diff --checkpasses, and the committed-object conventions check passes. This is a documentation-only follow-up; runtime regression testing is not applicable and the existing behavior-test results remain tied to96f506f8707ce1cd3cb4beebd56de44227f16990.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:17:19Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/relinker/src/guest/GuestModuleBuilder.cppdocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mddocs/user/USAGE.mdcore/relinker/relinker/src/guest/GuestModuleBuilder.cppdocs/user/USAGE.md