Repository navigation
feat(libc): implement overlap-safe bcopy - #6532
Conversation
|
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.
|
karimibrahim07
left a comment
There was a problem hiding this comment.
Windows check of head af691b717 (together with #6533, which merges cleanly with it), on main 5d9dcc42d. Windows 11 Pro (26300), WinLibs GCC 15.2.0 r7, Ninja Release.
guest_stringspasses, with the exhaustive source/destination/count overlap check.- Code:
memmovegivesbcopy(3)'s overlap-safe copy with the arguments swapped, and thecount != 0guard keepsbcopy(NULL, NULL, 0)well defined. That matches FreeBSD'sbcopy, which does nothing for a zero length. No issues.
Evidence: both descriptions use a purpose-built probe. In earlier rounds maintainers held back functions that no shipped title or released homebrew imports yet, so a real importer would help. I checked the two released websrv payloads built with the same ps5-payload-dev SDK. Neither Mari0 (Mari0.zip from websrv v0.34, SHA-256 e0331ed5…2ce3, the bundle in #6239) nor the Quake homebrew (#6698) imports bcopy or getopt_long_only, in love.elf/quake.elf or in their libOSMesa.so.8. If a released title or homebrew does, naming it would make the case.
Build note: with the same WinLibs GCC 15.2.0 r7, a full build of main 5d9dcc42d plus this PR (and #6532/#6533 together) completes here without the GpuIndirectArgumentsMisalignedWriterAhead.cpp:25 alignment error, so that error looks specific to your tree or setup.
AI-assisted: yes. I ran the build and tests above and read the import tables of the two bundles.
What
A PS5 ABI conformance homebrew importing bcopy stops at startup because its NID is absent. Implement source-first, overlap-safe copying and a zero-length no-op. The regression checks both overlap directions, identical pointers, separate buffers and copy boundaries.
Contract: FreeBSD bcopy(3). The signature/export is also present in the open PS5 payload SDK. This is general library behavior; no title-specific workaround.
Tested
Windows 11 Pro 10.0.26200 x64, Intel Core i7-10700K, supported WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, Python 3.13.7. The full suite's Vulkan tests select an NVIDIA GeForce RTX 4070 SUPER, Windows driver 32.0.16.1088. Baseline
b7cedd900d67a94453b8a45eec9b5623532a0441; branchfeat/guest-bcopy; tested headaf691b717ad068bb93ac50bfc428af63ab259613.Executed purpose-built PS5 ABI homebrew: identical ELF input is relinked and launched against baseline and rebuilt patched libraries. Baseline stops at the expected unresolved
bcopyimport (exit0xC0000139). Fixed reaches the ELF entry point, executes the behavioral checks and exits0. The input is compiled with clang 23 targetingx86_64-sie-ps5, with NID imports/SCE module metadata and a freestanding entry. Link-time stubs are not deployed; no trap or implementation substitution is used. This establishes module load, entry and conformance completion for this probe, not shipped-title, physical-console or gameplay compatibility.The full build was attempted on baseline and both fixes. All three hit the same unrelated upstream MinGW error in
GpuIndirectArgumentsMisalignedWriterAhead.cpp:25: requested alignment 65536 exceeds the object-file maximum 8192. Continuing Ninja with-k 0built the remaining available targets; the separatelibstarget and focused regression tests passed. The same new regression test cannot link on baseline specifically becausebcopy_nid_postfixis absent. Conventions andgit diff --checkpass. A clean full build is not claimed.Full CTest results (unrelated failures/skips are disclosed):
Failed on both:
windows_trace_imports. Baseline-only failures:agc_driver_store_over_untracked. Fixed-only failures: none. Skipped on this PR:agc_host_import_sparse,agc_driver_sparse_dma_buf_import,agc_driver_stencil_ref_export,guest_video_out_high_frame_rate,video_out_flip_labels,video_out_flip_labels_main,video_out_flip_lifetime,video_out_flip_reopen,video_out_flip_controls,video_out_flip_overlay,video_out_flip_unopened,video_out_flip_eop,video_out_flip_eop_main,video_out_flip_eop_aftergpu,guest_video_out_wqhd_detection_no_vulkan,long_paths. Native Linux/macOS were not tested locally. GitHub full builds require a collaborator-triggered run under current contribution rules.Unavailable on this PR:
agc_driver_gpu_indirect_arguments_misaligned_writer_ahead. The alignment build error above explains the unavailable AGC executable. Baselinewindows_trace_importsfails with WinError 225 because Defender blocks its separate generated fixture; no protection settings were changed. Neither unavailable nor skipped tests are execution evidence.Reproducer, input/build hashes and library artifacts
Save the C source below as
bcopy.cand the Python recipe asbuild_probe.py. SetLLVM_BINto thebindirectory of LLVM MinGW 20261006, then runpython build_probe.py bcopy bcopy puts. The generated input layout isprobes/bcopy/probe.elfwith an emptysce_module/; system-link stubs remain outside that module directory. The script preserves the input after construction.Build each checkout with:
Place the toolchain's
libgcc_s_seh-1.dll,libstdc++-6.dllandlibwinpthread-1.dllbeside the patched PRXs. Convert each variant with the baseline relinker:Startup diagnostics recorded the selected library paths.
--trace-importswas present but the optionalAPS5_TRACE_CALLSring was not enabled; no per-call trace capture is claimed. Execution is demonstrated by the probe's checks and successful return through the converted entry.Input ELF SHA256:
cde94935738d5ac7d35665cdf27509098d5c48f46bd665dfc6dd64ed3b3200d0. Relinker SHA256:a4babf4b9154c44b64676011724911b6fa38451b96923d7d596f48eaaf191f1a.59a0ec0a34c68c0c547d8a3e825abee36e0fe1165c6ed9a17a7620128c3daaa8f43a0d316fc29b762e025a396e86322212d8d26ef6d1f3a36a7e18f3bc6469a2d56fba282a0e9f2a85af9ee1db7037611b2dcc8f35e176aadd1696cd9c845b5bfa82ac6bb55c0ca1016b8e225fcc332cbd861242d8e64b5aafa52386d22c6afe9b799f8d27051476ebfdc91f92461374fd4526eac142168af3ff30023d34dad125a4c4f628de4f5e83c0c4dd4ac31dac5566fc411bd31e8463251d28f4c997f2Open-PR overlap check
Complete paginated inventory: 630 open PRs. Main checked:
44df21632125dbe3113a19173e7ebb879da53003. Exact changed-file lists and every shared-file implementation were inspected; Git tree-only previews normalize both sides to that main as the explicit merge base. 1 reliable clean shared-file comparisons; 19 inconclusive because those peers already conflict with main. No duplicate implementation or reliable pairwise conflict found. The two proposed topics also merge cleanly together; this does not claim combined runtime testing.The tested base is
b7cedd900d67a94453b8a45eec9b5623532a0441. Main advanced during validation; the newer main above was checked for integration conflicts, not claimed as the runtime-tested baseline.c33036b1629c16fcd304b12225cd37f6897688a901f2073d06385ca2adb537d4996ad61e8255bd2e2d6b8ef4341e21d78686bfba9da9a5c6bb14d6291263d7065489fd6b7a15ebbecb1fcf0ee72d21f907713af3078fcb4e24a15c96bf15c3df4e2b071abeb1ba79f2b3a2fc3882bf9d65553e4e754fc03de4b37aa2e22c15e0e07341a7d8c18100cbae55c28c49e6d6960021ef72e1382d78b9b83914cc7f3116b602cbfb29dcf3fc89b4ed67f228d65a27b20b66c8f11a47d64c2db6f514e409e94e91f5ac530992b12559c64489b556179b651ab4d966c29314ec67f9e72d1c663dbc8811cdb6c85753844be02381b339b4f6ca25b1b274555394e73a26f8c8d98347b447062d71dc1748d60edfdc0ec437aa597a5b7dbad53434ecca2bf92ee67c43952598c6a108941ef9b136024e27d1463a70edee4952553628e5f2895e296b79d94a6312c385890352d7f76e9a0d4380eb34b754de4b65b11c1f7d9beafe58a0d057c45da6cb0cb5f277da258a661bb11792e04941f4c79067f94df827623df9210738a5ba3275b9a59f1c8bChecklist
mainsnapshotb7cedd900d67a94453b8a45eec9b5623532a0441; refreshed current-main merge check above; no other open PR implements the same functions