Skip to content

fix(libkernel): expose earlier guest modules to Mach-O imports - #8481

Closed
ycarogabriel-lgtm wants to merge 1 commit into
boykopovar:mainfrom
ycarogabriel-lgtm:codex/macos-rtld-global
Closed

ycarogabriel-lgtm wants to merge 1 commit into
boykopovar:mainfrom
ycarogabriel-lgtm:codex/macos-rtld-global

Conversation

@ycarogabriel-lgtm

Copy link
Copy Markdown
Contributor

What

On macOS, load guest Mach-O modules with host RTLD_GLOBAL so a later relinked module can bind an import from a dependency loaded earlier. Preserve the guest's RTLD_LOCAL behavior for dlsym(RTLD_DEFAULT, ...) by checking the owning dyld image before returning a symbol. Linux and Windows paths keep their existing flag handling.

This extracts the module-visibility change and its focused dynamic-loader check from the former integration PR #7332. The known host limitation is recorded in the libkernel technical-debt entry.

Tested

  • Apple M1, macOS 26.6.2, x86-64 under Rosetta 2: ctest --test-dir build-mac -R '^guest_dynamic_loader$' passed at integration head b5fddb65c, which contains this change. The full non-GPU suite on its preceding integration head passed 842/843; the cold patched_libraries timeout passed alone.
  • This branch is one commit on current main; python3 tools/check_conventions.py --base origin/main passed. A standalone macOS build on main is blocked by its unchanged libc/General.cpp until fix(libc): build the host-facing libc code on macOS #4627 (Apple time and stat fields) is integrated. The test was not rerun standalone on this branch.
  • No title was run locally. Linux and Windows were not tested locally; no GPU code changed.

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: fix(libc): build the host-facing libc code on macOS #4627 for the macOS libc build; Macos port #7201 or its successor for the host module foundation
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

…on macOS

Relinked Mach-O modules bind every import by flat lookup, and dyld leaves images opened RTLD_LOCAL out of that lookup, while on the console and in ELF a module's dependencies resolve its imports whatever mode they were loaded with. sceKernelLoadStartModule and a plain dlopen open modules locally, so libfmodstudio could not find the libfmod it depends on ('symbol not found in flat namespace'), the load failed only through dlerror and both Planet of Lana (PPSA19450) and God of War: Sons of Sparta (PPSA28997) waited forever, as imellag traced on boykopovar#7332 and checked by opening modules globally.

On macOS the host dlopen now always uses RTLD_GLOBAL. The guest's own scope is unchanged: dlsym with the default handle skips the image of a module the guest opened without RTLD_GLOBAL, which GuestDynamicLoader now checks on every host. The remaining difference is in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1b8d47c)
@github-actions github-actions Bot added the open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20 label Oct 20, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your contribution! Authors with no pull requests merged into main can have 1 open pull request at a time, authors with at least 1 merged can have 20, and from 20 merged there is no limit. This PR has been automatically closed and labeled "open PR limit" because that limit was reached. This is not a judgment of the quality of your changes: reopen it once one of your open pull requests is merged or closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open PR limit Closed over the open PR limit: 1 without merged PRs, 20 with at least 1, none from 20

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant