fix(relinker): protect macOS TLS code entry roots #11488

Merged
roboterspinne merged 3 commits from upstream-pr/11488 into main 2026-11-02 12:27:47 +00:00
roboterspinne commented 2026-10-26 17:07:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-26T17:07:55Z.


What

The macOS TLS scan asked CodeInstructionCollector::Collect for no entry roots and replaced every supported fs:[disp32] access with jmp rel32 and NOPs, even when a collector root lay inside the instruction. On untouched 4017310678, an SCE fixture whose relocation pointer makes 64 48 8b 04 25 00 00 00 00 c3 at 0x240 code and whose function holds lea rax, [rip -> 0x244] (0x244 taken as data) fails for --windows with FAIL: TLS rewrite would overwrite an executable entry point (offset 0x244), but converts for --macos with exit 0 and Took 1 pointer target(s) outside the unwind functions as data, the first at 0x244, and the bytes the lea addresses are rewritten. The Windows TLS builder has refused this since #5890 and, for pointer targets taken as data, #8166.

  • Rule. ScanTls in MacOsImage.cpp now passes &entryRoots to Collect, as WindowsTlsBuilder::Build does, and before recording a supported access (load, store immediate, ALU read) throws TLS rewrite would overwrite an executable entry point at the root's file offset when a root lies strictly inside [instruction, instruction + length). The macOS rewrite span is the instruction length, never longer than the Windows span, and both targets use the same collector roots and access forms, so every input this refuses is already refused by --windows. Code roots inside an fs instruction already fail in the collector with overlapping instruction boundaries on both targets; the newly refused inputs are pointer targets taken as data in PS4 unwind-gap images. GS traps are unchanged; on main the Windows builder does not check them against entry roots either (#11090 adds that check for Windows). docs/dev/debt/relinker.md line 33 stays accurate and is not edited, so this PR does not conflict with #10479 or #10861 there.
  • Tests. test_sce_code_extent.py gets lea_into_tls_fixture() and the case sce-tls-rewrite-over-data-target-<target> in the Windows/macOS loop, expecting TLS rewrite would overwrite an executable entry point (offset 0x244) and no output on both targets. After #10861 (Felipebmaitan), which rewrites the same Collect call and changes sce-tls-rewrite-over-lea-target to expect the collector error, this case is the only SCE test of the entry-root rule on either target; whichever of the two merges second resolves the Collect conflict in MacOsImage.cpp as Collect(source, headers, {}, &entryRoots, message, nullptr, extraEntries).
  • Overlap. pr_overlap.py cannot compare this branch with #10249 (MacOsImage.cpp) and #10861 (MacOsImage.cpp, test_sce_code_extent.py), because both conflict with main. Checked by hand: #10861 changes the same Collect call in ScanTls (line 293 on main, lines 293 and 294 here), adding extraEntries where this PR passes &entryRoots, and whichever lands second keeps the entryRoots declaration and passes both arguments, Collect(source, headers, {}, &entryRoots, message, nullptr, extraEntries). That is the only conflict this PR adds: a trial merge with #10861 also conflicts in GuestModuleBuilder.cpp, RelinkerPipeline.cpp and docs/dev/debt/relinker.md, as main alone does, in files this PR does not touch. #10861's new extraEntries parameter of ScanTls (line 290 here), its ScanTls call in WriteMacOsImage (line 456 here) and its new expectations for sce-entry-after-code-<target> and sce-tls-rewrite-over-lea-target (cases at lines 248 and 269 here) merge cleanly with lea_into_tls_fixture (line 184) and the new case (lines 241 and 242). #10249 changes one expression in WriteMacOsImage, the displacement of a TLS stub jump (line 636 on main, 640 here), not ScanTls (lines 290 to 345 here); MacOsImage.cpp merges without a conflict, and its conflicts with main are in State.hpp and libSceJobManager/Export.cpp.

Tested

