fix(relinker): validate complete relocation symbol entries #4952

Merged
Ondra97 merged 1 commit from upstream-pr/4952 into main 2026-10-14 05:27:03 +00:00
Ondra97 commented 2026-10-13 06:06:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-13T06:06:59Z.


What

The executable relocation reader accepted symbol indices beyond DT_OS_SYMTABSZ when the bytes remained inside the file. A Linux fixture declaring only the null symbol (24 bytes), but referring to symbol 1, exited successfully and wrote an output. Named imports also required only five bytes of a 24-byte symbol entry.

Use one symbol-position check for ordinary imports and the zero-value section symbols accepted by RELATIVE relocations. Require a complete symbol record and respect the declared table size when present. NONE relocations continue to ignore their symbol field. Export handling is unchanged.

Tested

Windows 11 x64, WinLibs MinGW-w64 GCC 15.2.0, Python 3.14, Release relinker-only with BUILD_TESTING=ON. Rebased onto current main a5f493f90dca348a65561aed4bb325a629d1b668; head f10ab0b6ab9dc9e3e897be9c458d828d91168c69.

  • Release build succeeds. Full CTest suite: 152/152 pass, no skips, 44.51 seconds. All 9 targeted relocation, TLS, diagnostic and code-extent tests also pass.
  • Reused the common symbol bounds check in the new executable TLS reader. Six added cases cover DTPMOD64, DTPOFF64 and TPOFF64, each with a defined or imported symbol beyond DT_OS_SYMTABSZ; conversion fails without creating an output. Existing valid TLS behavior remains covered.
  • Conventions, whitespace and test registration checks pass; all 23 built test executables are registered. Source review found no issue with the conflict resolution.
  • Upstream TLS handling, import function/weak classification, conversion diagnostics and SCE code extent handling are preserved. NONE and symbol-free TLS relocations retain their bypass.
  • The existing conventions_function_bodies test took 34.52 seconds under parallel load and 26.31 seconds in isolation. Its timeout was not changed.

Related #5229 preserves executable defined-symbol relocations and partly overlaps the ordinary symbol read. This bounds correction does not depend on that feature; its rebase needs to retain the common bounds lookup. Their combination was not built or tested here.

No console title or Linux/macOS host execution was performed during this rebase validation.

Checklist

  • Based on current main; no other open PR implements the same fix
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stub added
  • No notes, investigation Markdown files or images added to the repository
  • New third-party code is a submodule built from source: no dependency added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839118150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4952). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-13T06:06:59Z. --- ### What The executable relocation reader accepted symbol indices beyond `DT_OS_SYMTABSZ` when the bytes remained inside the file. A Linux fixture declaring only the null symbol (24 bytes), but referring to symbol 1, exited successfully and wrote an output. Named imports also required only five bytes of a 24-byte symbol entry. Use one symbol-position check for ordinary imports and the zero-value section symbols accepted by RELATIVE relocations. Require a complete symbol record and respect the declared table size when present. NONE relocations continue to ignore their symbol field. Export handling is unchanged. ### Tested Windows 11 x64, WinLibs MinGW-w64 GCC 15.2.0, Python 3.14, Release relinker-only with BUILD_TESTING=ON. Rebased onto current `main` `a5f493f90dca348a65561aed4bb325a629d1b668`; head `f10ab0b6ab9dc9e3e897be9c458d828d91168c69`. - Release build succeeds. Full CTest suite: 152/152 pass, no skips, 44.51 seconds. All 9 targeted relocation, TLS, diagnostic and code-extent tests also pass. - Reused the common symbol bounds check in the new executable TLS reader. Six added cases cover DTPMOD64, DTPOFF64 and TPOFF64, each with a defined or imported symbol beyond DT_OS_SYMTABSZ; conversion fails without creating an output. Existing valid TLS behavior remains covered. - Conventions, whitespace and test registration checks pass; all 23 built test executables are registered. Source review found no issue with the conflict resolution. - Upstream TLS handling, import function/weak classification, conversion diagnostics and SCE code extent handling are preserved. NONE and symbol-free TLS relocations retain their bypass. - The existing conventions_function_bodies test took 34.52 seconds under parallel load and 26.31 seconds in isolation. Its timeout was not changed. Related #5229 preserves executable defined-symbol relocations and partly overlaps the ordinary symbol read. This bounds correction does not depend on that feature; its rebase needs to retain the common bounds lookup. Their combination was not built or tested here. No console title or Linux/macOS host execution was performed during this rebase validation. ### Checklist - [x] Based on current `main`; no other open PR implements the same fix - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stub added - [x] No notes, investigation Markdown files or images added to the repository - [x] New third-party code is a submodule built from source: no dependency added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (Codex)
xXPBSXx commented 2026-10-13 08:41:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:41:15Z.


Windows test: head 5e5ce90f0 merged onto current main 5f426f947 (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter ^jmprel_table_bounds$: jmprel_table_bounds passed (1 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141723887 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4952#issuecomment-6141723887). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:41:15Z. --- Windows test: head `5e5ce90f0` merged onto current `main` `5f426f947` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest with the filter `^jmprel_table_bounds$`: jmprel_table_bounds passed (1 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
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!4952
No description provided.