Skip to content

fix(libkernel): export _readv, _writev, _fcntl, _fstat, __sys_socketex - #5992

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Get-fix:ps4/libkernel-underscore-io
Oct 18, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Get-fix:ps4/libkernel-underscore-io

Conversation

@Get-fix

@Get-fix Get-fix commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What

PS4 programs and modules built with the OpenOrbis toolchain import these libkernel names, and the samples stop at start-up without them: FAIL: unresolved ELF import YSHRBRLn2pI (_writev, all nine samples that otherwise start), +WRlkKjZvag (_readv), t0fXUzq61Z4 (_fcntl) and A0O5kF5x4LQ (_fstat, in the library sample's libExample.prx). __sys_socketex is imported by the networking sample.

  • _readv, _writev, _fcntl and _fstat forward to readv, writev, fcntl and fstat, as _ioctl already does. _fcntl passes its argument on as a full 64-bit value, so the record lock commands keep their whole pointer.
  • __sys_socketex creates a socket like socket(); its name argument is ignored, as sceNetSocket does.

Part of the PS4 homebrew work tracked in #3093.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, full build with BUILD_TESTING=ON, on main e442f4c2e:

  • guest_kernel_fcntl, guest_file_vector and guest_file_timestamps pass, as do guest_udp, guest_sendfile and guest_sce_net (6/6). They call each name and check what it did: _readv reads from an offset, _writev writes swapped segments, _fstat returns the same times as fstat, _fcntl sets descriptor flags and reads a record lock into a static flock (in the image, above 4 GiB), and __sys_socketex makes a TCP socket.
  • Each of these makes a test fail: _fcntl narrowing its argument to int, or dropping it; __sys_socketex swapping family and type; _readv reading nothing; _writev claiming success without writing; _fstat filling nothing.
  • OpenOrbis samples with the other changes listed in Relinker rejects PS4 executables: SCE dynamic tables and data in the code segment (two ready branches) + remaining PS4 work #3093 (left out one at a time on main 84b01f9cd, all together on e442f4c2e): with this change the nine samples start; the networking sample, a TCP server, was not run for this PR.
  • tools/check_conventions.py --base origin/main passes.

Not tested on Linux.

Checklist

🤖 Generated with Claude Code

OpenOrbis programs and modules import these PS4 libkernel names (the
graphics, library and networking samples). The underscore names
forward to readv, writev, fcntl and fstat, as _ioctl already does;
_fcntl passes its argument on as a full 64-bit value, so the record
lock commands keep their whole pointer. __sys_socketex creates a
socket like socket(); its name argument is ignored, as sceNetSocket
does.
@github-actions

Copy link
Copy Markdown

Progress report (73efd94 → f12d2de)

📈 System libraries: 88.87% (+0.01%, +5 implemented functions)

✅ 5 implemented
Library Name
libkernel __sys_socketex_nid_postfix
libkernel _fcntl_nid_postfix
libkernel _fstat_nid_postfix
libkernel _readv_nid_postfix
libkernel _writev_nid_postfix

This was referenced Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 6044 core/libs/tests/GuestFileTimestamps.cpp
core/libs/tests/GuestFileVector.cpp
core/libs/tests/GuestKernelFcntl.cpp
PR 6222 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 6879 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7201 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7299 core/libs/prx/libkernel/File/src/Stdio.cpp

@Get-fix

Get-fix commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

I checked the overlap the bot lists. I fetched each listed pull request and, for every file it shares with this one, merged its change with git merge-file into current main (a5e2a80c6) and into main with this pull request merged. A conflict that appears only in the second case is one this pull request adds.

The bot lists 21 pull requests, with 41 shared files between them (File/src/Stdio.cpp and Socket/src/Udp.cpp). This pull request adds no conflict to any of them. Its additions are new functions placed after the ones they forward to.

AI-assisted: yes (Claude Code). I ran these checks myself on Windows 11.

🤖 Generated with Claude Code

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the five forwarders against readv/writev/fcntl/fstat/socket, the 64-bit _fcntl argument, and the new assertions in guest_file_vector, guest_file_timestamps and guest_kernel_fcntl (all pass; the tests don't link without the change). Merging once the full Build is green.

@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked against current main (4272979): merges cleanly, the five forwarders and the new assertions in guest_file_vector, guest_file_timestamps and guest_kernel_fcntl pass. Merging once the full Build is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants