fix(relinker): suppress duplicate system library lifecycle #1156
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1156"
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 ahir061 on 2026-10-07T15:26:34Z.
What
Closes #693.
When a title bundles a system library that AnyPS5 already provides as a replacement, the converted guest copy should remain available as an export provider but must not run as a second active runtime.
Previously, a bundled
libc.prxand AnyPS5's replacementlibs/libc.prxcould both execute their lifecycle callbacks. On Linux this caused both libc instances to perform the application-heap handshake, producing two main pools instead of one.This change makes lifecycle ownership generic and identity-based:
DT_INIT,DT_INIT_ARRAY,DT_FINI_ARRAY, andDT_FINI.Both
DT_OS_MODULE_INFO(0x6100000d) andDT_OS_MODULE_INFO_1(0x61000043) are accepted for SCE module identity.The guest code itself is not patched and the bundled module is not removed, so other bundled modules can continue resolving symbols from it.
Tested
macOS arm64, AppleClang,
BUILD_TESTING=ON.The relinker and the new lifecycle replacement fixture were built through CMake. The repository's GCC-specific static link flags required local command-line link-rule overrides on macOS.
The following CTests pass:
guest_lifecycle_ownershipguest_host_libcwindows_import_modulesguest_module_directoriesguest_symbol_namesguest_absolute_symbolsguest_tlsguest_intel_trampolinesThe new regression covers:
The new lifecycle regression fails on the previous behavior and passes with this change.
Native Linux/Windows lifecycle callback execution was not tested on this macOS arm64 host. No proprietary title was tested.
Independent Windows validation also confirmed the synthetic lifecycle behavior: main produced HIAaih, while this PR produced Hh, with the dependent guest export remaining callable in both cases.
Checklist
main; no other open PR implements the same fixretpatchinggit diff --checkpassesImported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-07T20:05:42Z.
Review: COMMENTED
Windows validation of
3b6aab11af7a88d7a70ed79085761d713dbf24fe: the lifecycle ownership behavior passes the native Windows checks below.Windows 11, WinLibs GCC 15.2.0 UCRT, Python 3.12. I used the preserved foreign-only relinker from a clean local integration of this contribution into main
cea1ef13. Its originalcf62b3c2PR tree is identical to the current head's full tree. I reconstructed the recorded integration patch and checked that its resulting tree equals a fresh merge of the current head into that same base. This is not a new full-project build or a current-main claim.test_guest_lifecycle_ownership.py, its imported helpers and a freshly compiled unchanged replacement fixture pass. On Windows this executes the generated PE cases and checks their lifecycle events and exported values. It also inspects Linux output; it does not execute Linux binaries.libc.prx, before its Windows cases.guest,consumerandexecutablebuilders:renamed.prxdeclares exported module identitylibcthrough tag0x61000043, andconsumer.prximports itssharedfunction. Main producesHIAaih; the PR producesHh. Both processes return 42. Thus the replacement's constructor/destructor remain, the guest's direct/array lifecycle callbacks disappear, and its export remains callable by the dependent guest.The earlier integration's full 31-group Windows relinker CTest suite also passed without skips; I revalidated that archived receipt and binary identity, but did not repeat the entire suite for this review. The focused checks above are fresh. The fixture DLL uses the PR's MinGW unwind/exception compile options. No proprietary code is included.
This validates the synthetic Windows lifecycle behavior, not a real-title heap handshake, native Linux execution, menu or gameplay. The implementation and fixture remain your contribution. Validation helpers and this report were prepared with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by ahir061 on 2026-10-07T20:49:01Z.
Thanks for the detailed validation. The direct HIAaih vs Hh comparison is especially useful, since it confirms the duplicate guest lifecycle is suppressed while the dependent guest can still call its export.
I also appreciate the clear scope around what was and wasn’t validated.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T08:36:17Z.
Checked the diff against the description and #693: identity resolution (SCE module info → SONAME → filename, exact before normalized, ambiguous/conflicting throws), lifecycle suppression on both writers (Linux dynamic tags, Windows RVAs), exports kept and the replacement kept as a host dependency. Linux and Windows CI are green.
Added on top of your commits (rebased on
main):test_guest_lifecycle_ownership.pynow has a non-executablePT_GNU_STACKheader. Without it the converted.guest.prxhas none (LinuxGuestModuleWriteronly forwards the source's), and glibc 2.41+ refuses todlopenit ("cannot enable executable stack"), so the native part of the test failed on current Arch/Fedora/Ubuntu while CI's older glibc passed. With the header it passes in full on glibc 2.44.Merging once CI is green on the rebased head.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T10:50:11Z.
Reverting this in #1515 for now: with the bundled libc's init suppressed, titles still call its
malloc, which returns NULL (#1500), and titles that bundle libc crash at launch on Linux. Bisected to this merge. The #693 double handshake comes back with the revert; happy to look at a reworked version that initialises the bundled copy or routes its allocator to ours, with a test that calls a title's bundledmalloc.