fix(relinker): skip prefixed decodings inside an earlier instruction in the macOS TLS scan #6410
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6410"
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 DavidSamir on 2026-10-15T14:15:15Z.
What
27 catalog titles cannot be converted for macOS on
main, among them SuperTuxKart (PPSA69421), PSXS5 (PPSA97510), SwanStationPS5 (PPSA98510), ProsperoStore (PPSA99000), ProsperoRadio (PPSA99001), ProsperoTV (PPSA99003), SymphonyStation5 (PPSA17641) and OpenNOW (PPSA99082). Each fails on the same two bytes:They are not code. The titles link OpenSSL, whose assembly keeps
CRYPTOGAMS by <[email protected]>in the code segment; at PSXS5's offset 0xbabf4d the bytes are theenofopenssl(... 6f 70 | 65 6e 73 73 6c ...). A function range that begins inside an instruction makes the code analysis collect a second decoding from the middle of it, and here that decoding starts with a GS prefix. The Windows TLS rewriter skips a non-FS segment-prefixed decoding inside an earlier collected instruction (90dcd6256, "tolerate unwind ranges that split an instruction"), so the same titles convert for Windows. The macOS scan inMacOsImage.cpphas no such check and refuses the module.The macOS scan now tracks the end of the decodings it has seen, as the Windows rewriter does, and skips a segment-prefixed decoding that starts inside an earlier one unless the prefix is FS. A GS access at an instruction start is still refused.
With this PR 25 of the 27 convert. The other two get past this refusal and stop on unrelated ones, each with its own PR: Mortalfin (PPSA99141) on
Guest TLS access without a non-empty PT_TLS(#6448) and PS5MC (PPSA99420) on the stack-protector checksub %fs:0x28,%rax(#6419).Three commits:
fix(relinker): skip prefixed decodings inside an earlier instruction in the macOS TLS scan.test(relinker): convert a function that begins inside an instruction for macOS: a newmacos_tls_overlaptest converts the Windows coverage group'sfunction-begins-inside-instructionfixture with--macos. A symbol starts inside amovabswhose immediate holds a GS-prefixed decoding (65 2e 62 69 6e). It converts, and themovabsis unchanged in the output.test(relinker): keep refusing a GS access at an instruction start for macOS.There is no fourth step to split out.
Tested
Windows host (
be5dfd6237onmain0afa6a607e, Windows 11 10.0.26300, WinLibs GCC 15.2.0 r7, Release). The relinker writes macOS output on any host:tools/check_conventions.py --base origin/main: passed.tools/pr_overlap.py: no overlap with open pull requests.Each of the three commits builds, and the relinker tests pass at each (
macos|tls_function_coverage|tls_diagnostics|guest_tls|empty_tls, 35/36/36 tests; run onmaind92a8dad39before rebasing onto0afa6a607e, which changes nothing undercore/relinker).macos_tls_overlapfails without the fix: withMacOsImage.cppas onmain,function-begins-inside-instructionstops withUnsupported macOS guest TLS instruction (bytes: 65 2e 62 69 6e c3 c3 c3).Full build and full
ctest: 1250/1258 passed. Seven of the eight failures were timeouts or crashes under load early in the run (guest_needed_modules,windows_diagnostic_fixture_isolation,guest_gnu_hash,guest_video_out_resolution_status,agc_shader_mode_register,guest_none_relocations,guest_avplayer); all seven pass when rerun alone. The eighth,check_main_sync, fails the same way onmainon this host: its Unicode file name test reads git's UTF-8 output as cp1252 (sp ace é.txt).Linux (WSL2 Ubuntu 24.04, GCC 13.3.0): the relinker builds and the
macos|tlstests pass (38/39;guest_force_tls_destructoris not run because only the relinker target was built).macOS conversion of every catalog title (79) with
main's relinker and with this branch's, same arguments:mainwith(bytes: 65 6e), converted with this PRmainwith(bytes: 65 6e), now stopping on a later, unrelated refusalThe bytes the refusal named stay in place. In 23 of the converted titles,
CRYPTOGAMS by <[email protected]>occurs as often in the macOS output as in the input (20 times each); in the 24th, PPSA99039, the string is present in both input and output.macOS 26.7.1, Apple M2, MoltenVK 1.4.2, x86-64 under Rosetta, added 2026-10-16: head
be5dfd623, converted with--macos --to-rosettaand run 20 s each against the runtime of a local tree ofmainwith the macOS port work merged. 20 of the 25 titles were run, and each loads and runs its own code. Three keep running: PSXS5 (PPSA97510) draws its interface at about 11 ms a frame, SwanStationPS5 (PPSA98510) runs with only its network downloads failing (curl 77), and Nuvio PS5 (PPSA99997) is still running at 20 s. The other 17 run until the AGC driver stops on a GPU feature MoltenVK lacks:viewport depth outside [0, 1](#4650): PPSA17641, PPSA99001, PPSA99002, PPSA99003, PPSA99009, PPSA99773, PPSA99930;Barycentric geometry SPIR-V: geometry shaders are unavailable(#6222): PPSA74126, PPSA98427, PPSA99039, PPSA99082, PPSA99177, PPSA99474, PPSA99505, PPSA99515;last provoking vertex requires VK_EXT_provoking_vertex(#6741): PPSA99600.Not run there: SuperTuxKart (PPSA69421, 712 MB). PPSA99004, PPSA99008, PPSA99288 and PPSA99360 stopped on
Forbidden syscall instruction, since these runs didn't pass--skip-syscall-check.Limits of this Mac's GPU.
vulkaninfoon Apple M2 with MoltenVK 1.4.2 reports no geometry shaders, noshaderFloat64, noVK_EXT_depth_range_unrestrictedand noVK_EXT_provoking_vertex. AnyPS5 turns MoltenVK'sVK_KHR_fragment_shader_barycentricoff (5333a2053), so barycentric pixel shaders need the geometry-shader fallback. These are limits of the device, so this PR can't remove them. A title named here as stopping on one of them is not tested past that stop:Barycentric geometry SPIR-V: geometry shaders are unavailable: no geometry shaders; #6222 has a route around it.viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted: #4650 works around it.last provoking vertex requires VK_EXT_provoking_vertex: #6741 removes it only for draws whose pixel shader can't observe the provoking vertex.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T14:33:57Z.
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.
core/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/elfpatcher/src/macos/MacOsImage.cppcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-16T04:25:37Z.
Hardware run on Apple silicon, as asked in the handoff.
macOS 26.7.1, Apple M2 (8 GB), Rosetta 2, AppleClang 21.0.0. Relinkers built (
-DANYPS5_RELINKER_ONLY=ON, Release) frommain5d9dcc42dalone and with this branch merged; catalog releases, sha256 checked, eboot and modules unwrapped withtools/unwrap_self.py, converted with--macos --to-rosetta. For the runs, libraries from a local tree ofmaince991f1ecwith #4627, #4630, #6124, #6028, #6135 and mugurc's macOS branches merged, so they build on macOS; MoltenVK from the LunarG SDK 1.4.363.main's relinker fails withUnsupported macOS guest TLS instruction (bytes: 65 6e) (offset 0xbabf4d); with this branch alone it converts. The converted title runs on the M2 for the full 60 s, drawing its UI (ui: draw 4.1 ms, present 12.6 ms per frame) through MoltenVK.65 6efor PSXS5, so this is the change that moves it.AI-assisted: yes