Windows 11, GCC 15.2.0 (WinLibs UCRT), relinker-only Release build (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON); synthetic fixtures only, no title or homebrew.

  • Counter-check (run on 4017310678, before the rebase): sce_code_extent with the new case on untouched 4017310678 fails with AssertionError: ('sce-tls-rewrite-over-data-target-macos', 0, ...); the Windows case before it passes. The same input run directly: Linux exit 0 with the fs load unchanged, --windows exit 2 at offset 0x244, --macos exit 0 with the fs load replaced. With the change --macos exits 2 with the Windows message and Linux and --windows are unchanged. Rebased onto 3a2c51afd2, which has no relinker changes since 4017310678.
  • Merged current main (88795ed448) into the branch without conflicts (9ef8b4b75a; the earlier merge of 1be850b6e1 is b7d06974f2); since 3a2c51afd2, #8076, #9408 and #10561 changed MacOsImage.cpp, test_sce_code_extent.py or CodeInstructionCollector.cpp, none of them in lines of this PR, and neither file of this PR changed after 1be850b6e1; tools/check_main_sync.py reported 0 behind and a clean merge at 88795ed448. On 9ef8b4b75a, ctest -R 'sce_code_extent|macos_tls|tls_function_coverage|windows_tls_protected|macos_gs|macos_trace_imports' -j 6: 40 tests passed: sce_code_extent (2.4 s), macos_tls_alu, macos_tls_overlap, macos_gs_traps, macos_trace_imports, windows_tls_protected_entries and the 34 tls_function_coverage_* tests.
  • Full suite on 9ef8b4b75a: ctest --test-dir build-relinker -j 6: 310 tests, 307 passed, long_paths skipped; failures known on this machine on main as well: select_tests (Windows symlink fixture) and patch_advisor_unit (path with spaces, which open #10667 fixes); both failed again alone.
  • python tools/check_conventions.py --base upstream/main with this title and description passed on 9ef8b4b75a.
  • Not tested on Linux or macOS; CI runs the tests on all three hosts.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5021529868 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11488). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-10-26T17:07:55Z. --- ### What The macOS TLS scan asked `CodeInstructionCollector::Collect` for no entry roots and replaced every supported `fs:[disp32]` access with `jmp rel32` and NOPs, even when a collector root lay inside the instruction. On untouched 4017310678, an SCE fixture whose relocation pointer makes `64 48 8b 04 25 00 00 00 00 c3` at 0x240 code and whose function holds `lea rax, [rip -> 0x244]` (0x244 taken as data) fails for `--windows` with `FAIL: TLS rewrite would overwrite an executable entry point (offset 0x244)`, but converts for `--macos` with exit 0 and `Took 1 pointer target(s) outside the unwind functions as data, the first at 0x244`, and the bytes the `lea` addresses are rewritten. The Windows TLS builder has refused this since #5890 and, for pointer targets taken as data, #8166. - **Rule.** `ScanTls` in `MacOsImage.cpp` now passes `&entryRoots` to `Collect`, as `WindowsTlsBuilder::Build` does, and before recording a supported access (load, store immediate, ALU read) throws `TLS rewrite would overwrite an executable entry point` at the root's file offset when a root lies strictly inside `[instruction, instruction + length)`. The macOS rewrite span is the instruction length, never longer than the Windows span, and both targets use the same collector roots and access forms, so every input this refuses is already refused by `--windows`. Code roots inside an `fs` instruction already fail in the collector with `overlapping instruction boundaries` on both targets; the newly refused inputs are pointer targets taken as data in PS4 unwind-gap images. GS traps are unchanged; on `main` the Windows builder does not check them against entry roots either (#11090 adds that check for Windows). `docs/dev/debt/relinker.md` line 33 stays accurate and is not edited, so this PR does not conflict with #10479 or #10861 there. - **Tests.** `test_sce_code_extent.py` gets `lea_into_tls_fixture()` and the case `sce-tls-rewrite-over-data-target-<target>` in the Windows/macOS loop, expecting `TLS rewrite would overwrite an executable entry point (offset 0x244)` and no output on both targets. After #10861 (Felipebmaitan), which rewrites the same `Collect` call and changes `sce-tls-rewrite-over-lea-target` to expect the collector error, this case is the only SCE test of the entry-root rule on either target; whichever of the two merges second resolves the `Collect` conflict in `MacOsImage.cpp` as `Collect(source, headers, {}, &entryRoots, message, nullptr, extraEntries)`. - **Overlap.** `pr_overlap.py` cannot compare this branch with #10249 (`MacOsImage.cpp`) and #10861 (`MacOsImage.cpp`, `test_sce_code_extent.py`), because both conflict with `main`. Checked by hand: #10861 changes the same `Collect` call in `ScanTls` (line 293 on `main`, lines 293 and 294 here), adding `extraEntries` where this PR passes `&entryRoots`, and whichever lands second keeps the `entryRoots` declaration and passes both arguments, `Collect(source, headers, {}, &entryRoots, message, nullptr, extraEntries)`. That is the only conflict this PR adds: a trial merge with #10861 also conflicts in `GuestModuleBuilder.cpp`, `RelinkerPipeline.cpp` and `docs/dev/debt/relinker.md`, as `main` alone does, in files this PR does not touch. #10861's new `extraEntries` parameter of `ScanTls` (line 290 here), its `ScanTls` call in `WriteMacOsImage` (line 456 here) and its new expectations for `sce-entry-after-code-<target>` and `sce-tls-rewrite-over-lea-target` (cases at lines 248 and 269 here) merge cleanly with `lea_into_tls_fixture` (line 184) and the new case (lines 241 and 242). #10249 changes one expression in `WriteMacOsImage`, the displacement of a TLS stub jump (line 636 on `main`, 640 here), not `ScanTls` (lines 290 to 345 here); `MacOsImage.cpp` merges without a conflict, and its conflicts with `main` are in `State.hpp` and `libSceJobManager/Export.cpp`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, GCC 15.2.0 (WinLibs UCRT), relinker-only Release build (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`); synthetic fixtures only, no title or homebrew. - Counter-check (run on 4017310678, before the rebase): `sce_code_extent` with the new case on untouched 4017310678 fails with `AssertionError: ('sce-tls-rewrite-over-data-target-macos', 0, ...)`; the Windows case before it passes. The same input run directly: Linux exit 0 with the `fs` load unchanged, `--windows` exit 2 at offset 0x244, `--macos` exit 0 with the `fs` load replaced. With the change `--macos` exits 2 with the Windows message and Linux and `--windows` are unchanged. Rebased onto 3a2c51afd2, which has no relinker changes since 4017310678. - Merged current `main` (88795ed448) into the branch without conflicts (9ef8b4b75a; the earlier merge of 1be850b6e1 is b7d06974f2); since 3a2c51afd2, #8076, #9408 and #10561 changed `MacOsImage.cpp`, `test_sce_code_extent.py` or `CodeInstructionCollector.cpp`, none of them in lines of this PR, and neither file of this PR changed after 1be850b6e1; `tools/check_main_sync.py` reported 0 behind and a clean merge at 88795ed448. On 9ef8b4b75a, `ctest -R 'sce_code_extent|macos_tls|tls_function_coverage|windows_tls_protected|macos_gs|macos_trace_imports' -j 6`: 40 tests passed: `sce_code_extent` (2.4 s), `macos_tls_alu`, `macos_tls_overlap`, `macos_gs_traps`, `macos_trace_imports`, `windows_tls_protected_entries` and the 34 `tls_function_coverage_*` tests. - Full suite on 9ef8b4b75a: `ctest --test-dir build-relinker -j 6`: 310 tests, 307 passed, `long_paths` skipped; failures known on this machine on `main` as well: `select_tests` (Windows symlink fixture) and `patch_advisor_unit` (path with spaces, which open #10667 fixes); both failed again alone. - `python tools/check_conventions.py --base upstream/main` with this title and description passed on 9ef8b4b75a. - Not tested on Linux or macOS; CI runs the tests on all three hosts. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
