Skip to content

fix(loader): resolve sceKernelDlsym on the main module - #2786

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
tototomate123:fix/hfw-loader-split
Oct 11, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
tototomate123:fix/hfw-loader-split

Conversation

@tototomate123

@tototomate123 tototomate123 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Split from #1616, following its review. Resolve handle 0 through the main executable for sceKernelDlsym, retaining the existing error behavior. The regression calls an executable-only export; Windows exports it through a generated .def, with a plain extern "C" definition instead of __declspec.

Tested

Linux x86-64, GCC 16.2.1, Release. guest_dynamic_loader passes, including main-module calls and missing-symbol errors. MinGW C++20 syntax check passes; Windows runtime/CI has not been run locally. Conventions and whitespace checks pass on current main (5edae353).

Depends on

None for build. HFW integration also needs #2785 (relinker), #2787 (filesystem), #2788 (http), #2789 (apr), #2790 (shader). #1269 (media), #1339 (VRR), #1586 (unwind) and #1436 (imports) are now on main. Local image-table experiments are excluded; open #757 → #758 overlaps them, and #920 is closed without merging. Earlier combined integration reached menu/loading UI; these isolated branches have not been game-tested and gameplay is unverified.

Checklist

  • Based on current main; no duplicate implementation found beyond superseded fix(linux): resolve loader and APR failures exposed by HFW #1616
  • One topic per PR
  • No code comments except technical debt
  • Unimplemented paths throw; offline HTTP limitations documented
  • No investigation notes, logs or images committed
  • No new third-party dependencies
  • Generic behavior; no title-specific dispatch
  • Depends on: none for build; HFW integration requirements listed above
  • AI-assisted: yes, Codex

@github-actions github-actions Bot added the intake paused Closed while PR intake is limited to authors with at least 10 PRs merged into main label Oct 10, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting this out. Checked on Linux (GCC, Release, PR merged onto current main): the build and the area's ctest (94 tests) pass, including guest_dynamic_loader.

  • The new regression does not fail without the change on Linux. With Module.cpp reverted, guest_dynamic_loader still passes: dlsym_nid_postfix(nullptr, ...) already falls back to DefaultScopeSymbol (DynamicLoader.cpp:164), so sceKernelDlsym(0, ...) finds the executable's export there. The fix only changes behaviour on Windows, where there is no such fallback and the only global module is the one dlopen(nullptr) registers.
  • The Windows part can't be checked from Linux and the PR says it wasn't run. Please post evidence from a Windows build (MinGW or MSVC): the guest_dynamic_loader output on main (failing at the new sceKernelDlsym(0, "GuestDefaultScopeOnly", ...) check) and with this PR (passing), and that the generated .def links.

The change itself looks right (handle 0 only, same ESRCH on a missing symbol, module handle closed after the lookup). Once the Windows before/after is in, this is ready from my side.

@Mouhand-Kaddo

Mouhand-Kaddo commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Additional platform validation of standalone PR head 43110f8ed73e386396efdd34aaccb6c34e002393 (2026-10-11):

Windows: failed tests — Windows 11, WinLibs GCC 15.2.0 UCRT/POSIX/SEH r7; CMake 4.3.1 / Ninja; Release, BUILD_TESTING=ON.

1 checks, 1 failures, 0 CTest skips. Built the selected targets and dependencies; this is focused validation, not a full build or full-suite run.

Checks: guest_dynamic_loader.

Command after building: ctest --test-dir <build> --verbose --no-tests=error --timeout 30 -R "^guest_dynamic_loader$".

Diagnostic-only rebuild (same assertions, added failure printing): sceKernelDlsym(0, "GuestDefaultScopeOnly", &mainSymbol) == 0 && mainSymbol != nullptr. The PE export table does not contain GuestDefaultScopeOnly. Pristine parent 5edae35 passes guest_dynamic_loader.

Failed cases: guest_dynamic_loader.

No title/gameplay validation. These results cover the standalone head, not a merge with current main.

@tototomate123

Copy link
Copy Markdown
Contributor Author

@adriadam10 Fixed the Windows export configuration and rebased onto current main. I’m on Linux, so I cant test native Windows directly, but the MinGW-built test under Wine fails without the loader change and passes with it; Linux also passes, so looks fixed.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. Checked on Linux (GCC, Release, PR merged onto current main): build and the area's ctest (106 tests) pass, guest_dynamic_loader included. As expected, the regression passes on Linux without the loader change (the default-scope fallback already resolves it); it only discriminates on Windows, where the .def export now makes GuestDefaultScopeOnly visible. The main-module path (GetModuleHandleW(nullptr) → registered handle → GetProcAddress) and the error return look right. Merging once the Windows build job is green.

@adriadam10
adriadam10 merged commit f100f6c into boykopovar:main Oct 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants