Linux: .native wrapper libraries have no dependency edge to their plain twin, so guest modules cannot bind #906
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 jeffrey12cali on 2026-10-06T15:36:51Z.
Symptom
On Linux a title's own module can never be loaded, and the title spins on it forever. Measured on PPSA28997 after its intro movies:
wTpfglkmv34issceMsgDialogProgressBarSetValue. The boot sequence stops dead there - the title is not waiting on an event or on input, it is retrying a load that cannot succeed.Cause
The guest module's
DT_NEEDEDnames the.nativewrapper, but the symbol is exported only by the plain library, and no edge connects the two:wTpfglkmv34DT_NEEDEDmentions its plain twinlibs/libSceMsgDialog.native.prxlibs/libSceMsgDialog.prxConfirmed live:
/proc/<pid>/mapsshows onlylibSceMsgDialog.native.prxmapped, so the defining object is never in the new module's lookup scope andRTLD_NOWbinding fails.The same shape exists for every
.nativewrapper - none of the nine has aDT_NEEDEDedge to its plain twin - and several have exports that exist only on one side:libSceSaveDatalibSceMsgDialoglibSceAudiodeclibSceSharelibSceSaveDataDialoglibSceAjmlibSceAvPlayerlibSceFontlibSceNgs2Why Windows does not hit this
PE import resolution binds against every module already loaded in the process, and the Windows relinker points guest imports at the library that implements them. ELF lookup is scope-based, so on Linux naming only the wrapper is enough to fail. This is the same family as #694 (process-wide vs scoped symbol lookup), just at load time rather than at
dlsymtime.Reproduction
Any title whose module imports a symbol that lives in a plain library while its
DT_NEEDEDnames the.nativewrapper. For this title: relink, launch on Linux, and watch forundefined symbol: wTpfglkmv34fromdlopenof the title's ownPSN.prx.Possible fixes
.nativewrapper aDT_NEEDEDon its plain twin (or the reverse) so the pair is always in one scope.DT_NEEDEDinstead of the wrapper.dlopens.Not sufficient on its own
With
libSceMsgDialog.prxforce-loaded for the test,PSN.prxloads and the title then faults inside it atPSN.prx.guest.prx+0x3ee7on the main thread - a separate problem, presumably the next wrapper edge in the table (libSceSaveData, 26 plain-only exports, is also in that module'sDT_NEEDED). Reporting this one first because it is what makes the title stop booting.Unrelated but worth noting from the same investigation: of the 2315 unimplemented NID imports our prepared tree stubs, exactly one is ever called by this title (
dbOlWdppb4o, 24 times, which ps5rs attributes tosceAgcCreateInterpolantMappinginlibSceAgc) - so the backlog size is not what is blocking boot.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-06T22:50:26Z.
Same question as #918: @jeffrey12cali are you still planning to send a PR for this, or should someone else take it? Happy to pick it up if you are not, but I do not want to duplicate your work.
Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-06T23:09:01Z.
Please take it — I have a title-side stopgap for now, and one measurement that should shape the implementation, because the obvious fix regresses this title.
The obvious fix is to give each
X.native.prxwrapper a realDT_NEEDEDedge to the plainX.prx. I built it (linking the twin into the wrapper targets) and the load does succeed — but every wrapper in the executable'sDT_NEEDEDis in the global scope on Linux, and the pairs share NIDs:libSceAvPlayer30 exports with all 30 overlapping,libSceSaveData41 with 14 overlapping,libSceMsgDialog7 with 6. Pulling the plain twin in globally rebinds other modules to the wrong implementation, and the title then fails earlier than before: it prints its plugin-error block and never reaches the load that motivated this issue.So the fix has to keep the twin out of the global scope. Two shapes look right to me:
What I do today is a targeted version of (1), at prepare time: rewrite the importing module's own
DT_NEEDEDstring fromlibSceMsgDialog.native.prxtolibSceMsgDialog.prx. The replacement is shorter than what it replaces, so it fits the existing string-table slot and no table has to grow.Repro: PPSA28997, Linux relink. The title retries
dlopen(/app0/Media/Plugins/PSN.prx, RTLD_NOW)1518 times per path variant, and every attempt fails withundefined symbol: wTpfglkmv34(sceMsgDialogProgressBarSetValue, exported bylibSceMsgDialog.prx, absent fromlibSceMsgDialog.native.prx). Happy to test whatever you land against this title.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-06T23:13:56Z.
Implemented option 1 in a PR: each
.nativewrapper now links its plain twin on ELF targets, so the twin is in the wrapper's lookup scope. Verified locally —dlopen(libSceMsgDialog.native.prx)leaveslibSceMsgDialog.prxunmapped before the change and maps it after, for all nine wrappers; 369/369 tests pass. @jeffrey12cali if you already have this in a branch, say so and I will close mine.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-06T23:14:55Z.
Thanks — and that measurement saved me from shipping a regression: #1009 took the
DT_NEEDEDedge approach and is now closed.Taking it on the basis you describe: the twin has to stay out of the global scope. I am going to look at the relinker side first — where the converted guest module's
DT_NEEDEDis emitted, and whether it can name the library that actually defines the imported NID instead of the wrapper (your stopgap, applied at conversion time rather than at prepare time). If that turns out to be the wrong layer I will look at the wrapper re-exporting the plain library's symbols instead.Your repro numbers are very useful; I will use the nine pairs and their overlap counts as the constraint to check against. If you would rather keep it and land your own version, say so and I will drop it.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-06T23:17:28Z.
One measurement that constrains the shape, from a minimal ELF repro on this box (glibc, x86-64). Three shared libraries:
libtwin.so(definestwin_sym),libwrapper.so,libmod.so(the "referring object"), and an executable.dlsym(RTLD_DEFAULT, "twin_sym")from a laterdlopenDT_NEEDEDon the twin (the approach in the PR I closed)DT_NEEDEDon the twin and isdlopened, not in the executable'sDT_NEEDEDdlsym(module, "twin_sym")still resolvesDT_NEEDEDon the twin and is in the executable'sDT_NEEDEDSo shape 1 keeps the twin local only when the referring module is not in the executable's
DT_NEEDED.GuestModuleBuilder::Buildcurrently adds every converted guest module to the executable'sDT_NEEDED(for (const auto index : order) addNeeded(...)), so a per-module twin edge on its own would still land in the executable's closure and rebind, which matches what you measured.It also explains why your stopgap works: it replaces the wrapper name rather than adding the twin alongside it, so no pair is ever in one closure.
Two shapes that stay local, then:
DT_NEEDED(which may conflict with the current initialization ordering), orHappy to implement whichever you and @boykopovar prefer. I would rather ask than guess again after closing #1009.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T01:11:00Z.
I measured the pairs before touching any ELF scoping, and the premise behind the
DT_NEEDEDedge turns out to be mostly wrong: eight of the nine wrappers already export every symbol their plain twin does.Counts from a Release build of
libs(nm -D --defined-only, plain vs.native):_ZNKSt5ctypeIcE8do_widenEcDummyFunction_nid_no_patchDummyFunction_nid_no_patchOnly
libSceShare.nativeis genuinely incomplete. It is missing four exports the plain library has:sceShareCaptureScreenshotExtended— implemented there: zeroes the request id and answersERROR_NOT_SUPPORTEDsceShareCaptureVideoClipExtended—NotImplemented_nid_no_patchin the plain library toosceShareGetRunningStatus— samesceShareSetContentParamForApplicationTitle— sameThe other three differences are not NIDs at all: a
std::ctypetemplate instantiation the linker happened to export, and theDummyFunction_nid_no_patchplaceholder of two libraries that have one real export each.libSceAjm.nativeandlibSceNgs2.nativeare the wrappers with the most exports in the whole set (37 and 35).So an edge is not needed for eight of the nine pairs, and for the ninth the fix is to add four declarations to
libSceShare.native— noDT_NEEDEDedge, no second copy of anything in the global scope, and nothing for the pairs to rebind against. I am sending that as a PR instead of the scoping change.That leaves one thing the overlap numbers do not explain, and I would rather ask than guess again. The original
undefined symbol: wTpfglkmv34is defined in bothlibSceMsgDialog.prxandlibSceMsgDialog.native.prx, and (as you measured) the wrappers are in the executable'sDT_NEEDED, so a global lookup should find it. Is the conversion giving that plugin aDT_NEEDEDlist that does not name the library it imports from — the relinker picking the wrapper where the NID actually lives in the plain twin — or is/app0/Media/Plugins/PSN.prxloaded in a way that does not consult the global scope at all?Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T01:17:16Z.
Sent as #1024:
libSceShare.nativenow exports the four symbols it was missing, with a behavioural test. No dependency edge, no lookup-scope change — the wrapper defines them itself, so nothing extra enters the global scope. Full suite 372/372.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-07T02:08:51Z.
Correction to my measurement above, after @oneandonlydean pointed me at #228.
I concluded from the symbol counts that
libSceShare.nativewas "the only genuine gap" and that adding the four exports to the wrapper was the fix. That conclusion is wrong. The owner's rule in #228 is that a title importinglibSceXalso loadslibSceX.native, so the symbols are found from whichever of the pair is present, and a copy in the other library is not needed (Font being the known exception, where a title loads only one). Under that modellibSceShare.nativenot exporting whatlibSceShareexports is not a load failure at all, and #1024 was closed for exactly that reason.What survives from the measurement is the part that does not depend on that conclusion:
libSceShareexports are still the only real difference between a pair, andlibSceShareis loaded alongside the wrapper.So the question this issue actually turns on is the one @oneandonlydean raised on #1024: whether a module's import is resolved by how the plain library is found, rather than by what the wrapper exports. That matches the original symptom better than my reading did —
wTpfglkmv34is defined in bothlibSceMsgDialog.prxandlibSceMsgDialog.native.prx, so a module that cannot see it has a lookup-scope problem, not a missing-export one.I do not have a title to reproduce the
undefined symbolline with, so I cannot settle it; leaving the measurement here for whoever can.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-07T05:16:10Z.
Please land the
libSceSharefix - I would rather have that than any scoping change, and I will not duplicate it.Your counts and mine are both correct, and the reason is a snapshot difference worth writing down, because it explains why the wrapper looked incomplete here:
sos-v0.2.2(c8830699), builtlibsmainbuildlibSceMsgDialog(plain) exportswTpfglkmv34libSceMsgDialog.nativeexportswTpfglkmv34absentThe runtime agrees with the numbers rather than with either of us: on our pin
dlopen(/app0/Media/Plugins/PSN.prx, RTLD_NOW)fails withundefined symbol: wTpfglkmv34, and onmainthe wrapper source declares it (core/libs/prx/libSceMsgDialog.native/Export.cppcontainsProgressBarSetValue). So the specific gap we hit was closed onmainbetween those snapshots, and an edge really is unnecessary there now - onlylibSceShare.nativeis left incomplete, which is what your PR fixes.Two things from this thread I would keep even though the edge is gone:
GuestModuleBuilder::Buildadds every converted guest module to the executable'sDT_NEEDED, so a per-module dependency added to any module that is also in that list lands in the global closure by construction. If a title ever needs a twin that a wrapper cannot re-export, that is the wall it hits, and the two shapes you listed are the only ones that stay local.For completeness, our side of this is temporary and self-labelling:
tools/sos_linux/twinscope.pyreplaces the importing module's ownDT_NEEDEDstring with the plain twin's name (a shorter string in the same slot, so no table grows) at prepare time, purely because we are pinned tosos-v0.2.2. When we re-pin ontomainit comes out: the wrapper already answers the import, and your PR closes the last pair.Thanks for measuring instead of defending the first approach - the repro and the table made this thread much better than my report did.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T08:26:11Z.
Closing: on main
libSceMsgDialog.nativeexportswTpfglkmv34, so the module binds without a dependency edge, as measured above. If a title still fails withundefined symbolon current main, please comment with the log and it can be reopened.Imported from boykopovar/AnyPS5. Originally posted by jeffrey12cali on 2026-10-08T11:56:26Z.
That matches my side, and the close is correct.
Our difference was only the snapshot. On
sos-v0.2.2(c8830699) the wrapper exports five symbols andwTpfglkmv34is not among them, which is whydlopenof the title'sPSNmodule failed there with that exact name. On currentmainthe wrapper declares it, so no dependency edge is needed.Our runner still carries a title-side stopgap for the older pin, because we are 18 commits behind. It replaces the importing module's own
DT_NEEDEDstring rather than adding a second library, so nothing new reaches the global scope. It comes out when we re-pin.