fix(relinker): reject executable TLS symbols in special sections #11038

Merged
plexerPK merged 1 commit from upstream-pr/11038 into main 2026-10-26 21:59:54 +00:00
plexerPK commented 2026-10-25 14:43:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by plexerPK on 2026-10-25T14:43:57Z.


What

Executable TLS relocations now reject defined STT_TLS symbols in reserved section indexes before folding their values into the TLS block. Previously SHN_ABS, SHN_COMMON and other reserved indexes could relink successfully when the symbol was not collected as an export. This applies the existing executable-export section policy to relocation-bound symbols; undefined imports retain their existing path.

The change is confined to definedTlsSymbolValue in the executable relocation path. #10731 changes the separate GuestImageReader module path, and merged #10646 validates executable exports.

Tested

macOS arm64, Release relinker-only build at c1bfd95e3a08a3b35f5576274bdea5da158002de on main 3a2c51afd2ee6a824cd3a294912c65e6bbf2b768. All four affected CTests pass: executable_tls_relocations, executable_export_bounds, linux_executable_exports and macos_executable_exports. The added matrix covers five section indexes, local/global binding, three TLS relocation kinds and four target modes (120 conversions); invalid sections exit 2 without output, and valid-section controls retain the existing Windows/macOS DTPMOD64 rejection. The regression failed before the guard. Conventions and diff checks pass.

Current official overlap reports no conflicting hunks but cannot compare #8076, which conflicts with main; its actual pipeline hunk was manually confirmed to concern separate unwind scanning. Fresh title/text and actual file/diff checks found no competing executable-section guard. #10730's current nonempty-TLS change merges cleanly, and its normal-section empty-TLS cases keep their diagnostic path. Own synthetic ELF fixtures only: these are output-format conversions on macOS, with no Linux/Windows host execution, guest/title execution, GPU or hosted-CI result claimed.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5005722037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11038). Originally posted by [plexerPK](https://github.com/plexerPK) on 2026-10-25T14:43:57Z. --- ### What Executable TLS relocations now reject defined STT_TLS symbols in reserved section indexes before folding their values into the TLS block. Previously SHN_ABS, SHN_COMMON and other reserved indexes could relink successfully when the symbol was not collected as an export. This applies the existing executable-export section policy to relocation-bound symbols; undefined imports retain their existing path. The change is confined to definedTlsSymbolValue in the executable relocation path. #10731 changes the separate GuestImageReader module path, and merged #10646 validates executable exports. ### Tested macOS arm64, Release relinker-only build at `c1bfd95e3a08a3b35f5576274bdea5da158002de` on main `3a2c51afd2ee6a824cd3a294912c65e6bbf2b768`. All four affected CTests pass: `executable_tls_relocations`, `executable_export_bounds`, `linux_executable_exports` and `macos_executable_exports`. The added matrix covers five section indexes, local/global binding, three TLS relocation kinds and four target modes (120 conversions); invalid sections exit 2 without output, and valid-section controls retain the existing Windows/macOS DTPMOD64 rejection. The regression failed before the guard. Conventions and diff checks pass. Current official overlap reports no conflicting hunks but cannot compare #8076, which conflicts with main; its actual pipeline hunk was manually confirmed to concern separate unwind scanning. Fresh title/text and actual file/diff checks found no competing executable-section guard. #10730's current nonempty-TLS change merges cleanly, and its normal-section empty-TLS cases keep their diagnostic path. Own synthetic ELF fixtures only: these are output-format conversions on macOS, with no Linux/Windows host execution, guest/title execution, GPU or hosted-CI result claimed. <!-- 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. --> ### 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: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-25 15:00:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:00:59Z.

Review: APPROVED


Reviewed exact head c1bfd95e3a08a3b35f5576274bdea5da158002de. I configured and built the relinker-only Release target locally, then ran test_executable_tls_relocations.py against that exact binary; it passes. The test exercises the five section indexes across binding, relocation kind and target format, and preserves valid-section controls. git diff --check upstream/main...HEAD and conventions pass. Hosted Ubuntu, Windows, macOS arm64, macOS x86_64 and ASan relinker jobs all pass; product jobs are skipped by path policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5643774572 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11038#pullrequestreview-5643774572). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T15:00:59Z. **Review:** APPROVED --- Reviewed exact head `c1bfd95e3a08a3b35f5576274bdea5da158002de`. I configured and built the relinker-only Release target locally, then ran `test_executable_tls_relocations.py` against that exact binary; it passes. The test exercises the five section indexes across binding, relocation kind and target format, and preserves valid-section controls. `git diff --check upstream/main...HEAD` and conventions pass. Hosted Ubuntu, Windows, macOS arm64, macOS x86_64 and ASan relinker jobs all pass; product jobs are skipped by path policy.
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!11038
No description provided.