fix(relinker): load libSceGnmDriver.prx for a libSceGnmDriver_padebug dependency #18087
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18087"
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 adam25136 on 2026-11-10T11:07:33Z.
What
A PS4 title can list
libSceGnmDriver_padebug.prxinDT_NEEDEDwhile its GNM imports name the module and librarylibSceGnmDriver. Three titles are known to ask for it: Hasbro Family Fun Pack (CUSA03312), where savvaniss resolved 44 imports with a copy oflibSceGnmDriver.prxunder that name (comment on #6977); Until Dawn, whose local relinker change by SuperCatElvis also loadslibSceGnmDriverfor it (comment on #6684); and GTA V (CUSA00419 01.57, bring-up #18084), where 45 imports come from that module. AnyPS5 builds no file of that name, so on Windows the entry stub looked forlibs\libSceGnmDriver_padebug.prxand those imports stayed unresolved (FAIL: unresolved ELF import ..., exit0xC0000139). This PR makes the relinker loadlibSceGnmDriver.prxfor that name.Domain::NeededLibraryNamemapslibSceGnmDriver_padebug, with any module suffix, tolibSceGnmDriver.prx. The Windows import builder and entry stub, the LinuxDT_NEEDEDrewrite and the Linux guest-module dependencies (GuestModuleBuilder.cpp) all use it, so they loadlibSceGnmDriver.prx. Mapping the name, rather than adding a copy of the library under the padebug name, also keeps one GNM driver in a process that loads both names: two files would load as two DLLs, each with its own globals.Domain::ImportModulematches an import from modulelibSceGnmDriverto alibSceGnmDriver_padebugdependency, the way it already matcheslibmonosgentolibmonosgen-2.0. This only keeps those imports scoped to that library; without it they still resolve on Windows, through the search of every library.SysVDynamicSectionBuilderandGuestImageReadertreated a dependency as a console file name whenNeededLibraryName(name) != name. With the mapping, that would also hold forlibSceGnmDriver_padebug.prx, which has the plain.prxsuffix. Both now call the newDomain::ConsoleModuleSuffix(.sprx,.suprxor.debug_prx), which gives the same answer as before for every other name.tools/import_audit.py, whichdocs/dev/GAME_TESTING.mdasks testers to run, applies the same mapping, so it no longer reportslibSceGnmDriver_padebug.prxas a missing library.docs/dev/debt/relinker.mdgets an entry that starts with what is not known: whether a console's padebug module exports or does anything thatlibSceGnmDriverdoesn't.libSceGnmDriver_padebugis a system module name, not a value from one title: the three titles above ask for it, andmainalready aliases thelibmonosgenimport module the same way. An import thatlibSceGnmDriverdoesn't export still fails at start, assceGnmDrawInitDefaultHardwareStatedoes for GTA V.Tested
Windows 10 Pro 22H2 (19045), i9-12900KF, WinLibs GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release,
BUILD_TESTING=ON, onmainb7eff8409a.New checks:
import_module(ImportModuleTests.cpp): the mapping for.prxand.sprx;ConsoleModuleSuffixfor.prx,.sprx,.debug_prxand no suffix; the module match with only the padebug dependency, and with both names present.windows_import_modules: an executable that needslibSceGnmDriver_padebug.prx(and, in a second case,.sprx), with an import from modulelibSceGnmDriver, converted with--windows. The output nameslibs\libSceGnmDriver.prxand never the padebug name; run here with onlylibs\libSceGnmDriver.prxpresent, it returns that library's value.linux_named_imports: converted for Linux, the same dependency becomeslibSceGnmDriver.prxinDT_NEEDED, and an unscoped import keeps its name, as for any other.prxdependency and unlike a.sprxone. The padebug case checks only the converted file; the test's Linux-only part that runs the output doesn't run it.import_audit(test_import_audit.py): an import fromlibSceGnmDriver_padebug.prx, and in a second case.sprx, audited against alibSceGnmDriver.prxin--libs, once as a PE and once as an ELF library: no missing library, no library mismatch, andlibSceGnmDriver.prxas the provider.Do the new checks fail without the change? Each part reversed in turn, with this PR's tests kept:
NeededLibraryNamemappingimport_module,windows_import_modules,linux_named_importslibSceGnmDrivermodule matchimport_module(Windows still resolves the import through the unscoped search)ConsoleModuleSuffixcounting.prxtooimport_module,linux_named_importsSysVDynamicSectionBuilderback toNeededLibraryName(name) != namelinux_named_importsimport_audit.pymappingimport_auditGuestImageReader's call site was not reversed separately.All tests in
build/core/relinkeron this branch and onmainb7eff8409a: 246 of 246 pass on each, none skipped.import_auditpasses on this branch too.The title, GTA V CUSA00419 01.57, on this branch and on
mainb7eff8409a. Both runs used the same local changes, neither of them in this PR: the eboot,libc.prxandlibSceFios2.prxunwrapped with a local workaround oftools/unwrap_self.py, and the relinker accepting the eboot's one undefined import with protected visibility (_Unwind_Resume), which it refuses otherwise. Started for up to 20 s:mainb7eff8409alibSceGnmDriver, andsceMsgDialogGetResultsceGnmDrawInitDefaultHardwareState, which onlylibSceGnmDriverForNeoModeexports (the same kind of gap as #17581), andsceMsgDialogGetResultThe title still stops at start on those two.
Rebased onto
main2c41a032c6before opening (head667e27b39e): none of the commits sinceb7eff8409achangescore/relinker,tools/import_audit.py, its test ordocs/dev/debt/relinker.md. Built there,import_module,windows_import_modules,linux_named_importsandimport_auditpass again.Rebased onto
mainaa5f2b541aon 2026-11-13 (head6233f821ec): the Linux and macOS relinker checks of1141485352(run 43363169084) failed onlyoutput_fifo_macos, whichmainfailed too after #18450 put the output file's name into the macOS signature; #19406, merged since, changed that test to compare outputs written under the same name. This rebase had no conflict and the changed lines are the same as1141485352's. On this head, on Windows, the four tests above pass, each reversal in the table above fails the same tests, and all 278 tests inbuild/core/relinkerpass on this head and onmainaa5f2b541a, none skipped. The FIFO tests run only on Linux and macOS, so this PR's checks will show them. The GTA V run was not repeated: its converted files were deleted since, and the changed lines are the same as on the heads it ran with.Rebased onto
main04202b49a5on 2026-11-13 (head1141485352): the Windows relinker check of the previous head ran onmain6229b3a7c1, which still had #17548 and failed to buildAvx2TwinLoweringTests.cppon Windows; #19221 reverted #17548. This rebase had no conflict, the commit is unchanged (git range-diffshows it equal), and the four tests above pass again on this machine.Rebased onto
maina445e0f0f7before that (head7cd08b6638). The only conflict was indocs/dev/debt/relinker.md: #15942, merged since, added its entry at the same place. Both entries are kept, #15942's first, and the code and test changes are the same as in667e27b39e. Rerun on that head:build/core/relinkerpass on that head and onmaina445e0f0f7, none skipped, including #15942'slinux_guest_qualified_imports;mainto the same 2 with this PR.python tools/check_conventions.py --base origin/main --title "<this title>" --body <this description>: all checks pass.tools/pr_overlap.py --branchbefore opening (in a full clone, 1,985 open pull requests): 54 share a file with this branch, among them my #17564, which also changestools/import_audit.pyand merges without a conflict.docs/dev/debt/relinker.md(line 76 onmain). Keeping both entries resolves it.main. Fifteen share onlydocs/dev/debt/relinker.mdwith this branch. The other six are kyon-eth's draft stack #13472, #13473, #13475, #13477, #13482 and #13486: each adds aliases to the same lookup inImportModule.hpp, and each adds its ownImportModuleTests.cpp, whichmainalready has. The padebug alias is written in the sameif (lookup == ...) lookup = ...;form those PRs use, so whichever lands second keeps both sets of lines, and this PR's new checks return codes 90 to 94, which none of those PRs uses.Not covered: macOS, which was not built or run here and whose dependency reader (
ReadNeededLibrariesinMacOsMachOPatcher.cpp) doesn't callNeededLibraryName; running the Linux output; whether a console's padebug module exports or does anything thatlibSceGnmDriverdoesn't.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code