fix(relinker): preserve weak imports in Linux guest modules #6080
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6080"
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-14T21:27:16Z.
What
Linux guest-module conversion changes undefined
STB_WEAKsymbols toSTB_GLOBAL. A module that checks an optional import for null can load before conversion, then fail at startup after conversion because the loader treats that import as required.Keep the source symbol binding by removing the promotion in
LinuxGuestModuleWriter. Available weak imports still resolve to their providers; missing strong imports and required libraries still fail. This follows the executable behavior merged in #4510, which left guest modules for separate work. The ELF symbol-binding specification describes unresolved weak symbols having a zero value; native Linux loader behavior is measured below.Tested
Zorin OS 18.1 x86-64, Python 3.12.3, GCC 13.3.0, CMake 3.28.3. Synthetic page-aligned x86-64 ELF fixtures with declared host-module ownership and a required host import; no title files or title-unblocking claim.
4808d9c2032129eaf9dc31015e7c8cfbffde7a5c, head875a159f6467618385e0ec2ac97646863c332856. Relevant relinker, CMake and tool sources are unchanged between the tested base0ae1deb85and this upstream rebase.fa539dd9bafa17005c7d890117499c208effb8d2: the original missing-weak module loads and its null-guarded function returns 42. Conversion succeeds, but the converted module failsdlopenwith an undefined-symbol error. A present weak provider returns 77; missing required/global imports remain loader errors.weak_importsCTest passes in 0.29 s; the exact new regression fails against the saved original binary. Missing required host-library refusal is also exercised. Existing assertions remain intact. Conventions and whitespace checks pass.DT_FLAGSand #5614 changes finalizer arguments in the same writer; neither changes this binding. #5473's weak-import tests concern macOS executables and are already on currentmain.Hosted relinker CI passed on Linux, Windows and macOS at head
875a159f6467618385e0ec2ac97646863c332856, including the expandedweak_importstest on each platform. Eligibility, intake and conventions also passed. Full runtime-library jobs were skipped by the repository's PR policy.Manual review of the partial-overlap notice against main
fa9365ca74: #6112 changes preinit handling, and its Linux writer composes with this PR's weak-binding preservation. It introduces no additional conflict; the peer's existing base conflicts remain unchanged.Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T22:15:08Z.
Checked the one-line change in
LinuxGuestModuleWriter.cppand the expandedweak_importstest: relinker-scope build and ctest pass (136/136), and reverting only the writer change makesweak_importsfail, so the test pins the fix. Relinker CI is green on Linux, Windows and macOS; merging.