fix(relinker): keep FS and GS accesses in place when lowering for macOS #25971
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25971"
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 Gonic0 on 2026-11-23T02:16:58Z.
What
relinker --macos --to-rosettastopped GTA V (PPSA04264) with "AMD-only instruction is also a guest TLS access". At0xafd542a 4-bytevmovups %ymm0,(%rbx)is split by the Rosetta lowering and needs a 5-byte jump, so the converter moves a neighbour into its stub. The instruction before it is another 256-bit store with its own stub, so after #7309's preferred non-segment pass the converter falls back to the followingmovq %fs:0x0,%rax. The macOS image writer rewrites every guest FS access into a TLS stub and every GS access into a trap, so a moved segment access can never be written there, and the writer refuses the image.The converter now takes
keepSegmentAccesses, which only the macOS output sets (the executable inConversion.cppand the guest modules inGuestModuleBuilder.cpp). With it, an instruction with an FS or GS prefix is never moved: the window search skips the segment fallback and goes on to an island, islands do not take a segment access into their window, and a short AMD-only instruction whose jump would cover one is refused (or kept when its lowering is optional) instead of failing later in the writer. Linux and Windows output, and the default ofMakeAmd64OnlyConverter, are unchanged, so #7309's fallback still applies there.Tested
Apple M5 Pro, macOS 27.3, x86_64 Release under Rosetta 2, on
main441fa65119.eboot.elf, unwrapped withtools/unwrap_self.py:relinker --macos --registry --to-rosettaonmainfails with "AMD-only instruction is also a guest TLS access" at RVA0xb0d542; with this pull request it completes (147,551 stubs, 2 optionalVRCPPSkept for lack of room between branches) and converts the 3sce_modulemodules.tools/import_audit.pyon the four registries exits 0. The title then starts under AnyPS5 and reaches its DLC scan before a separate memory-mapping stop that this change does not touch.amd64_only_converter: newconverterWideStoreKeepsSegmentAccessescovers FS and GS neighbours: with the option a 256-bit store before one is lowered through an island that leaves the access in place, and a store whose only room is such an access is refused; without the option the store still falls back to the access.core/relinkerCMake files pass.tools/check_conventions.py --base upstream/mainpasses.Not tested on Linux or Windows output beyond the converter tests, where the default is unchanged.
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 PrivacyOnion on 2026-11-23T02:21:49Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
db7ae63096:tools/check_conventions.pypassed.amd64_only_converter_testsbuilt cleanly.amd64_only_converter):core/relinker/codegen/include/codegen/IAmd64OnlyConverter.hpp,core/relinker/codegen/src/Amd64OnlyConverter.cpp,core/relinker/relinker/src/guest/GuestModuleBuilder.cpp,core/relinker/relinker/src/pipeline/Conversion.cppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:26:39Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the exact-head review found no verified defects, and the inspected code supports merging.
What I ran
Reviewed head
db7ae630964e46ed25e01a7a161fd3694bb324b3. No commands or tests were run in this review; the test results below are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The reported macOS conversion, relinker tests, conventions check, and Linux or Windows behavior were not independently confirmed. No files were excluded: all five files in the manifest were included and read.
To get this to a good state
Nothing is required.