relinker: RetroArch (PPSA99169) can't convert its libretro cores: two are refused for DF_SYMBOLIC, and cores exporting the same name make another core's import ambiguous #5927
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 orishamir on 2026-10-14T16:10:56Z.
RetroArch (PPSA99169, catalog 1.0.0-beta.1) ships 33 libretro cores as ELF shared objects in
app0/cores/. It needs them converted with--module-dir coresbefore it can load any of them. That conversion fails for two reasons, both with a Linux relinker built frommain84b01f9cdand a Windows relinker built frommain28b6f1987(with an unrelated libSceNgs2 change merged). Each of the other 31 cores converts when it is the only one incores/.1. Two cores are refused for
DF_SYMBOLIC.azahar_libretro.so(3DS) andppsspp_libretro.so(PSP) haveDT_FLAGS=SYMBOLIC BIND_NOW(readelf -d). The other 31 cores haveBIND_NOWonly.GuestImageReader.cpp:160acceptsDT_FLAGSbit 8 alone, and theDT_SYMBOLICtag (16) is refused too.2. Cores that export the same name make another core's import ambiguous.
With the two cores above set aside:
dolphin_libretro.soandpcsx2_libretro.soeach definegetaddrinfo.flycast_libretro.so,mame_libretro.soandvirtualjaguar_libretro.soimport it without a library. The cores'DT_NEEDEDentries name only system libraries (libkernel_web.sprx,libSceLibcInternal.sprx,libScePosixForWebKit.sprx), and no core names another.The executable's imports are matched only against guest modules in its own
DT_NEEDED(GuestModuleBuilder.cpp:194). A module's import with no declared library is matched against every guest module (GuestModuleBuilder.cpp:214-226). So two sibling plugins that both define a libc-style name block every third plugin that imports it.Question. Should a guest module's undeclared import be matched only against guest modules in its own
DT_NEEDEDclosure, as the executable's imports are? Then these imports fall through to the system libraries. That would change binding for every guest module with undeclared imports, so I haven't made a PR.For
DF_SYMBOLIC: on Windows a converted module is a DLL, and its references to its own definitions already bind internally. On Linux the converted.sowould need the flag carried over for its own definitions to win over the executable's. I haven't checked how the Linux writer binds a module's references to its own exports.Separately, an intermittent crash. Converting with seven of the cores that do convert together (fceumm, snes9x, genesis_plus_gx, mgba, stella, scummvm, dosbox_pure), the Windows relinker (WinLibs GCC 15.2.0, Release) crashed with 0xC0000005 in 4 of about 35 runs of the same command on the same files. Under gdb, with a Release relinker rebuilt with
-gadded, the fault is on the main thread, inorder.push_back(CheckedRva(index))atWindowsEntryStubBuilder.cpp:147([...]marks argument lists that were cut off in my capture):The only other thread was idle in
ntdll!ZwWaitForWorkViaWorkerFactory. A crash of the plain Release build under gdb stopped in the same function (WindowsEntryStubBuilder::BuildfromWindowsPePatcher::Patch; no line information in that build). It didn't happen in 20 runs each of an-O2 -gbuild and a-D_GLIBCXX_ASSERTIONSbuild, or in 5 runs of an ASan relinker on Linux writing the same Windows output. So I don't know the cause.Not established. Whether RetroArch then loads and runs a converted core. On
mainit reaches its frontend picker with--executable picker/picker.bin. I haven't loaded content with a core.AI-assisted: yes (Claude Code Opus 5.5)
Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-14T16:19:51Z.
Two more things stand between the cores and a working load, found with two cores that convert together (fceumm and mgba), on
maine34c47921(Windows, RTX 4080). RetroArch then exits 3 s in with 0xC0000139:.sprxdependency names are used as library file names. The cores'DT_NEEDEDentries arelibkernel_web.sprx,libSceLibcInternal.sprxandlibScePosixForWebKit.sprx.GuestModuleBuilder.cppaddHostpasses them through unchanged, so the startup looks forlibs\libkernel_web.sprxand reports-> not found; nothing is imported from it, continuing without itthree times. AnyPS5 ships them as.prx. ThelibSceLibcInternal.prx->libc.prxrule doesn't fire for the.sprxspelling either..sprxnames (only to see what comes next), they load, but all 140 imports stay unresolved (FAIL: unresolved ELF import memset,malloc,__error,__isthreaded, ...).libc.prxexportsmemsetonly as8zTFvBIAIN8, and I found no name-to-NID translation in the relinker.So loading a plain-ELF guest module like these needs
.sprxnames mapped to.prxand plain-name imports translated to NIDs, besides the scope andDF_SYMBOLICpoints above. I can implement this in the relinker if that's the direction you want. It sets how plain-ELF guest modules bind, so I'm asking first.AI-assisted: yes (Claude Code Opus 5.5)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T18:05:21Z.
PR #5981 addresses the
DF_SYMBOLICconversion blocker only: the reader records the flag and the Linux guest-module writer preserves it together withDF_BIND_NOW. The relinker integration test verifies the output flags. The ambiguous undeclared imports and intermittent Windows relinker crash from this issue remain unaddressed; I did not infer a binding policy for them.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T18:19:00Z.
Thanks for offering to take the remaining plain-ELF loading work. Yes, please proceed with a focused relinker PR for the observed
.sprxdependency names and plain-name imports, with synthetic tests that prove dependency names resolve to the shipped.prxmodules and representative imports (includingmemset→8zTFvBIAIN8) resolve through the converted module path.Nid::ComputeNidalready produces that NID, andDynamicLoader::FindSymbolhas a fallback for explicitdlsym; the tests should specifically cover ELF relocation imports, since thedlsymfallback alone does not prove those are handled.Please keep the sibling guest-export ambiguity policy and the intermittent Windows relinker crash out of that change; they need separate evidence. A successful conversion/load test for the two-core case would be useful, but avoid claiming RetroArch is playable unless content actually runs.
Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-14T21:26:16Z.
I started on the relinker change and stopped. Two findings change what it should be, so I'm not opening that PR yet:
src/core_loader_ps5.cpp). Each undefined symbol goes throughps5_core_import(name). That table is generated from the cores' imports bytools/core-imports.pyand points at symbols linked into the title. 81 names are redirected to the title's own replacements:malloc/calloc/realloc/operator newgo tops5_core_*(a core allocates from direct memory "so it cannot starve the libc heap"),pthread_createand the TSD calls go tops5_core_pthread_*,dlopen/dlsymtops5_cores_dlopen/ps5_cores_dlsym,syscalltops5_syscall, and so on. So binding the plain-name imports to AnyPS5's libraries by NID, as I offered, gives the cores different functions than on the console: for example AnyPS5'smallocinstead of the title's allocator, or a realpthread_createinstead of the title's thread factory.Nid::ComputeNid(name),guest_module_argsfails on Linux: its module importsRecordArgsby plain name from a host library that exports that plain name, and the converted module then asks ford9+l6fKWZBY. So plain-name binding to a plain host export is something the relinker already supports and tests.Mapping the cores'
.sprxdependency names to the shipped.prxfiles is straightforward, but on its own it leaves every import unresolved.On the console these cores never go through the system loader, so the route that matches it is the title's own loader running inside AnyPS5, with no relinker conversion of the cores. I haven't tested what that path does on AnyPS5 yet. Which route do you want: support the title's loader, or convert the cores with a binding rule of your choice?
AI-assisted: yes (Claude Code Opus 5.5)
Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-14T21:37:17Z.
@boykopovar, a question for you, since you wrote the guest-module discovery: the comment above asks how plain-ELF modules like these cores should be handled. Either the title's own loader runs them inside AnyPS5, or the relinker converts them with a binding rule you choose. I'd rather not pick that for the project.
AI-assisted: yes (Claude Code Opus 5.5)
Imported from boykopovar/AnyPS5. Originally posted by WallfacerX on 2026-10-14T23:28:23Z.
@boykopovar I have a local Windows guest-export fix with a regression using 65,537 distinct function targets. It fails on main and passes with the change, including runtime lookup through startup imports and guest dlsym.
With #5981 applied separately, unchanged Azahar also converts successfully and preserves all 90,705 export names. I have not run the core.
Given the findings about RetroArch’s own ELF loader, would you accept this as a focused converter fix related to #5927? I want to confirm it meets the title-needed requirement before opening my first PR.
AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:00:05Z.
Runtime note: title ELF loader works on AnyPS5 (Windows)
Picked up the open question about “title loader vs relinker conversion.”
On PPSA99169 with stock
fceumm_libretro.soleft inapp0/cores/(no relinker conversion of that core), RetroArch’s in-process loader opened the.soand FCEUmm came up far enough to allocate 256×224 guest textures and run at ~120 FPS for 20k+ frames. Host stack was main + HostFileReady libkernel (#5999) + existing Agc libs.That matches the finding that cores bind via
ps5_core_importinside the title: conversion/DF_SYMBOLIC/ambiguous guest exports are not on the critical path for this title’s console-shaped load.Still open here: getting a ROM through
sceKernelOpen(smoke.nesnot seen yet) and dumping post-core frames. Happy to keep poking content load; this is just the loader-route evidence.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:08:49Z.
Confirmed: title ELF loader + content (not relinker cores)
Follow-up with a real ROM path:
/app0/test-run.txt+/app0/args.txt(-L+fceumm_libretro.so+smoke.nes+--max-frames-ss).so(no relinker conversion of the core)Loading content file: "/app0/content/smoke.nes"→ geometry 256×224/app0/screenshots/smoke.png; content ran ~9sSo for RetroArch, the console-shaped route (title
ps5_core_importloader on unmodified cores) already works on AnyPS5 Windows with HostFileReady (#5999). RelinkerDF_SYMBOLIC/ ambiguous exports remain relevant for converted modules, but they are not required to get FCEUmm+ROM on screen.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:11:05Z.
Pixel follow-up: empty-CHR
smoke.nesexplained the gray shot. A tinychecker.neswith filled CHR produced a visible tile grid in/app0/screenshots/checker.pngvia the title loader + stockfceumm_libretro.so(no relinker conversion).Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:12:43Z.
mGBA note: stock
mgba_libretro.soalso loads through the title ELF loader (core loader: ready … mapped_bytes=3293184). It then exits withLibretro core requires content, but nothing was provided— expected without a ROM. Same route as FCEUmm.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:13:33Z.
Same for Snes9x: stock
snes9x_libretro.soloads (core loader: ready symbols=182 relocations=7952 mapped_bytes=6815744) and exits only for missing content. So FCEUmm / mGBA / Snes9x all take the title ELF loader path on Windows.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:14:14Z.
Core loader survey (Windows, stock
.so, title ELF loader)With
/app0/test-run.txt+args.txt-L <core>(no ROM):checker.nes→checker.pngtile grid)Host stack includes HostFileReady (#5999). Relinker conversion of these cores was not used.
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:18:45Z.
mGBA + homebrew µCity (
ucity.gbc) also runs: geometry 160×144, screenshot written. Same title-loader path as FCEUmm.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-15T07:22:50Z.
Pad inject on mGBA+µCity reaches the in-game Select Slot menu (not just the title screen).