fix(relinker): load needed providers for unscoped Windows imports #3365
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3365"
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 MathiasDevelopes on 2026-10-11T09:07:45Z.
What
Windows startup skips needed host libraries unless an import identifies them as a provider. Imports without a recorded library name search across dependencies, but their provider can consequently remain unloaded.
When unscoped imports exist, attempt to load the needed host libraries so their exports participate in resolution. Missing libraries without explicitly scoped imports remain optional; unresolved symbols still fail startup with an error. Explicitly scoped imports retain their existing behavior.
Adds a regression where an unscoped import resolves through an available native library while another optional dependency is missing.
Tested
Windows, WinLibs MinGW-w64 GCC 15.2.0 r7, CMake 3.31.12, Python 3.13.16, Release.
4f8d4017c.BUILD_TESTING=ON: 105/105 tests passed.windows_import_modules, including the new regression: passed in 3.44 seconds.tools/check_conventions.py --base origin/mainand whitespace checks passed.99b82IKXpH4; this fix allowed startup and rendering. It later stopped at unsupported depth-plane sampling. Gameplay is unverified.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-11T09:07:51Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:12:19Z.
Review: CHANGES_REQUESTED
Thanks, the stub change looks right to me: the load path, the
ERROR_MOD_NOT_FOUNDskip and the cleared handle behave like the previous "not imported" case. Relinker tests pass locally (99/99).One thing to fix:
core/relinker/relinker/tests/test_windows_import_modules.py:245-247: the regression only runs the output whenos.name == 'nt'. On Linux it just checks that the conversion succeeds, which also holds without the change (revertingWindowsEntryStubBuilder.cppleaveswindows_import_modulesgreen). Please show that the test fails onmainon Windows (log of the run without the fix), or add an assertion that also fails on Linux, e.g. inspect the generated stub/output for theLoadLibraryExWpath of the unscoped provider.Not verified on our side: Windows execution and Planet Coaster.
Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-11T09:23:38Z.
Fixed in 116b98a76.
The regression now inspects the generated PE outside the Windows execution guard, checking that both available.prx and unused.prx have a path reference followed by a call through the LoadLibraryExW IAT slot.
Rebuilding with the pre-fix WindowsEntryStubBuilder.cpp makes the new assertion fail:
AssertionError: available.prx: expected a loader path reference, found 0
With the inspection bypassed, Windows execution also fails with 0xc0000139 and FAIL: unresolved ELF import shared. Both checks pass with the fix restored.
All 105 checks passed, including three rerun outside the sandbox. The inspection was verified with Windows execution disabled; it wasn’t run on a Linux host. Planet Coaster remains untested.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:36:52Z.
Review: APPROVED
Checked: relinker build + ctest green (110/110 on the rebased tree), and
windows_import_modulesfails whenWindowsEntryStubBuilder.cppis reverted, so the regression is real.Added one commit on your branch: drop the leftover docstring in
check_native_load_paths(test_windows_import_modules.py:15, no code comments). Merging once CI is green.