MarcZX10 commented 2026-10-26 17:21:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T17:21:28Z.

Review: CHANGES_REQUESTED


I reviewed the entry-root guard against the existing Windows TLS check and built this exact head in a Linux relinker-only Release build. The SCE integration script passed, and the focused CTest selection passed 40/40, including sce_code_extent and the TLS coverage tests. Hosted Linux, Windows, macOS arm64 and ASan relinker checks also pass; macOS x86_64 is still pending. Product jobs are skipped by the repository's path policy.

One repository requirement remains: CONTRIBUTING.md says to keep the branch up to date with main. tools/check_main_sync.py --strict reports this head 2 commits ahead and 37 behind current main, although the merge is clean and intervening main commits do not touch the PR's changed paths. Please sync the branch and rerun the focused tests; I found no independent code defect and will re-review the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5656184067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11488#pullrequestreview-5656184067). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T17:21:28Z. **Review:** CHANGES_REQUESTED --- I reviewed the entry-root guard against the existing Windows TLS check and built this exact head in a Linux relinker-only Release build. The SCE integration script passed, and the focused CTest selection passed 40/40, including `sce_code_extent` and the TLS coverage tests. Hosted Linux, Windows, macOS arm64 and ASan relinker checks also pass; macOS x86_64 is still pending. Product jobs are skipped by the repository's path policy. One repository requirement remains: `CONTRIBUTING.md` says to keep the branch up to date with `main`. `tools/check_main_sync.py --strict` reports this head 2 commits ahead and 37 behind current `main`, although the merge is clean and intervening `main` commits do not touch the PR's changed paths. Please sync the branch and rerun the focused tests; I found no independent code defect and will re-review the updated head.
jotitadev commented 2026-10-27 01:27:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:27:17Z.

