fix(relinker): retain declared import library identities #1617
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1617"
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 eliasbruno124-dev on 2026-10-08T14:58:33Z.
What
Depends on #1503. This branch contains its corrected head
188dd9f5f814d2f258c5ac04775ba42ec80374c5and main4b005b229e24be9ec3f185def9e59cbc03aa9e4a. The library-owner change remains 98d9184b; merge #1503 first. The update preserves the generalized module/library resolver and includes the parent's.sprxhandling, with additional library-owner tests.When an import's module name does not match a declared dependency, the relinker drops its owner even if the library qualifier identifies that dependency. On Windows a colliding export can then bind to the first unrelated provider. The regression returns 11 from that provider instead of 22 from the declared one.
Read
DT_SCE_IMPORT_LIBin both executable and guest readers. If module resolution finds no dependency, resolve the library qualifier against the existing dependency list. Exact and normalized module matches retain precedence. When module resolution succeeds, the library qualifier is not used. Otherwise, no library table or a declared library without a matching dependency retains the broad fallback requested in #684. A referenced ID missing from an existing library table is malformed and throws, as do invalid names and ambiguous matches. No libraries, export implementations or title-specific aliases are added.Original input PPSA27836 / 01.000.001 demonstrates the mismatch: imports declare module
libSceJson, librarylibSceJson2, and dependencylibSceJson2.prx.Tested
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON. Corrected parent188dd9f5: 37/37 registered groups pass. Current commit847feacc09bec211d8025002102e63e812137cb5: 38/38 pass, without failures or skips. Conventions andgit diff --checkpass. CI for this exact head passes the Linux and Windows full builds/tests and the relinker jobs on Linux, Windows and macOS..prx/.sprx/.suprxand native spellings, duplicate/invalid IDs, malformed metadata, ambiguous names, unresolved symbols and the existing fallback. The PR1503 identity regression also passes.7d3b3930. All 1,815 emitted import occurrences / 896 unique queries were inspected: 84 previously unqualified owners now agree with the original library metadata and declared dependencies (62 Json2, 7 AppContent, 7 SaveDataDialog.native, 8 MsgDialog.native); the other 812 records are unchanged. Inputs and host binaries retain their hashes. Original filenames and HDD content were not changed.4b005b22and the corrected #1503 parent. The shared resolver conflict was resolved locally and the result was tested above.Overlap rechecked on October 9 against main
f1451396: this branch and #1815 merge cleanly together. Both inherit #1503 (188dd9f5), including the identicaltest_guest_module_identity.py; neither follow-up depends on the other. This branch also merges cleanly with that main.Checklist
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T16:33:18Z.
Verified the same way as #1503 — by replaying the merge and running the fields, not by reading the diff.
Scope and replay. This PR's own change is the single commit
98d9184b(5 files, +171/-25:ImportModule.hpp,GuestImageReader.cpp,RelinkerPipeline.cpp, the CMake registration and the new test). I cherry-picked it onto today'smain(4b005b22) with #1503 already merged, in the order your body asks for:Negative control. Reverting only the three implementation files to
2eae8ac7(its parent, i.e. #1503 without this change) and keeping the test:So the regression does gate this change: on the #1503-only tree the owner is dropped and the colliding provider answers 11 instead of 22, which is the failure your body describes.
Not a duplicate. I checked the symbol rather than the topic:
0x61000049,importLibrariesandImportLibraryappear nowhere else among the open PRs that touch this area (#1403, #1529, #1507, #1446, #1661, #1462, #846) — only in this PR and its stacked base. Nothing to reconcile.The new failure modes are pinned by tests, which is the right call. The refactor widens the throwing surface:
resolveis now reached through the library qualifier, so a symbol whose library qualifier is?, empty, malformed, or an ID that is not declared inDT_SCE_IMPORT_LIBthrows where #1503 (andmain) returned an empty owner. Your test asserts all four (shared#?#B,shared##B,shared#QAA#B,shared#B#B) plus the invalid declared-name case, and separately asserts that a declared but unmatched library still yields the empty owner (library='unmatched',library=None) — so the boundary between "unowned import" and "hard error" is deliberate and covered rather than accidental.One question, since that boundary moved. An empty owner means "treat this as a host-side import" downstream, and it used to be reachable for any symbol whose library qualifier was not a declared dependency. Now the same input throws if the qualifier is not declared at all. That is fine if PS5 toolchains always emit a
DT_SCE_IMPORT_LIBentry for every library an import names — which the tag's purpose suggests — but it does mean a title that used to convert with an unowned import will now stop at the relinker. Worth one sentence in the body confirming you saw no such case in the Castlevania run, or a note that it should be impossible by construction; the review will otherwise ask.Everything else checks out: the
0x61000049reader sits before the catch-all that previously discarded those tags into nothing, both readers build the ID map with the same>> 48/0xffffffffconvention as the module imports, and duplicate IDs still fail loudly on both sides.Neither PR has a maintainer review: this one has no reviews and no comments at all, and #1503's single approval carries no review body. Both are green and mergeable and land in order without conflict, so the pair is a clean unit of work for whoever reviews next.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by eliasbruno124-dev on 2026-10-08T17:03:21Z.
@Dextroid17 Confirmed against the retained original Castlevania metadata: all 1,525 qualified undefined symbol entries across its 13 code files reference declared import library and module IDs. No undeclared-library case was observed. The broader bounded check covered 23,736 entries across 141 files, with 12 other inventoried files not covered; this does not establish a universal toolchain guarantee.
The body now states that distinction and the fallback/error boundary explicitly. Updated to the corrected #1503 parent, preserving module precedence and adding .sprx library-owner coverage. Current head
847feaccpasses all 38 registered groups locally on Windows; the identical final fixture still fails on the parent with the wrong-provider result. New CI is running.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T17:17:16Z.
Checked the update at
847feacc:The 23,736/141/12 scoping is the right way to state it: it answers my question about the undeclared-library boundary without turning one title's inventory into a universal claim. Nothing further from me on this one either.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T20:41:03Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/relinker/relinker/tests/test_guest_module_identity.pyImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:54:56Z.
Closing: on top of #1503 this doesn't change a title run (PPSA27836 has the same missing imports either way), and the colliding-provider case only exists in the synthetic test. Please reopen with a title where main binds an import to the wrong provider.
Pull request closed