fix(relinker): preserve weak imports in macOS guest modules #6105
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6105"
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 Zinebyte on 2026-10-14T22:19:29Z.
What
A converted macOS guest module currently emits strong Mach-O binds for both weak and global undefined ELF symbols. An optional symbol therefore becomes a mandatory import, even though the macOS executable writer already preserves weak binding.
Pass the guest symbol's
STB_WEAKbinding to the existing Mach-O bind writer. Add a focused guest-module regression that checks the weak/strong opcodes and declared library dependency on all hosts. On macOS it also compiles a small x86-64 loader and providers with the system Clang, then checks missing/present weak imports, missing strong imports, and missing declared libraries in fresh processes.The native probe uses
RTLD_NOW | RTLD_LOCAL, matching the guest dynamic-loader API. It runs directly on Intel or through already-installed Rosetta on Apple Silicon. Local machines without x86-64 execution can skip native controls; hosted Darwin CI fails rather than skipping them. No Rosetta installation or workflow changes are added.Tested
Linux x86-64, Release relinker-only build at upstream
fa9365ca74: all 182 CTests pass (12.89 s). The new regression is also selected byctest -L '^relinker$' -R '^macos_guest_weak_imports$'and passes. The standalone metadata regression fails against unchanged production on the optional import's strong bind opcode (0x40instead of0x41). The required import remains strong and the declared host library remains required. Independent adversarial review checked the fixture, branch displacements, runpaths, missing-import controls and hosted native-execution guard.Hosted Build 38778017732 passed for PR head
5c378ece, merged into current main: Linux 183/183 tests, Windows 178/178 and macOS 174/174. The focused regression took 0.05 s, 0.25 s and 2.83 s respectively. The macOS probe passed all five native loader controls: 42 with the weak import absent, 77 with its provider present, and failure for missing required/global imports or a declared library. Hosted Darwin cannot skip these controls. Production and regression code are unchanged from the previously green revision; this update adds the component test label and rebases onto current main. Conventions passed. No retail-title result is claimed.Manual review of all 21 peers named in the partial-comparison notice against main
fa9365ca74found no new conflict blocks from this PR. The macOS preinit metadata in #6112 composes with the weak bind flag; the other shared changes register unrelated tests or organize components. Their existing conflicts with main remain unchanged. The test now carries therelinkerlabel so it also remains included in component-filtered runs if #6044 lands; this uses existing CMake functionality and does not depend on that PR.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:14:48Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:14:20Z.
Checked:
STB_WEAKnow reaches the existing Mach-O weak bind flag (MacOsGuestModuleWriter.cpp:86→MacOsImage.cpp:613); required imports stay strong. The newmacos_guest_weak_importstest fails without the change (verified by reverting the writer line) and passes with it; relinker jobs are green on Linux, Windows and macOS. Merging.