Review: COMMENTED


Validated on macOS: Apple M2 Max, macOS 27.2, Xcode 27 clang, relinker-only Release (-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON). Head 9ef8b4b75a applied on current main cb45ae2ddf (clean merge). Two builds: arm64 native, and x86_64 under Rosetta with /usr/bin/python3 3.9.6.

  • Red/green. With only the test change on main, sce_code_extent fails at sce-tls-rewrite-over-data-target-macos (exit 0, output written) on both arm64 and Rosetta. With the fix, the focused set passes 41/41 on both: sce_code_extent, sce_code_gaps, macos_tls_*, macos_gs_traps, macos_trace_imports, windows_tls_protected_entries and the 34 tls_function_coverage_*. Full suite: arm64 309/309, Rosetta 307/307, the same counts as main.
  • Effect in the generated Mach-O on main. I converted lea_into_tls_fixture() with --macos --skip-sce-module. The output is an x86_64 Mach-O, and the guest bytes at 0x240 go from 64 48 8b 04 25 00 00 00 00 c3 to e9 bb 1d 00 00 90 90 90 90 c3. The four bytes the lea addresses (0x244) change from 25 00 00 00 to 00 90 90 90.
  • At runtime on main. I ran that Mach-O under Rosetta with stub x86_64 dylibs for lib.so, libc.prx and libkernel.prx. Aps5StartGuest_nid_no_patch calls the entry and prints the four bytes at the pointer it returns (the START pattern of test_macos_trace_imports.py). The TLS allocate/register hooks are no-ops, since the fs load never runs. The guest reads 00 90 90 90. The output is the same whether the relinker was built arm64 or x86_64.
  • With this PR, --macos exits 2 with TLS rewrite would overwrite an executable entry point (offset 0x244) and writes no output, matching --windows.

No findings.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661203954 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11488#pullrequestreview-5661203954). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T01:27:17Z. **Review:** COMMENTED --- Validated on macOS: Apple M2 Max, macOS 27.2, Xcode 27 clang, relinker-only Release (`-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`). Head `9ef8b4b75a` applied on current `main` `cb45ae2ddf` (clean merge). Two builds: arm64 native, and x86_64 under Rosetta with `/usr/bin/python3` 3.9.6. - **Red/green.** With only the test change on `main`, `sce_code_extent` fails at `sce-tls-rewrite-over-data-target-macos` (exit 0, output written) on both arm64 and Rosetta. With the fix, the focused set passes 41/41 on both: `sce_code_extent`, `sce_code_gaps`, `macos_tls_*`, `macos_gs_traps`, `macos_trace_imports`, `windows_tls_protected_entries` and the 34 `tls_function_coverage_*`. Full suite: arm64 309/309, Rosetta 307/307, the same counts as `main`. - **Effect in the generated Mach-O on `main`.** I converted `lea_into_tls_fixture()` with `--macos --skip-sce-module`. The output is an x86_64 Mach-O, and the guest bytes at 0x240 go from `64 48 8b 04 25 00 00 00 00 c3` to `e9 bb 1d 00 00 90 90 90 90 c3`. The four bytes the `lea` addresses (0x244) change from `25 00 00 00` to `00 90 90 90`. - **At runtime on `main`.** I ran that Mach-O under Rosetta with stub x86_64 dylibs for `lib.so`, `libc.prx` and `libkernel.prx`. `Aps5StartGuest_nid_no_patch` calls the entry and prints the four bytes at the pointer it returns (the `START` pattern of `test_macos_trace_imports.py`). The TLS allocate/register hooks are no-ops, since the `fs` load never runs. The guest reads `00 90 90 90`. The output is the same whether the relinker was built arm64 or x86_64. - **With this PR,** `--macos` exits 2 with `TLS rewrite would overwrite an executable entry point (offset 0x244)` and writes no output, matching `--windows`. No findings. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
maximilianfv commented 2026-10-27 06:52:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-27T06:52:31Z.

Review: APPROVED


Approve: the macOS TLS scan now refuses a supported fs: rewrite over a collector root the same way the Windows builder does, and the new case fails without the fix and passes with it on macOS x86_64.

Tested on Apple M1 Pro, macOS 27.0.1 (x86_64 build under Rosetta 2)

