Relinker: seven catalog homebrew titles stop on raw FreeBSD syscall stubs from the ps5-payload-dev SDK libc #2136

Closed
opened 2026-10-09 09:50:55 +00:00 by overlordxrz-source · 3 comments
overlordxrz-source commented 2026-10-09 09:50:55 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-09T09:50:55Z.


Title: Relinker: seven catalog homebrew titles stop on raw FreeBSD syscall stubs from the ps5-payload-dev SDK libc

What

On main 6cc0503da, seven titles from ps5-homebrew-catalog (https://github.com/blackbearreloaded/ps5-homebrew-catalog) fail to relink with "FAIL: Forbidden syscall instruction at code offset 0x…":

  • PPSA01153, OliSe Player 02.000.001, 0xb03d47
  • PPSA99004, ProsperoAI 01.000.000, 0xad3597
  • PPSA99008, ProsperoEden 1.000.090, 0x212f07a
  • PPSA99011, PS5 FSR4 Showcase 01.000.010, 0x511d17
  • PPSA99203, PS5SX2 vk-285-139, 0x1083ec7
  • PPSA99204, PS5NES 1.0.0.8, 0xc43f97
  • PPSA99206, PS5N64 releasev7, 0xcb9da7

These failures are genuine. Each stop is a real syscall instruction from libc/syscalls.c in the ps5-payload-dev SDK (https://github.com/ps5-payload-dev/sdk/blob/master/libc/syscalls.c):

  • 6 titles stop on the generic syscall() wrapper (mov rax,rdi … mov r9,[rsp+8]; syscall; ret).
  • PPSA99008 stops on the link() stub (mov rax,9; mov r10,rcx; syscall; ret).

The relinker's own decoder finds 233 such sites per title, which is every function in that file. They sit in one contiguous block, and there are no other hits. The 39 other catalog titles have none. Scanner sync looks correct.

Most stubs are dead code. The direct callers I found:

  • link/symlink/readlink/pathconf/fchmodat/openat/unlinkat/utimensat. These are probably libc++ std::filesystem, but that is inferred from strings because there are no symbols.
  • fork, dup, fstatat, ppoll, clock_nanosleep.
  • syscall(SYS_socket) from the SDK's if_nametoindex.
  • __syscall(SYS_recvmsg/SYS_sendmsg) from its recvmmsg/sendmmsg.

Because guest code runs natively, --skip-syscall-check would run Linux syscalls with the same numbers. For example, FreeBSD link (9) would run mmap, and symlink (57) would run fork. That flag is not a workaround here.

Question

Which direction would you accept?

  1. Relinker stub redirection. Recognise the SDK's fixed stub signatures (48 C7 C0 imm32 49 89 CA 0F 05 C3 and the 23-byte generic body), and patch each stub entry to jump to host implementations that follow the FreeBSD error ABI (CF plus errno in rax). The generic syscall()/__syscall() would go through a dispatcher keyed on rax.
  2. Deferred failure. Keep relinking, replace each syscall with a trap (for example UD2), and fail at runtime with the syscall number and address only if one is actually reached.
  3. Keep the hard failure. Point such titles upstream so the SDK routes these calls through libkernel exports.

This does not overlap #1935, which rejects prefixed syscall instructions. None of these hits are prefixed, and no catalog title has a prefixed one.

Tested

  • Relinker on main 6cc0503da, built natively (aarch64 Linux, zig c++ 0.17 with the CMake target's sources).
  • All 46 catalog titles downloaded, except PPSA76677 and PPSA77711, sha256-checked against the catalog, and unwrapped from fSELF.
  • 39 titles relink. 7 stop as above.
  • With --skip-syscall-check the 7 relink. No title was run.

AI use: an AI assistant helped with the scanning tools, the disassembly and this write-up. I reviewed the results.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5776187968 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2136). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-09T09:50:55Z. --- Title: Relinker: seven catalog homebrew titles stop on raw FreeBSD syscall stubs from the ps5-payload-dev SDK libc ### What On main 6cc0503da, seven titles from ps5-homebrew-catalog (https://github.com/blackbearreloaded/ps5-homebrew-catalog) fail to relink with "FAIL: Forbidden syscall instruction at code offset 0x…": - PPSA01153, OliSe Player 02.000.001, 0xb03d47 - PPSA99004, ProsperoAI 01.000.000, 0xad3597 - PPSA99008, ProsperoEden 1.000.090, 0x212f07a - PPSA99011, PS5 FSR4 Showcase 01.000.010, 0x511d17 - PPSA99203, PS5SX2 vk-285-139, 0x1083ec7 - PPSA99204, PS5NES 1.0.0.8, 0xc43f97 - PPSA99206, PS5N64 releasev7, 0xcb9da7 These failures are genuine. Each stop is a real syscall instruction from libc/syscalls.c in the ps5-payload-dev SDK (https://github.com/ps5-payload-dev/sdk/blob/master/libc/syscalls.c): - 6 titles stop on the generic syscall() wrapper (mov rax,rdi … mov r9,[rsp+8]; syscall; ret). - PPSA99008 stops on the link() stub (mov rax,9; mov r10,rcx; syscall; ret). The relinker's own decoder finds 233 such sites per title, which is every function in that file. They sit in one contiguous block, and there are no other hits. The 39 other catalog titles have none. Scanner sync looks correct. Most stubs are dead code. The direct callers I found: - link/symlink/readlink/pathconf/fchmodat/openat/unlinkat/utimensat. These are probably libc++ std::filesystem, but that is inferred from strings because there are no symbols. - fork, dup, fstatat, ppoll, clock_nanosleep. - syscall(SYS_socket) from the SDK's if_nametoindex. - __syscall(SYS_recvmsg/SYS_sendmsg) from its recvmmsg/sendmmsg. Because guest code runs natively, --skip-syscall-check would run Linux syscalls with the same numbers. For example, FreeBSD link (9) would run mmap, and symlink (57) would run fork. That flag is not a workaround here. ### Question Which direction would you accept? 1. Relinker stub redirection. Recognise the SDK's fixed stub signatures (48 C7 C0 imm32 49 89 CA 0F 05 C3 and the 23-byte generic body), and patch each stub entry to jump to host implementations that follow the FreeBSD error ABI (CF plus errno in rax). The generic syscall()/__syscall() would go through a dispatcher keyed on rax. 2. Deferred failure. Keep relinking, replace each syscall with a trap (for example UD2), and fail at runtime with the syscall number and address only if one is actually reached. 3. Keep the hard failure. Point such titles upstream so the SDK routes these calls through libkernel exports. This does not overlap #1935, which rejects prefixed syscall instructions. None of these hits are prefixed, and no catalog title has a prefixed one. ### Tested - Relinker on main 6cc0503da, built natively (aarch64 Linux, zig c++ 0.17 with the CMake target's sources). - All 46 catalog titles downloaded, except PPSA76677 and PPSA77711, sha256-checked against the catalog, and unwrapped from fSELF. - 39 titles relink. 7 stop as above. - With --skip-syscall-check the 7 relink. No title was run. AI use: an AI assistant helped with the scanning tools, the disassembly and this write-up. I reviewed the results.
overlordxrz-source commented 2026-10-11 03:18:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-11T03:18:18Z.


Rig data for this wall on current main (6c9cb3a5, Linux x86_64, 60 s per title). Nine catalog titles stop here:

Title Offset Site at offset SDK stubs in eboot With --trap-sdk-syscall-stubs
OliSe Player PPSA01153 0xb04df7 SDK generic syscall() 231 numbered + 2 generic relinks, next stop 04AjkP0jO9U
ProsperoAI PPSA99004 0x1108bf7 SDK generic 231 + 2 relinks, next stop 5G2ONUzRgjY
ProsperoEden PPSA99008 0x214dcda SDK numbered stub, #9 (link) 3 numbered (9/57/58) relinks, next stop 5G2ONUzRgjY
PS5 FSR4 Showcase PPSA99011 0x511d17 SDK generic 231 + 2 relinks, next stop r28hEh6cNH0
PS5SX2 PPSA99203 0x10a2d37 SDK generic 231 + 2 relinks, next stop aML18Z0J0t0
PS5NES PPSA99204 0xc43f97 SDK generic 231 + 2 relinks, next stop VUzjXknPPBs
PS5N64 PPSA99206 0xcb9da7 SDK generic 231 + 2 relinks, next stop oxMp8uPqa+U
Nuvio Max'd PPSA99288 0x21a6cda not an SDK stub (its stub block starts at 0x21a75a7) 231 + 2 still fails at 0x21a6cda
PS5CEMU-HAR PPSA99360 0x1699f07 SDK generic 5 numbered (9/41/57/58/191) + 1 generic relinks, next stop 04AjkP0jO9U

So 8 of 9 hit only the ps5-payload-dev libc/syscalls.c stubs, and with them trapped (ud2) they relink and move on to ordinary import stops. None of the 8 reached a trapped stub at runtime (no SIGILL in any run). Nuvio Max'd has one raw syscall outside the SDK block, and the flag correctly still rejects it.

The branch keeps this opt-in so the default and #2206's test don't change. Every non-SDK syscall still fails the relink, and the tests cover Linux/Windows output, guest modules, and nine shapes that must still be rejected. Would you take it as an opt-in flag, or do you prefer the trap by default, or routing the stubs to host implementations?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104954017 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2136#issuecomment-6104954017). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-11T03:18:18Z. --- Rig data for this wall on current main (6c9cb3a5, Linux x86_64, 60 s per title). Nine catalog titles stop here: | Title | Offset | Site at offset | SDK stubs in eboot | With `--trap-sdk-syscall-stubs` | |---|---|---|---|---| | OliSe Player PPSA01153 | 0xb04df7 | SDK generic `syscall()` | 231 numbered + 2 generic | relinks, next stop `04AjkP0jO9U` | | ProsperoAI PPSA99004 | 0x1108bf7 | SDK generic | 231 + 2 | relinks, next stop `5G2ONUzRgjY` | | ProsperoEden PPSA99008 | 0x214dcda | SDK numbered stub, #9 (`link`) | 3 numbered (9/57/58) | relinks, next stop `5G2ONUzRgjY` | | PS5 FSR4 Showcase PPSA99011 | 0x511d17 | SDK generic | 231 + 2 | relinks, next stop `r28hEh6cNH0` | | PS5SX2 PPSA99203 | 0x10a2d37 | SDK generic | 231 + 2 | relinks, next stop `aML18Z0J0t0` | | PS5NES PPSA99204 | 0xc43f97 | SDK generic | 231 + 2 | relinks, next stop `VUzjXknPPBs` | | PS5N64 PPSA99206 | 0xcb9da7 | SDK generic | 231 + 2 | relinks, next stop `oxMp8uPqa+U` | | Nuvio Max'd PPSA99288 | 0x21a6cda | not an SDK stub (its stub block starts at 0x21a75a7) | 231 + 2 | still fails at 0x21a6cda | | PS5CEMU-HAR PPSA99360 | 0x1699f07 | SDK generic | 5 numbered (9/41/57/58/191) + 1 generic | relinks, next stop `04AjkP0jO9U` | So 8 of 9 hit only the ps5-payload-dev `libc/syscalls.c` stubs, and with them trapped (`ud2`) they relink and move on to ordinary import stops. None of the 8 reached a trapped stub at runtime (no SIGILL in any run). Nuvio Max'd has one raw syscall outside the SDK block, and the flag correctly still rejects it. The branch keeps this opt-in so the default and #2206's test don't change. Every non-SDK syscall still fails the relink, and the tests cover Linux/Windows output, guest modules, and nine shapes that must still be rejected. Would you take it as an opt-in flag, or do you prefer the trap by default, or routing the stubs to host implementations?
MarcZX10 commented 2026-10-11 16:55:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T16:55:29Z.


I opened PR #3804 with an opt-in implementation of the deferred-failure direction.

--trap-sdk-syscall-stubs recognizes only the exact numbered and generic SDK wrapper byte patterns described here, then replaces the syscall instruction with UD2 in the main executable and bundled guest modules. Unrecognized syscall instructions still stop relinking, and default behavior is unchanged. If one of the trapped wrappers runs, it raises an illegal-instruction exception; the flag does not emulate FreeBSD syscalls.

The Linux x86_64 relinker-only Release build passed, along with all 115 relinker-only CTest tests. This validates the generated patches with fixtures; I did not run the catalog titles. The PR has the AI-assisted disclosure.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111405990 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2136#issuecomment-6111405990). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T16:55:29Z. --- I opened [PR #3804](https://github.com/boykopovar/AnyPS5/pull/3804) with an opt-in implementation of the deferred-failure direction. `--trap-sdk-syscall-stubs` recognizes only the exact numbered and generic SDK wrapper byte patterns described here, then replaces the `syscall` instruction with `UD2` in the main executable and bundled guest modules. Unrecognized syscall instructions still stop relinking, and default behavior is unchanged. If one of the trapped wrappers runs, it raises an illegal-instruction exception; the flag does not emulate FreeBSD syscalls. The Linux x86_64 relinker-only Release build passed, along with all 115 relinker-only CTest tests. This validates the generated patches with fixtures; I did not run the catalog titles. The PR has the AI-assisted disclosure.
hansjm10 commented 2026-10-11 18:29:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by hansjm10 on 2026-10-11T18:29:23Z.


What PS5 FSR4 Showcase (PPSA99011, 01.000.010, the catalog's zip, sha256 matching) hits after the SDK stubs, with #3804 (0a6247532) on main a11c8f7f7, Linux, RADV:

  1. --trap-sdk-syscall-stubs traps 233 sites (231 numbered, 2 generic) and the title relinks. tools/import_audit.py: 213 of 215 imports implemented, one stub (sceSystemServiceLoadExec), one absent, which is where the loader stops:
    ./app.elf: symbol lookup error: ./app.elf: undefined symbol: r28hEh6cNH0
    
    r28hEh6cNH0 is sceAgcDriverGetHsOffchipParam. Its only callers in ps5-vulkan, the Vulkan layer the showcase pins at 4bb0c8b, are on tessellation paths (graphics_queue_ps5.c L2241). With a throwing export, the run below never reaches it.
  2. Next, ps5-vulkan's platform_ps5.c L99 loads internal module 0x80000094, which ModuleTable.hpp lacks:
    [debug:0] FSR4_SHOWCASE_BEGIN heap=0
    terminate called after throwing an instance of 'std::runtime_error'
      what():  sceSysmoduleLoadModuleInternal: unknown id 2147483796
    
    libNidResolver sysmodules.c L245 names it libSceAgc, the table #2541 used for 0x110.
  3. With it registered, the next stop is sceAgcInit: unsupported register defaults version. ps5-vulkan calls sceAgcInit(&state, sizeof(state)) (L106), while its own probe build calls the export with a scalar version, __real_sceAgcInit(11) (graphics_main.c L68). AnyPS5 takes a version below 14. What the console does when a stack address lands in that argument is unknown, so I'm not taking this one.

No trapped stub was reached (no SIGILL). I'm taking 1 and 2 as two PRs, each Depends on: #3804.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6112264295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2136#issuecomment-6112264295). Originally posted by [hansjm10](https://github.com/hansjm10) on 2026-10-11T18:29:23Z. --- What PS5 FSR4 Showcase (PPSA99011, 01.000.010, the catalog's zip, sha256 matching) hits after the SDK stubs, with #3804 (`0a6247532`) on `main` a11c8f7f7, Linux, RADV: 1. `--trap-sdk-syscall-stubs` traps 233 sites (231 numbered, 2 generic) and the title relinks. `tools/import_audit.py`: 213 of 215 imports implemented, one stub (`sceSystemServiceLoadExec`), one absent, which is where the loader stops: ``` ./app.elf: symbol lookup error: ./app.elf: undefined symbol: r28hEh6cNH0 ``` `r28hEh6cNH0` is `sceAgcDriverGetHsOffchipParam`. Its only callers in ps5-vulkan, the Vulkan layer the showcase pins at [`4bb0c8b`](https://github.com/blackbearreloaded/ps5-vulkan/tree/4bb0c8b1423698a7369efc22b829bf16a99e7128), are on tessellation paths ([`graphics_queue_ps5.c` L2241](https://github.com/blackbearreloaded/ps5-vulkan/blob/4bb0c8b1423698a7369efc22b829bf16a99e7128/native/graphics_queue_ps5.c#L2241)). With a throwing export, the run below never reaches it. 2. Next, ps5-vulkan's [`platform_ps5.c` L99](https://github.com/blackbearreloaded/ps5-vulkan/blob/4bb0c8b1423698a7369efc22b829bf16a99e7128/native/platform_ps5.c#L99) loads internal module `0x80000094`, which `ModuleTable.hpp` lacks: ``` [debug:0] FSR4_SHOWCASE_BEGIN heap=0 terminate called after throwing an instance of 'std::runtime_error' what(): sceSysmoduleLoadModuleInternal: unknown id 2147483796 ``` [`libNidResolver` `sysmodules.c` L245](https://github.com/astrelsky/libNidResolver/blob/3f7ce7086c38ef35eb7869aafb247ed544ae3ee1/source/sysmodules.c#L245) names it `libSceAgc`, the table #2541 used for `0x110`. 3. With it registered, the next stop is `sceAgcInit: unsupported register defaults version`. ps5-vulkan calls `sceAgcInit(&state, sizeof(state))` ([L106](https://github.com/blackbearreloaded/ps5-vulkan/blob/4bb0c8b1423698a7369efc22b829bf16a99e7128/native/platform_ps5.c#L106)), while its own probe build calls the export with a scalar version, `__real_sceAgcInit(11)` ([`graphics_main.c` L68](https://github.com/blackbearreloaded/ps5-vulkan/blob/4bb0c8b1423698a7369efc22b829bf16a99e7128/native/graphics_main.c#L68)). AnyPS5 takes a version below 14. What the console does when a stack address lands in that argument is unknown, so I'm not taking this one. No trapped stub was reached (no SIGILL). I'm taking 1 and 2 as two PRs, each `Depends on: #3804`. AI-assisted: yes (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#2136
No description provided.