Repository navigation
PS4 executables on AnyPS5: first results (a PS4 homebrew runs) and what retail PS4 games would need #3094
Get-fix
started this conversation in
Architecture changes
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
In #159, boykopovar wrote:
and, about versioning of system libraries:
So I tried it. The relinker fixes and the remaining work are tracked in #3093.
Short answer
libSceGnmDriver, the PS4 GPU driver. AnyPS5 implements the PS5 one (libSceAgcDriver) and has nolibSceGnmDriver.What I tested
graphicssample: it draws a Mandelbrot set on the CPU straight into the frame buffer. I used their prebuilt sample ELF and packaged it into a PS4 eboot with OpenOrbis create-fself v1.3.mainat 262c031, and no PS4 hardware.Two relinker fixes (ready)
fix/relinker-sce-dynamic-tables: DT_SCE_* table values are offsets into PT_SCE_DYNLIBDATA, not file offsets.fix/relinker-scan-code-extent: for executables with PT_SCE_DYNLIBDATA, the syscall and call-site scans stop at the end of the PLT. Bloodborne keeps 37 MiB of read-only data after its code, and the scans decoded it as code.Checks:
ctest:
mainNew tests: each fails on
mainand passes with its fix.Mutation checks: all six are caught.
PS5 executables: ps5-doom, VLC and Jelly5 convert byte-identically to
main.Details are in the issue.
Where each executable stops
Relinker only, current
main:mainDynamic string offset is outside DT_STRSZSymbol table entry out of boundsUnsupported 0F 79 opcode without SSE4A prefix(data decoded as code)RELATIVE relocation has a nonzero symbol indexCode analysis: overlapping instruction boundaries (offset 0x3457cf)(inline jump tables)The homebrew on screen
With both fixes and the experimental changes below, the sample did the following:
main()ran and printedCreating a sceneandEntering draw loop;OpenOrbis graphics sample | FPS: 3.4.I dumped frames from its display buffer. They match the sample source: only the blue channel varies, the set is black, and every frame is the same. The low frame rate is expected, because the sample recomputes the whole 1920x1080 image on the CPU every frame (Debug build). I haven't compared it with real hardware.
What it needed, in the order it hit them:
R_X86_64_RELATIVEwith symbol index 1, a value-0STT_SECTIONsymbol. The relinker rejects it.PT_INTERP. The CFG followed pointers into the/libexec/ld-elf.so.1string at the start of text.sceVideoOutSetBufferAttributeandsceVideoOutRegisterBuffers(PS4 names) are absent. They map onto the...2functions with pixel format((f & 0xFFFF0000) << 32) | ((f & 0xFFFF) << 16), so 0x80000000 becomes 0x8000000000000000.__error: the sample imports it from libkernel, but AnyPS5 exports it from libc.prx. libc.prx is only added when libSceLibcInternal.prx is needed; PS5 games always need it, this sample doesn't.param.json: AnyPS5 requires it, but PS4 titles shipparam.sfo. I used a minimal param.json.sceVideoOutGetFlipStatus(see below)._readv,_writev,_fcntl,_ioctl: thin wrappers over existing functions.Side finding:
APS5_DUMP_FRAMESwrites nothing for linear display buffers.VulkanDevice::PresentDisplayBufferreturns from the linear path before the dump code, so this also affects PS5 titles.On the two statements in #159
"the PS5's system libraries have everything needed"
The console may well ship everything. AnyPS5, though, reimplements the libraries PS5 games use, and PS4 games also need some outside that set. Bloodborne has 701 imports, and 233 of them come from the game's own bundled
libc.prxandlibSceFios2.prx. That leaves 468 system imports:libSceGnmDriver;"no problems with versioning system libraries"
There is one data point for PS4 callers.
sceVideoOutGetFlipStatushas the same NID on both consoles, but:SceVideoOutFlipStatusis 0x40 bytes;The first 0x40 bytes have the same layout (
flipArgat 0x18). The other 0x40 bytes landed on the savedrbpof the sample's flip-wait function, and it crashed right after the first flip. Writing 0x40 bytes fixed it. So PS4 support needs a way to tell PS4 callers apart, for example PT_SCE_DYNLIBDATA in the executable or its SDK version. I don't know how the PS5's own library does it.What PS4 games would need
libSceGnmDriverand the PS4 GPU path behind it. PS4 shaders are GCN code, while AnyPS5's shader recompiler targets the PS5's RDNA 2 instructions. The two are related but not encoded the same way, so this needs a GCN front end or a separate path. I haven't measured how much of the existing recompiler could be reused. shadPS4 implements this layer for its PS4 emulator and could serve as a reference.Items 1–3 are enough for CPU-drawn homebrew. Retail games need item 4, which is a decision for the maintainers.
I can share the dumped frames and the experimental changes if that helps.
AI-assisted: yes (Claude Code). I ran every result above locally.
🤖 Generated with Claude Code
All reactions