Applied at 9ef8b4b75 to mugurc's macOS series (27e968974) merged with main at 2742004ed2, with other open macOS fixes, then toggled only this PR. Full build, Release.

Selection: ctest -R 'sce_code_extent|sce_code_gaps|macos_tls|tls_function_coverage|windows_tls|macos_gs|macos_empty_tls' (42 tests: sce_code_extent, sce_code_gaps, macos_tls_alu, macos_tls_overlap, macos_empty_tls, macos_gs_traps, 4 windows_tls_* and 33 tls_function_coverage_*).

sce_code_extent (sce-tls-rewrite-over-data-target-*) other 41 tests
Without this PR (relinker unchanged, only the new test case added) Failed: AssertionError: ('sce-tls-rewrite-over-data-target-macos', 0, ...), output written with Took 1 pointer target(s) outside the unwind functions as data, the first at 0x244; the Windows case before it passed 41/41 passed
With this PR Passed 41/41 passed (two runs, 42/42 each)

main at b7105f7285 still passes nullptr to Collect in ScanTls, so the bug is still there, and this head merges with it without conflicts.

Code

The check at core/relinker/elfpatcher/src/macos/MacOsImage.cpp:338-340 is the Windows checkProtectedEntry rule (WindowsTlsBuilder.cpp), applied to the same span the macOS rewrite overwrites (info.Length). A root at the instruction start is still accepted (upper_bound), which sce-pointer-to-far-tls-load-* already covers. A root at the instruction end is accepted too. Passing &entryRoots only fills the set, so the collector's behaviour does not change. No defects found. Two non-blocking notes:

  1. GS traps on macOS (MacOsImage.cpp:316) are still not checked against entry roots. #11090 has since merged, so main now checks them for Windows (WindowsTlsBuilder.cpp:158-161), and the body's sentence "on main the Windows builder does not check them" is out of date. This is a separate gap for a follow-up PR, not part of this one.
  2. docs/dev/debt/relinker.md:33 still names only the Windows TLS rewrite as failing instead of overwriting an entry point. The body explains why it is left unchanged here; it can be updated once #10479 and #10861 settle.

AI-assisted: yes (Claude Code applied the PR, ran the tests, read the code and wrote this review).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5663264145 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11488#pullrequestreview-5663264145). Originally posted by [maximilianfv](https://github.com/maximilianfv) on 2026-10-27T06:52:31Z. **Review:** APPROVED --- Approve: the macOS TLS scan now refuses a supported `fs:` rewrite over a collector root the same way the Windows builder does, and the new case fails without the fix and passes with it on macOS x86_64. ### Tested on Apple M1 Pro, macOS 27.0.1 (x86_64 build under Rosetta 2) Applied at `9ef8b4b75` to mugurc's macOS series (`27e968974`) merged with `main` at `2742004ed2`, with other open macOS fixes, then toggled only this PR. Full build, Release. Selection: `ctest -R 'sce_code_extent|sce_code_gaps|macos_tls|tls_function_coverage|windows_tls|macos_gs|macos_empty_tls'` (42 tests: `sce_code_extent`, `sce_code_gaps`, `macos_tls_alu`, `macos_tls_overlap`, `macos_empty_tls`, `macos_gs_traps`, 4 `windows_tls_*` and 33 `tls_function_coverage_*`). | | `sce_code_extent` (`sce-tls-rewrite-over-data-target-*`) | other 41 tests | |---|---|---| | Without this PR (relinker unchanged, only the new test case added) | Failed: `AssertionError: ('sce-tls-rewrite-over-data-target-macos', 0, ...)`, output written with `Took 1 pointer target(s) outside the unwind functions as data, the first at 0x244`; the Windows case before it passed | 41/41 passed | | With this PR | Passed | 41/41 passed (two runs, 42/42 each) | `main` at `b7105f7285` still passes `nullptr` to `Collect` in `ScanTls`, so the bug is still there, and this head merges with it without conflicts. ### Code The check at `core/relinker/elfpatcher/src/macos/MacOsImage.cpp:338-340` is the Windows `checkProtectedEntry` rule (`WindowsTlsBuilder.cpp`), applied to the same span the macOS rewrite overwrites (`info.Length`). A root at the instruction start is still accepted (`upper_bound`), which `sce-pointer-to-far-tls-load-*` already covers. A root at the instruction end is accepted too. Passing `&entryRoots` only fills the set, so the collector's behaviour does not change. No defects found. Two non-blocking notes: 1. GS traps on macOS (`MacOsImage.cpp:316`) are still not checked against entry roots. #11090 has since merged, so `main` now checks them for Windows (`WindowsTlsBuilder.cpp:158-161`), and the body's sentence "on `main` the Windows builder does not check them" is out of date. This is a separate gap for a follow-up PR, not part of this one. 2. `docs/dev/debt/relinker.md:33` still names only the Windows TLS rewrite as failing instead of overwriting an entry point. The body explains why it is left unchanged here; it can be updated once #10479 and #10861 settle. AI-assisted: yes (Claude Code applied the PR, ran the tests, read the code and wrote this review).
MarcZX10 commented 2026-10-28 22:06:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T22:06:24Z.

