relinker: route ps5-payload-dev SDK syscall stubs to the libkernel exports that already implement them #10219
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 VakzOs on 2026-10-23T14:24:21Z.
Follow-up to #2136, which #3804 closed by adding
--trap-sdk-syscall-stubs.What happens
Homebrew built with the ps5-payload-dev SDK carries numbered syscall stubs (
mov rax, N; mov r10, rcx; syscall; ret). Without--trap-sdk-syscall-stubsthe relinker refuses the executable:With the flag the stub becomes
UD2. The title converts, and it crashes only if the stub runs. USAGE.md documents the flag as debugging only.The flag is now part of the normal recipe for catalog homebrew. Public reports collected on the blocker map use it for 18 titles:
A 19th is Apotris (PPSA98513, catalog v1.0.0), tested this week.
One case, disassembled
I looked at a single title. In Apotris the only raw syscall in the executable is that stub. Its number is 191, FreeBSD
pathconf. It has one caller:The caller sits next to the
current_pathstring, which matches libc++std::filesystem::current_path(). AnyPS5 already implements this call aslibkernel_syspathconf, including name 5 = 1024. Only the route is missing.Proposal
When the relinker matches an exact numbered SDK stub whose syscall number is on a fixed list, it would replace the stub with a jump to the libkernel export that implements that syscall, instead of
UD2. The stub's arguments are already in SysV order: themov r10, rcxonly feeds the kernel. Numbers that are not on the list keep today's behaviour: refuse by default,UD2with the flag. The list starts with the numbers that converted titles actually contain, one entry per verified syscall, each with a test. Pathconf (191) would be the first.A second way would leave the relinker alone. A trapped stub still runs
mov rax, Nbefore itsUD2, and the caller's return address is on top of the stack. A runtime illegal-instruction handler could check for the exact trapped stub bytes, look up N, and setripto the libkernel export. That is a tail call that returns straight to the caller, with the arguments untouched. Windows already has a precedent inHandleSse4ainCrashReport.cpp. Linux and macOS have no SIGILL handler, though, and a guest can install its own, so this way needs more design than the relinker one.Open questions for maintainers
rax, while the libkernel export returns -1 and setserrno. The Apotris caller tests for -1. Should the redirect keep libkernel's convention, or should it go through a thunk that reproduces the raw one?AI-assisted: yes. The disassembly and the list of titles above were gathered with an AI assistant; only Apotris was disassembled.