fix(relinker): write a bucketed hash table for Linux guest modules #1249
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1249"
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 Raghav314 on 2026-10-07T19:45:24Z.
What
On Linux the relinker wrote each guest module's DT_HASH with one bucket, so every symbol sat in a single chain. Guest modules come first in the global lookup scope, so every symbol lookup from a host prx walked every symbol of every guest module before reaching the host definition. The relinker now writes a standard SysV hash table (gABI ELF hash) with one bucket per symbol, which is how the console's own modules ship it (nbucket == nchain in all seven of Hades II's sce_module prx). The table is built from the final string and symbol tables, after the
#guestand__tls_get_addrrenames.Hades II (PPSA36082) bundles libSceNpCppWebApi.prx with 44906 symbols, and a lookup walked all of them. Its 512 MiB upload pool is freed only after a GPU fence, and the slow lookups were one of the delays in front of that fence: with this change and some local changes it gets past loading (3/3 runs); without it the pool overflows (2/2).
Tested
Linux (CachyOS), x86-64, GCC, 7800X3D / RTX 4090.
main.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:00Z.
Please move the
-z nowlink change (core/libs/CMakeLists.txt,HostLibraryBinding.cpp) into its own PR: it changes when a missing import fails for every host prx, and it's a second topic. The hash table fix can go in on its own; a launch-to-first-open number for it alone would help, since the description has-z nowalone (2.73 s) and both (0.38 s) but not the hash fix alone.Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-08T05:03:56Z.
Thanks for the review,Done, #1249 is now only the hash table fix, rebased on current main. Launch to first file open in Hades II with the hash fix alone is 0.51 s (1.88 s on main; 0.38 s with both changes, 2.73 s with -z now alone).
Before I open a separate PR for -z now, do you think its worth having on its own? with this hash fix, hades 2 still loads on my separate local branch, although the load margins are a small amount tighter.
-z does also make linux match the behaviour thats there on windows by default, so its ur call.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T06:37:16Z.
Only if a title needs it. With the hash fix Hades II gets past loading, so I'd leave
-z nowout until one does.Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-08T06:53:53Z.
Alright sounds good
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:03:26Z.
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.
main)core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cppL57-58core/relinker/elfpatcher/src/linux/LinuxGuestModuleWriter.cppL57-58Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:37:45Z.
Checked the new DT_HASH layout (gABI ELF hash, nbucket == nchain == symbol count, null symbol skipped) and the test:
guest_symbol_namesfails without the change and passes with it, full ctest passes (549/549) on Linux, CI is green. Merging.