Review: APPROVED


Reviewing exact head 9ef8b4b75abf646172f1b0cd8b683a21f15ba062.

What I ran

  • Inspected the exact code and fixture changes, current review evidence, and hosted checks.
  • Confirmed the branch includes a clean merge of main 88795ed448; current main has not changed the TLS scanner, code collector, or touched test file since that sync.
  • GitHub relinker jobs pass on macOS arm64, macOS x86_64, Linux, and Windows; ASan, conventions, labels, eligibility, and report checks pass.
  • I did not run a local build or tests.

Results

Check Result Evidence
Entry-root guard and regression fixture Reviewed Exact PR diff
Focused relinker tests Pass, author-reported 40 tests on the synced head; independent macOS reports give red/green 41/41 and 42/42 suites
Full relinker suite Pass with known failures, author-reported 307/310; two failures reproduced on main and one skipped
Hosted relinker platform matrix Pass macOS arm64/x86_64, Linux, Windows
Hosted ASan and policy checks Pass GitHub Actions
Local build and CTest Not run This review

Findings

Blocking

None.

Non-blocking

  • The guard uses the instruction length as the rewrite span and rejects only an entry root strictly inside it, preserving the boundary cases. The regression demonstrates the prior macOS output corrupting bytes addressed by lea and the new macOS behavior refusing it, matching the existing Windows protection.
  • The discussion identifies the related ScanTls overlap with #10861 and the separate broader merge conflicts. Reconcile both changes when integrating; the shared collector call must retain both the entry-root argument and extraEntries.

Sources

Not verified

  • I did not execute the native/macOS builds or tests locally; platform and regression evidence is from hosted checks and PR participants.

To get this to a good state

No blocking issue remains in the reviewed head. Preserve the collector arguments when resolving #10861's overlapping change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5690322079 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11488#pullrequestreview-5690322079). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-28T22:06:24Z. **Review:** APPROVED --- Reviewing exact head `9ef8b4b75abf646172f1b0cd8b683a21f15ba062`. ## What I ran - Inspected the exact code and fixture changes, current review evidence, and hosted checks. - Confirmed the branch includes a clean merge of main `88795ed448`; current main has not changed the TLS scanner, code collector, or touched test file since that sync. - GitHub relinker jobs pass on macOS arm64, macOS x86_64, Linux, and Windows; ASan, conventions, labels, eligibility, and report checks pass. - I did not run a local build or tests. ## Results | Check | Result | Evidence | |---|---|---| | Entry-root guard and regression fixture | Reviewed | Exact PR diff | | Focused relinker tests | Pass, author-reported | 40 tests on the synced head; independent macOS reports give red/green 41/41 and 42/42 suites | | Full relinker suite | Pass with known failures, author-reported | 307/310; two failures reproduced on main and one skipped | | Hosted relinker platform matrix | Pass | macOS arm64/x86_64, Linux, Windows | | Hosted ASan and policy checks | Pass | GitHub Actions | | Local build and CTest | Not run | This review | ## Findings ### Blocking None. ### Non-blocking - The guard uses the instruction length as the rewrite span and rejects only an entry root strictly inside it, preserving the boundary cases. The regression demonstrates the prior macOS output corrupting bytes addressed by `lea` and the new macOS behavior refusing it, matching the existing Windows protection. - The discussion identifies the related `ScanTls` overlap with #10861 and the separate broader merge conflicts. Reconcile both changes when integrating; the shared collector call must retain both the entry-root argument and `extraEntries`. ## Sources - [Repository relinker build and test rules](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/BUILD.md) - [Current pull request and independent test reports](https://github.com/boykopovar/AnyPS5/pull/11488) ## Not verified - I did not execute the native/macOS builds or tests locally; platform and regression evidence is from hosted checks and PR participants. ## To get this to a good state No blocking issue remains in the reviewed head. Preserve the collector arguments when resolving #10861's overlapping change.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11488
No description provided.