fix(relinker): load libSceGnmDriver.prx for a libSceGnmDriver_padebug dependency #18087

Merged
adam25136 merged 1 commit from upstream-pr/18087 into main 2026-11-16 02:18:51 +00:00
adam25136 commented 2026-11-10 11:07:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adam25136 on 2026-11-10T11:07:33Z.


What

A PS4 title can list libSceGnmDriver_padebug.prx in DT_NEEDED while its GNM imports name the module and library libSceGnmDriver. Three titles are known to ask for it: Hasbro Family Fun Pack (CUSA03312), where savvaniss resolved 44 imports with a copy of libSceGnmDriver.prx under that name (comment on #6977); Until Dawn, whose local relinker change by SuperCatElvis also loads libSceGnmDriver for 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 for libs\libSceGnmDriver_padebug.prx and those imports stayed unresolved (FAIL: unresolved ELF import ..., exit 0xC0000139). This PR makes the relinker load libSceGnmDriver.prx for that name.

  • Domain::NeededLibraryName maps libSceGnmDriver_padebug, with any module suffix, to libSceGnmDriver.prx. The Windows import builder and entry stub, the Linux DT_NEEDED rewrite and the Linux guest-module dependencies (GuestModuleBuilder.cpp) all use it, so they load libSceGnmDriver.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::ImportModule matches an import from module libSceGnmDriver to a libSceGnmDriver_padebug dependency, the way it already matches libmonosgen to libmonosgen-2.0. This only keeps those imports scoped to that library; without it they still resolve on Windows, through the search of every library.
  • SysVDynamicSectionBuilder and GuestImageReader treated a dependency as a console file name when NeededLibraryName(name) != name. With the mapping, that would also hold for libSceGnmDriver_padebug.prx, which has the plain .prx suffix. Both now call the new Domain::ConsoleModuleSuffix (.sprx, .suprx or .debug_prx), which gives the same answer as before for every other name.
  • tools/import_audit.py, which docs/dev/GAME_TESTING.md asks testers to run, applies the same mapping, so it no longer reports libSceGnmDriver_padebug.prx as a missing library.
  • docs/dev/debt/relinker.md gets an entry that starts with what is not known: whether a console's padebug module exports or does anything that libSceGnmDriver doesn't.

libSceGnmDriver_padebug is a system module name, not a value from one title: the three titles above ask for it, and main already aliases the libmonosgen import module the same way. An import that libSceGnmDriver doesn't export still fails at start, as sceGnmDrawInitDefaultHardwareState does 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, on main b7eff8409a.

  • New checks:

    • import_module (ImportModuleTests.cpp): the mapping for .prx and .sprx; ConsoleModuleSuffix for .prx, .sprx, .debug_prx and no suffix; the module match with only the padebug dependency, and with both names present.
    • windows_import_modules: an executable that needs libSceGnmDriver_padebug.prx (and, in a second case, .sprx), with an import from module libSceGnmDriver, converted with --windows. The output names libs\libSceGnmDriver.prx and never the padebug name; run here with only libs\libSceGnmDriver.prx present, it returns that library's value.
    • linux_named_imports: converted for Linux, the same dependency becomes libSceGnmDriver.prx in DT_NEEDED, and an unscoped import keeps its name, as for any other .prx dependency and unlike a .sprx one. 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 from libSceGnmDriver_padebug.prx, and in a second case .sprx, audited against a libSceGnmDriver.prx in --libs, once as a PE and once as an ELF library: no missing library, no library mismatch, and libSceGnmDriver.prx as the provider.
  • Do the new checks fail without the change? Each part reversed in turn, with this PR's tests kept:

    Reversed Fails
    the NeededLibraryName mapping import_module, windows_import_modules, linux_named_imports
    the libSceGnmDriver module match import_module (Windows still resolves the import through the unscoped search)
    ConsoleModuleSuffix counting .prx too import_module, linux_named_imports
    SysVDynamicSectionBuilder back to NeededLibraryName(name) != name linux_named_imports
    the import_audit.py mapping import_audit

    GuestImageReader's call site was not reversed separately.

  • All tests in build/core/relinker on this branch and on main b7eff8409a: 246 of 246 pass on each, none skipped. import_audit passes on this branch too.

  • The title, GTA V CUSA00419 01.57, on this branch and on main b7eff8409a. Both runs used the same local changes, neither of them in this PR: the eboot, libc.prx and libSceFios2.prx unwrapped with a local workaround of tools/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:

    Build Unresolved imports at start
    main b7eff8409a 46: the 45 from module libSceGnmDriver, and sceMsgDialogGetResult
    this PR 2: sceGnmDrawInitDefaultHardwareState, which only libSceGnmDriverForNeoMode exports (the same kind of gap as #17581), and sceMsgDialogGetResult

    The title still stops at start on those two.

  • Rebased onto main 2c41a032c6 before opening (head 667e27b39e): none of the commits since b7eff8409a changes core/relinker, tools/import_audit.py, its test or docs/dev/debt/relinker.md. Built there, import_module, windows_import_modules, linux_named_imports and import_audit pass again.

  • Rebased onto main aa5f2b541a on 2026-11-13 (head 6233f821ec): the Linux and macOS relinker checks of 1141485352 (run 43363169084) failed only output_fifo_macos, which main failed 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 as 1141485352'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 in build/core/relinker pass on this head and on main aa5f2b541a, 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 main 04202b49a5 on 2026-11-13 (head 1141485352): the Windows relinker check of the previous head ran on main 6229b3a7c1, which still had #17548 and failed to build Avx2TwinLoweringTests.cpp on Windows; #19221 reverted #17548. This rebase had no conflict, the commit is unchanged (git range-diff shows it equal), and the four tests above pass again on this machine.

  • Rebased onto main a445e0f0f7 before that (head 7cd08b6638). The only conflict was in docs/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 in 667e27b39e. Rerun on that head:

    • the four tests above pass, and each reversal in the table fails the same tests as before;
    • all 271 tests in build/core/relinker pass on that head and on main a445e0f0f7, none skipped, including #15942's linux_guest_qualified_imports;
    • GTA V again goes from 46 unresolved imports on main to 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 --branch before opening (in a full clone, 1,985 open pull requests): 54 share a file with this branch, among them my #17564, which also changes tools/import_audit.py and merges without a conflict.

    • It reported 4 conflicts, #15942 (merged since), #16463, #17557 and #17558: each also adds an entry at the end of docs/dev/debt/relinker.md (line 76 on main). Keeping both entries resolves it.
    • It could not compare 21 that conflict with main. Fifteen share only docs/dev/debt/relinker.md with 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 in ImportModule.hpp, and each adds its own ImportModuleTests.cpp, which main already has. The padebug alias is written in the same if (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 (ReadNeededLibraries in MacOsMachOPatcher.cpp) doesn't call NeededLibraryName; running the Linux output; whether a console's padebug module exports or does anything that libSceGnmDriver doesn't.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5240233282 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18087). Originally posted by [adam25136](https://github.com/adam25136) on 2026-11-10T11:07:33Z. --- ### What A PS4 title can list `libSceGnmDriver_padebug.prx` in `DT_NEEDED` while its GNM imports name the module and library `libSceGnmDriver`. Three titles are known to ask for it: Hasbro Family Fun Pack (CUSA03312), where savvaniss resolved 44 imports with a copy of `libSceGnmDriver.prx` under that name ([comment on #6977](https://github.com/boykopovar/AnyPS5/pull/6977#issuecomment-6236089151)); Until Dawn, whose local relinker change by SuperCatElvis also loads `libSceGnmDriver` for it ([comment on #6684](https://github.com/boykopovar/AnyPS5/pull/6684#issuecomment-6264811774)); 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 for `libs\libSceGnmDriver_padebug.prx` and those imports stayed unresolved (`FAIL: unresolved ELF import ...`, exit `0xC0000139`). This PR makes the relinker load `libSceGnmDriver.prx` for that name. - `Domain::NeededLibraryName` maps `libSceGnmDriver_padebug`, with any module suffix, to `libSceGnmDriver.prx`. The Windows import builder and entry stub, the Linux `DT_NEEDED` rewrite and the Linux guest-module dependencies (`GuestModuleBuilder.cpp`) all use it, so they load `libSceGnmDriver.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::ImportModule` matches an import from module `libSceGnmDriver` to a `libSceGnmDriver_padebug` dependency, the way it already matches `libmonosgen` to `libmonosgen-2.0`. This only keeps those imports scoped to that library; without it they still resolve on Windows, through the search of every library. - `SysVDynamicSectionBuilder` and `GuestImageReader` treated a dependency as a console file name when `NeededLibraryName(name) != name`. With the mapping, that would also hold for `libSceGnmDriver_padebug.prx`, which has the plain `.prx` suffix. Both now call the new `Domain::ConsoleModuleSuffix` (`.sprx`, `.suprx` or `.debug_prx`), which gives the same answer as before for every other name. - `tools/import_audit.py`, which `docs/dev/GAME_TESTING.md` asks testers to run, applies the same mapping, so it no longer reports `libSceGnmDriver_padebug.prx` as a missing library. - `docs/dev/debt/relinker.md` gets an entry that starts with what is not known: whether a console's padebug module exports or does anything that `libSceGnmDriver` doesn't. `libSceGnmDriver_padebug` is a system module name, not a value from one title: the three titles above ask for it, and `main` already aliases the `libmonosgen` import module the same way. An import that `libSceGnmDriver` doesn't export still fails at start, as `sceGnmDrawInitDefaultHardwareState` does for GTA V. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 10 Pro 22H2 (19045), i9-12900KF, WinLibs GCC 15.2.0 r7, CMake 4.3.1, Ninja, Release, `BUILD_TESTING=ON`, on `main` `b7eff8409a`. - **New checks:** - `import_module` (`ImportModuleTests.cpp`): the mapping for `.prx` and `.sprx`; `ConsoleModuleSuffix` for `.prx`, `.sprx`, `.debug_prx` and no suffix; the module match with only the padebug dependency, and with both names present. - `windows_import_modules`: an executable that needs `libSceGnmDriver_padebug.prx` (and, in a second case, `.sprx`), with an import from module `libSceGnmDriver`, converted with `--windows`. The output names `libs\libSceGnmDriver.prx` and never the padebug name; run here with only `libs\libSceGnmDriver.prx` present, it returns that library's value. - `linux_named_imports`: converted for Linux, the same dependency becomes `libSceGnmDriver.prx` in `DT_NEEDED`, and an unscoped import keeps its name, as for any other `.prx` dependency and unlike a `.sprx` one. 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 from `libSceGnmDriver_padebug.prx`, and in a second case `.sprx`, audited against a `libSceGnmDriver.prx` in `--libs`, once as a PE and once as an ELF library: no missing library, no library mismatch, and `libSceGnmDriver.prx` as the provider. - **Do the new checks fail without the change?** Each part reversed in turn, with this PR's tests kept: | Reversed | Fails | |---|---| | the `NeededLibraryName` mapping | `import_module`, `windows_import_modules`, `linux_named_imports` | | the `libSceGnmDriver` module match | `import_module` (Windows still resolves the import through the unscoped search) | | `ConsoleModuleSuffix` counting `.prx` too | `import_module`, `linux_named_imports` | | `SysVDynamicSectionBuilder` back to `NeededLibraryName(name) != name` | `linux_named_imports` | | the `import_audit.py` mapping | `import_audit` | `GuestImageReader`'s call site was not reversed separately. - **All tests in `build/core/relinker`** on this branch and on `main` `b7eff8409a`: 246 of 246 pass on each, none skipped. `import_audit` passes on this branch too. - **The title,** GTA V CUSA00419 01.57, on this branch and on `main` `b7eff8409a`. Both runs used the same local changes, neither of them in this PR: the eboot, `libc.prx` and `libSceFios2.prx` unwrapped with a local workaround of `tools/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: | Build | Unresolved imports at start | |---|---| | `main` `b7eff8409a` | 46: the 45 from module `libSceGnmDriver`, and `sceMsgDialogGetResult` | | this PR | 2: `sceGnmDrawInitDefaultHardwareState`, which only `libSceGnmDriverForNeoMode` exports (the same kind of gap as #17581), and `sceMsgDialogGetResult` | The title still stops at start on those two. - **Rebased onto `main` `2c41a032c6` before opening** (head `667e27b39e`): none of the commits since `b7eff8409a` changes `core/relinker`, `tools/import_audit.py`, its test or `docs/dev/debt/relinker.md`. Built there, `import_module`, `windows_import_modules`, `linux_named_imports` and `import_audit` pass again. - **Rebased onto `main` `aa5f2b541a` on 2026-11-13** (head `6233f821ec`): the Linux and macOS relinker checks of `1141485352` ([run 43363169084](https://github.com/boykopovar/AnyPS5/actions/runs/43363169084)) failed only `output_fifo_macos`, which `main` failed 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 as `1141485352`'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 in `build/core/relinker` pass on this head and on `main` `aa5f2b541a`, 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 `main` `04202b49a5` on 2026-11-13** (head `1141485352`): the Windows relinker check of the previous head ran on `main` `6229b3a7c1`, which still had #17548 and failed to build `Avx2TwinLoweringTests.cpp` on Windows; #19221 reverted #17548. This rebase had no conflict, the commit is unchanged (`git range-diff` shows it equal), and the four tests above pass again on this machine. - **Rebased onto `main` `a445e0f0f7` before that** (head `7cd08b6638`). The only conflict was in `docs/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 in `667e27b39e`. Rerun on that head: - the four tests above pass, and each reversal in the table fails the same tests as before; - all 271 tests in `build/core/relinker` pass on that head and on `main` `a445e0f0f7`, none skipped, including #15942's `linux_guest_qualified_imports`; - GTA V again goes from 46 unresolved imports on `main` to 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 --branch` before opening (in a full clone, 1,985 open pull requests): 54 share a file with this branch, among them my #17564, which also changes `tools/import_audit.py` and merges without a conflict. - It reported 4 conflicts, #15942 (merged since), #16463, #17557 and #17558: each also adds an entry at the end of `docs/dev/debt/relinker.md` (line 76 on `main`). Keeping both entries resolves it. - It could not compare 21 that conflict with `main`. Fifteen share only `docs/dev/debt/relinker.md` with 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 in `ImportModule.hpp`, and each adds its own `ImportModuleTests.cpp`, which `main` already has. The padebug alias is written in the same `if (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 (`ReadNeededLibraries` in `MacOsMachOPatcher.cpp`) doesn't call `NeededLibraryName`; running the Linux output; whether a console's padebug module exports or does anything that `libSceGnmDriver` doesn't. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!18087
No description provided.