fix(relinker): tell code from data in images without PT_SCE_DYNLIBDATA #13716

Closed
simnJS wants to merge 6 commits from upstream-pr/13716 into main
simnJS commented 2026-10-31 02:25:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-10-31T02:25:41Z.


What

The code analysis builds its unwind function list, and with it the code/data decision for a relocation or lea target outside every unwind function, only for an image with a PT_SCE_DYNLIBDATA segment. An image without one leaves the list empty, so addPointerRoot follows every such target as code and BuildControlFlowGraph is told to follow code addresses. Read the unwind table in that branch as well, so an image with PT_GNU_EH_FRAME and no PT_SCE_DYNLIBDATA gets the same classification. An image with neither keeps the previous behaviour.

Trackmania (PPSA02195, 01.026.000) has no PT_SCE_DYNLIBDATA in its executable nor in any of its five bundled modules, and its eboot statically links the OpenSSL CRYPTOGAMS x86-64 assembly, which keeps its constant blocks between the unwind functions. Eight lea instructions take the address of its AES constants and two take the address of the Keccak round constants. Those bytes were followed as code, and the Windows TLS rewrite stopped on 64 22 d0 at va 0x1850935, then on 64 20 73 71 at va 0x1870715, which is the d sq of the string Keccak-1600 absorb and squeeze for x86_64, CRYPTOGAMS by <[email protected]>. With this change the conversion takes 55 pointer targets as data and completes.

This is the same classification the existing debt entry describes for PT_SCE_DYNLIBDATA images, applied to an image that has the unwind table it needs. It does not change the masking of undecodable constant tables in RelativeJumpTables.cpp, which leaves a gap alone when it decodes as valid instructions.

Tested

Linux, WSL Ubuntu 24.04.1, GCC 13.3.0, the distribution and compiler of the ubuntu-24.04 runner, replicating .github/workflows/fork-linux.yml: same CMake flags and ANYPS5_AGC_EXECUTION_TESTS, ANYPS5_REQUIRE_VULKAN=1 on lavapipe, GALLIUM_OVERRIDE_CPU_CAPS=avx, ctest --timeout 120 --repeat until-pass:2, full build then the libs target then every test. Run at --parallel 12 rather than 4, the same value on both sides.

  • On 813496001e, this branch's base: 3020 of 3029 pass. Nine fail: agc_driver_frame_capture_eop, agc_driver_frame_replay, agc_driver_frame_replay_concurrent, agc_driver_frame_replay_shader, agc_driver_frame_replay_shader_host, agc_driver_recorder, agc_storage_idle_writeback_race, agc_storage_kept_unit_settle, log_file.
  • On this branch: 3023 of 3032 pass, the same nine and no others.

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release:

  • tls_function_coverage_pointer_target_data (new): a non-SCE image whose function takes the address of 64 20 00 past the end of its unwind function. It fails on the base with Unsupported Windows guest TLS instruction (bytes: 64 20 00) (offset 0x1300) and passes here, reporting the target as data.
  • The whole tls_function_coverage label, tls_diagnostics, gs_trap_entry_roots and macos_gs_traps: 38 of 38 pass.
  • Trackmania (PPSA02195, 01.026.000) Windows conversion: completes, 5 modules, 2558 external prx references, Took 55 pointer target(s) outside the unwind functions as data, the first at 0x1850770. On the base it stops with Unsupported Windows guest TLS instruction.

