fix(relinker): retain qualified Linux guest import providers #15942
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15942"
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 nikhilpanchal1 on 2026-11-05T01:57:11Z.
What
A Linux executable or guest module could explicitly import from module B but bind to module A when both exported the same name. The converter selected B for its dependency graph, then gave both exports the same lookup name. Qualified executable imports could also be rejected as ambiguous.
Bind qualified imports through deterministic provider-specific aliases. Keep generic exports for
dlsym, preserve symbol metadata and zero-address thunk identity, and retain compatibility with ordinarySTT_NOTYPEdefinitions. Actual type/TLS mismatches still reject.Related to #5927. Undeclared-import ambiguity policy and existing macOS behavior remain unchanged.
Tested
Debian 13 x86-64, GCC 14.2, Python 3.12.14, Release,
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON. Base:acac7c854182; reviewed head:ccbfff364c.title_runchild-process cleanup test.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T00:52:32Z.
Review: COMMENTED
Tested on Windows 11 x64 with WinLibs GCC 15.2.0
15.2.0posix-14.0.0-ucrt-r7(as in CI), its CMake 4.3.1 and Ninja 1.13.2, and Python 3.15.0. Relinker-only Release build, head433570f4merged intomain9ade3ed8.ctest --timeout 120 --parallel 4: 794 tests. Nine timed out in that run while the machine was under other load, and all nine passed when rerun alone, both on this head and onmain.mainalone passed 793/793.test_linux_guest_qualified_imports.pyfails against themainrelinker atassert len(aliases) == 1({'shared#guest': (18, 0, 1, 4096, 6)}) and passes with this PR.Interaction with #16384. #16384 also accepts, on Linux, identical ordinary function exports that share a stripped name. Linux conversion built with the
guest_symbolsandconverthelpers oftest_guest_export_lookup.py, witha.prxexportingentry#A#Aandentry#B#A(both0x12, same address):b.prxexportsentryb.prxexportsothermain, and this PR aloneDuplicate or empty export after stripping #: entryDuplicate or empty guest binding alias: entry#module0#guestBoth copies of
entryina.prxare exported andentryis insharedExports, so the newBindingAliases.emplace_backinGuestModuleBuilder.cppaddsentry#module0#guestonce per symbol index, andLinuxGuestModuleWriterrejects the second. Keeping one alias per name and module fixes it:I applied that change to the merge of both PRs. Both cases above then convert, and these 10 tests pass:
guest_needed_modules,guest_module_directories,linux_guest_stack,guest_symbol_names,guest_host_libc,linux_guest_qualified_imports,linux_guest_zero_address_exports,guest_unused_import_dependencies,guest_export_lookupandlinux_guest_named_imports. Whichever of the two PRs lands second needs it.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T01:33:24Z.
Review: COMMENTED
Windows check of head
433570f454, merged ontomain210676ad86(clean merge).Setup: Windows 11, WinLibs GCC 15.2, Release, relinker-only.
linux_guest_qualified_imports,guest_symbol_names,guest_export_lookup,guest_needed_modules,guest_host_libc,guest_module_directories,guest_symbolic_modulesand thelinux_guest_*tests.test_linux_guest_qualified_imports.pyand the updatedtest_guest_symbol_names.pyboth fail against themainrelinker, so they cover the change.Interaction with #16384. Each PR passes on its own, and the two merge cleanly, but together they reject a module that #16384 alone accepts. #16384 lets a Linux module export the same stripped name twice when both entries are identical functions. This PR then emits one
BindingAliasesentry per exported symbol index, so that module gets two aliases with the same name, andLinuxGuestModuleWriterthrows.Repro on
main+ #15942 + #16384, using theguest_symbolshelper fromtest_guest_export_lookup.py:a.prxexportsentry#A#Aandentry#B#A(bothFUNC, section 1);b.prxexportsentry.Duplicate or empty guest binding alias: entry#module0#guest.b.prxexportsotherinstead): exit 0. With #16384 alone, both cases convert.A per-module set in the alias loop of
GuestModuleBuilder::Buildavoids it: declarestd::set<std::string> aliased;before the inner symbol loop and add&& aliased.insert(symbol.Name).secondto theBindingAliasescondition. Whichever of the two PRs lands second should carry that guard, plus a duplicate-entry case in the test.