feat(libc): implement _Vacopy #8593
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8593"
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 priyanshrv-netizen on 2026-10-20T17:43:25Z.
What
Implements
_Vacopy(NIDxRycekLYXdc), the Dinkumware helper behindva_copy, which the systemlibc.prx(buildJ03093718) exports and no source incore/libs/prxor open pull request defines yet.core/libs/prx/libc/src/RuntimeSupport.cppfollows that module's disassembly (0x3950), which copies the 24-byte System Vva_listin two steps and in this order:The order matters when the two lists overlap: the console writes the last 8 bytes first, then the first 16. The implementation copies in the same order, so an overlapping copy gives the same result, and returns the same value in
raxas the console's_Vacopy, which the Dinkumware header ignores.CheckVacopyincore/libs/tests/GuestStdioVariadic.cppcopies a 9-argument list, reads every argument through the copy, checks that the source is untouched and still readable afterwards, and checks the byte order of an overlapping copy.Tested
Windows 10, MSYS2 MinGW-w64 GCC 15.2.0 (
mingw64, not the WinLibs UCRT toolchain from BUILD.md). I did not configure the full CMake build.RuntimeSupport.cppbuilds with-Wall -Wextra -Werror -fno-asynchronous-unwind-tables.CheckVacopy(copied unchanged fromGuestStdioVariadic.cpp, with stubs for the two unrelated helpers that file's object needs) passes; againstmain'sRuntimeSupport.cppit fails to link on_Vacopy_nid_postfix. The first commit definedCheckVacopybut never called it frommain, so in the Release build the checks were dropped andguest_stdio_variadicpassed without them (found in review);mainnow calls it. Built with the CI flags (-O3 -DNDEBUG -Wall), the test object now references_Vacopy_nid_postfixand has no unused-function warning, and an implementation that copies bytes 0-15 before bytes 16-23 makesCheckVacopyabort.Against the console code itself: I mapped that
libc.prx's segments into memory, applied its relocations and called its_Vacopythrough a System V function pointer beside this one. For 200,000 random 24-byte lists, half at a random alignment, with the destination 8 bytes above the source, 8 bytes below it, or clear of it, the destination and the surrounding bytes were identical in every case.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch feat/libc-vacopyreports no overlap. It could not compare #5021, #7201 and #7648 (each conflicts withmain); I checked them by hand: all three changeRuntimeSupport.cppat line 112 or later, where this inserts at line 94, and none adds this export. Not tested on Linux; no title was run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T17:44:15Z.
Progress report (
2abfb1b→3b426ed)📈 System libraries: 49.67% (+0.01%, +1 implemented functions)
✅ 1 implemented
_Vacopy_nid_postfixImported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T19:04:29Z.
CheckVacopy()is defined at core/libs/tests/GuestStdioVariadic.cpp#L90, butmain()never calls it, so none of the three_Vacopychecks run.guest_stdio_variadicpasses whether_Vacopy_nid_postfixis right or wrong. For example, an implementation that copies bytes 0-15 before bytes 16-23 would still pass.CI builds in the Release configuration (build.yml#L40). There, GCC drops the unused static functions, so the test binary doesn't reference
_Vacopy_nid_postfixat all and would link and pass even without it. With g++ 15.2 (MinGW-w64) at-O3 -DNDEBUG -WallI getwarning: 'void CheckVacopy()' defined but not used [-Wunused-function], andnmon the object lists no_Vacopy_nid_postfix,CheckVacopyorSumThroughCopy.Calling it before
return 0;at L144 fixes this:The checks themselves look right. I built a small harness that only calls
CheckVacopy(). Your implementation passes. With the two copies swapped, it aborts withfailed: _Vacopy copies the overflow area before the offsets.Imported from boykopovar/AnyPS5. Originally posted by priyanshrv-netizen on 2026-10-21T10:20:09Z.
You're right, thanks. I wrote
CheckVacopy()but never added the call tomain(), and my local check ran it from a separate driver, so I missed that the test binary never used it. I reproduced what you saw: with-O3 -DNDEBUG -Wallthe object warns'void CheckVacopy()' defined but not usedand has no_Vacopy_nid_postfixreference.Fixed in
3b426ed:main()callsCheckVacopy()beforereturn 0;, as you suggested. With the same flags the warning is gone and the object references_Vacopy_nid_postfix. With the two copies swapped, it aborts withfailed: _Vacopy copies the overflow area before the offsets, and with this implementation it passes. I also corrected the Tested section of the description.