Not run: the full Windows suite on this branch, and the fork CI. GitHub Actions is disabled on my account at the moment, so the Linux figures above come from the local replica described here, not from a runner.

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: PPSA02195 #13709 conversion; the runtime then stops on the executable's own module name, reported there
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5093640817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13716). Originally posted by [simnJS](https://github.com/simnJS) on 2026-10-31T02:25:41Z. --- ### What The code analysis builds its unwind function list, and with it the code/data decision for a relocation or `lea` target outside every unwind function, only for an image with a `PT_SCE_DYNLIBDATA` segment. An image without one leaves the list empty, so `addPointerRoot` follows every such target as code and `BuildControlFlowGraph` is told to follow code addresses. Read the unwind table in that branch as well, so an image with `PT_GNU_EH_FRAME` and no `PT_SCE_DYNLIBDATA` gets the same classification. An image with neither keeps the previous behaviour. Trackmania (PPSA02195, 01.026.000) has no `PT_SCE_DYNLIBDATA` in its executable nor in any of its five bundled modules, and its eboot statically links the OpenSSL CRYPTOGAMS x86-64 assembly, which keeps its constant blocks between the unwind functions. Eight `lea` instructions take the address of its AES constants and two take the address of the Keccak round constants. Those bytes were followed as code, and the Windows TLS rewrite stopped on `64 22 d0` at va `0x1850935`, then on `64 20 73 71` at va `0x1870715`, which is the `d sq` of the string `Keccak-1600 absorb and squeeze for x86_64, CRYPTOGAMS by <[email protected]>`. With this change the conversion takes 55 pointer targets as data and completes. This is the same classification the existing debt entry describes for `PT_SCE_DYNLIBDATA` images, applied to an image that has the unwind table it needs. It does not change the masking of undecodable constant tables in `RelativeJumpTables.cpp`, which leaves a gap alone when it decodes as valid instructions. ### Tested Linux, WSL Ubuntu 24.04.1, GCC 13.3.0, the distribution and compiler of the `ubuntu-24.04` runner, replicating `.github/workflows/fork-linux.yml`: same CMake flags and `ANYPS5_AGC_EXECUTION_TESTS`, `ANYPS5_REQUIRE_VULKAN=1` on lavapipe, `GALLIUM_OVERRIDE_CPU_CAPS=avx`, `ctest --timeout 120 --repeat until-pass:2`, full build then the `libs` target then every test. Run at `--parallel 12` rather than 4, the same value on both sides. - On `813496001e`, this branch's base: 3020 of 3029 pass. Nine fail: `agc_driver_frame_capture_eop`, `agc_driver_frame_replay`, `agc_driver_frame_replay_concurrent`, `agc_driver_frame_replay_shader`, `agc_driver_frame_replay_shader_host`, `agc_driver_recorder`, `agc_storage_idle_writeback_race`, `agc_storage_kept_unit_settle`, `log_file`. - On this branch: 3023 of 3032 pass, the same nine and no others. Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release: - `tls_function_coverage_pointer_target_data` (new): a non-SCE image whose function takes the address of `64 20 00` past the end of its unwind function. It fails on the base with `Unsupported Windows guest TLS instruction (bytes: 64 20 00) (offset 0x1300)` and passes here, reporting the target as data. - The whole `tls_function_coverage` label, `tls_diagnostics`, `gs_trap_entry_roots` and `macos_gs_traps`: 38 of 38 pass. - Trackmania (PPSA02195, 01.026.000) Windows conversion: completes, 5 modules, 2558 external prx references, `Took 55 pointer target(s) outside the unwind functions as data, the first at 0x1850770`. On the base it stops with `Unsupported Windows guest TLS instruction`. Not run: the full Windows suite on this branch, and the fork CI. GitHub Actions is disabled on my account at the moment, so the Linux figures above come from the local replica described here, not from a runner. ### Checklist - [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: none - [x] Fixes: none - [x] Unblocks: PPSA02195 #13709 conversion; the runtime then stops on the executable's own module name, reported there - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-31 02:42:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T02:42:58Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The source change and relevant Linux, Windows, and ASAN jobs look sound, but the live overlap report identifies #11525 on the same debt-file lines and the required landing order is not yet agreed.

What I ran

Reviewed head c078d0fb7aa4426dc8ab9b47e8d961424e75ce73, PR base d30e04fb8a381100fa7845f4d3853c042551e6a9, and current main 0cc02f7cde69941f651819b1f7a80f7aa722a08b; the current-main merge preview was clean. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. I did not build or run tests locally.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13716
gh pr checks 13716 --repo boykopovar/AnyPS5
gh api repos/boykopovar/AnyPS5/issues/13716/comments --jq '.[] | {id,user:.user.login,created_at,body}'

Results

Check Result
Diff, conventions, Python syntax, test registration Passed on the exact head.
Current-main merge preview Clean; no declared dependencies.
Test-quality helper Not executable in the isolated precheck checkout because the workspace-only script is absent; this does not report a source failure.
Hosted relinker CI Ubuntu and Windows relinker jobs passed; the ASAN tls_function_coverage job passed. Two macOS relinker jobs were pending. Broader Linux, write-watch, register-context, and Windows product jobs were skipped by workflow selection.
Author-reported evidence The PR reports a Windows focused suite of 38/38 and a Trackmania conversion that succeeds after failing on the base. Its Linux WSL full run reports 3023/3032 on the branch, with the same nine failures on base; these are author-reported, not reproduced here.
Overlap rule The current overlap report lists #11525 for docs/dev/debt/relinker.md lines 39–40. I found no landing-order agreement in either PR's discussion.
Unedited output from checks

Precheck excerpts:

Head unchanged at completion: **True**
Base unchanged at completion: **True**
| diff_check | passed | `git diff --check d30e04fb8a381100fa7845f4d3853c042551e6a9...c078d0fb7aa4426dc8ab9b47e8d961424e75ce73` |
| conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base d30e04fb8a381100fa7845f4d3853c042551e6a9 --head c078d0fb7aa4426dc8ab9b47e8d961424e75ce73 --title fix(relinker): tell code from data in images without PT_SCE_DYNLIBDATA --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13716-c078d0fb7aa4/pr-body.md` |
| python_syntax | passed | `/usr/bin/python3 -m py_compile core/relinker/relinker/tests/test_tls_function_coverage.py` |
| python_test_registration | passed | `/usr/bin/python3 tools/check_test_registration.py --scripts` |
| live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 13716 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13716-c078d0fb7aa4/stack` |

Hosted checks:

relinker (macos-latest, clang++)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364215
relinker (macos-latest, clang++, x86_64)	pending	0	https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364156
relinker-asan	pass	2m39s	https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364141
relinker (ubuntu-latest, g++)	pass	4m30s	https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364243
relinker (windows-latest, g++)	pass	10m8s	https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364161

Overlap report row:

| [PR 11525](https://www.github.com/boykopovar/AnyPS5/pull/11525) | `docs/dev/debt/relinker.md` [L39-40](https://github.com/boykopovar/AnyPS5/blob/0cc02f7cde69941f651819b1f7a80f7aa722a08b/docs/dev/debt/relinker.md#L39-L40) |  |  |

Negative control

Assertion Change to code under test Result
The new pointer-target fixture distinguishes the base behavior Use the base code that follows the unwind range only for PT_SCE_DYNLIBDATA images The author reports that the base conversion fails on the TLS bytes and the branch succeeds; I did not run this control.

Findings

Blocking

The overlap report names #11525 on the same docs/dev/debt/relinker.md lines changed here. CONTRIBUTING.md requires authors of overlapping PRs to agree on which lands first and declare that order with Depends on; neither discussion records an agreement yet. Please coordinate the landing order with #11525's author and update the checklist dependency entry to match.

Non-blocking

I found no separate source-level blocker. The two macOS relinker jobs were still pending at the last check snapshot.

Sources

Not verified

No local build or test execution, full product CI, physical-console run, or title runtime. The author reports local Windows and Linux/WSL2 results; the macOS relinker jobs were pending, and the workflow skipped broader Linux and specialized jobs.

To get this to a good state

Please agree with #11525's author on landing order and record it in the Depends on checklist. I will rerun the same relevant checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5720637238 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13716#pullrequestreview-5720637238). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T02:42:58Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The source change and relevant Linux, Windows, and ASAN jobs look sound, but the live overlap report identifies #11525 on the same debt-file lines and the required landing order is not yet agreed. ## What I ran Reviewed head `c078d0fb7aa4426dc8ab9b47e8d961424e75ce73`, PR base `d30e04fb8a381100fa7845f4d3853c042551e6a9`, and current `main` `0cc02f7cde69941f651819b1f7a80f7aa722a08b`; the current-main merge preview was clean. Environment: Linux 6.1.0-54-amd64, Python 3.11.2, GCC 12.2.0. I did not build or run tests locally. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13716 gh pr checks 13716 --repo boykopovar/AnyPS5 gh api repos/boykopovar/AnyPS5/issues/13716/comments --jq '.[] | {id,user:.user.login,created_at,body}' ``` ## Results | Check | Result | |---|---| | Diff, conventions, Python syntax, test registration | Passed on the exact head. | | Current-main merge preview | Clean; no declared dependencies. | | Test-quality helper | Not executable in the isolated precheck checkout because the workspace-only script is absent; this does not report a source failure. | | Hosted relinker CI | Ubuntu and Windows relinker jobs passed; the ASAN `tls_function_coverage` job passed. Two macOS relinker jobs were pending. Broader Linux, write-watch, register-context, and Windows product jobs were skipped by workflow selection. | | Author-reported evidence | The PR reports a Windows focused suite of 38/38 and a Trackmania conversion that succeeds after failing on the base. Its Linux WSL full run reports 3023/3032 on the branch, with the same nine failures on base; these are author-reported, not reproduced here. | | Overlap rule | The current overlap report lists #11525 for `docs/dev/debt/relinker.md` lines 39–40. I found no landing-order agreement in either PR's discussion. | <details> <summary>Unedited output from checks</summary> Precheck excerpts: ```text Head unchanged at completion: **True** Base unchanged at completion: **True** | diff_check | passed | `git diff --check d30e04fb8a381100fa7845f4d3853c042551e6a9...c078d0fb7aa4426dc8ab9b47e8d961424e75ce73` | | conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base d30e04fb8a381100fa7845f4d3853c042551e6a9 --head c078d0fb7aa4426dc8ab9b47e8d961424e75ce73 --title fix(relinker): tell code from data in images without PT_SCE_DYNLIBDATA --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13716-c078d0fb7aa4/pr-body.md` | | python_syntax | passed | `/usr/bin/python3 -m py_compile core/relinker/relinker/tests/test_tls_function_coverage.py` | | python_test_registration | passed | `/usr/bin/python3 tools/check_test_registration.py --scripts` | | live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 13716 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13716-c078d0fb7aa4/stack` | ``` Hosted checks: ```text relinker (macos-latest, clang++) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364215 relinker (macos-latest, clang++, x86_64) pending 0 https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364156 relinker-asan pass 2m39s https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364141 relinker (ubuntu-latest, g++) pass 4m30s https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364243 relinker (windows-latest, g++) pass 10m8s https://github.com/boykopovar/AnyPS5/actions/runs/41159961846/job/124415364161 ``` Overlap report row: ```text | [PR 11525](https://www.github.com/boykopovar/AnyPS5/pull/11525) | `docs/dev/debt/relinker.md` [L39-40](https://github.com/boykopovar/AnyPS5/blob/0cc02f7cde69941f651819b1f7a80f7aa722a08b/docs/dev/debt/relinker.md#L39-L40) | | | ``` </details> ## Negative control | Assertion | Change to code under test | Result | |---|---|---| | The new pointer-target fixture distinguishes the base behavior | Use the base code that follows the unwind range only for `PT_SCE_DYNLIBDATA` images | The author reports that the base conversion fails on the TLS bytes and the branch succeeds; I did not run this control. | ## Findings ### Blocking The overlap report names #11525 on the same `docs/dev/debt/relinker.md` lines changed here. `CONTRIBUTING.md` requires authors of overlapping PRs to agree on which lands first and declare that order with `Depends on`; neither discussion records an agreement yet. Please coordinate the landing order with #11525's author and update the checklist dependency entry to match. ### Non-blocking I found no separate source-level blocker. The two macOS relinker jobs were still pending at the last check snapshot. ## Sources - [Repository overlap rule at current `main` `0cc02f7`](https://github.com/boykopovar/AnyPS5/blob/0cc02f7cde69941f651819b1f7a80f7aa722a08b/CONTRIBUTING.md#L69-L69) - [Current overlap report on #13716](https://github.com/boykopovar/AnyPS5/pull/13716#issuecomment-6537921535) - [Changed unwind-range classification at reviewed head `c078d0f`](https://github.com/boykopovar/AnyPS5/blob/c078d0fb7aa4426dc8ab9b47e8d961424e75ce73/core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp#L126-L133) - [New pointer-target test at reviewed head](https://github.com/boykopovar/AnyPS5/blob/c078d0fb7aa4426dc8ab9b47e8d961424e75ce73/core/relinker/relinker/tests/test_tls_function_coverage.py#L799-L805) ## Not verified No local build or test execution, full product CI, physical-console run, or title runtime. The author reports local Windows and Linux/WSL2 results; the macOS relinker jobs were pending, and the workflow skipped broader Linux and specialized jobs. ## To get this to a good state Please agree with #11525's author on landing order and record it in the `Depends on` checklist. I will rerun the same relevant checks on the updated head.
MarcZX10 commented 2026-11-19 04:41:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T04:41:30Z.

Review: APPROVED


Reviewed — looks good

No verified blocking defect was found in the changed code; the author-reported focused tests support the intended classification behavior, but I did not run checks on this revision.

What I ran

Reviewed head 0d9f99a233f35944a3c2d6f7ba67836638b68649 using the prepared diff and repo_read.py for repository context. No commands or tests were run.

Results

Check Result Note
Diff and source review passed All six changed files read
Tests on this revision not run Test results in the description are author-reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the build, test suite, Windows conversion, or fork CI. The description reports focused Windows tests and a local Linux replica; these results were not independently confirmed. No files were excluded by the manifest's review status.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5969423894 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13716#pullrequestreview-5969423894). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T04:41:30Z. **Review:** APPROVED --- # Reviewed — looks good No verified blocking defect was found in the changed code; the author-reported focused tests support the intended classification behavior, but I did not run checks on this revision. ## What I ran Reviewed head `0d9f99a233f35944a3c2d6f7ba67836638b68649` using the prepared diff and `repo_read.py` for repository context. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | All six changed files read | | Tests on this revision | not run | Test results in the description are author-reported | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the build, test suite, Windows conversion, or fork CI. The description reports focused Windows tests and a local Linux replica; these results were not independently confirmed. No files were excluded by the manifest's review status. ## To get this to a good state Nothing is required.

Pull request closed

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!13716
No description provided.