fix(relinker): enforce DWARF CFI bounds, register rules and landing pad checks #12910

Open
slopgobblercobbler wants to merge 2 commits from upstream-pr/12910 into main
slopgobblercobbler commented 2026-10-29 14:02:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-29T14:02:48Z.


What

Audits and enforces DWARF Call Frame Information (.eh_frame) validation in Relinker::UnusedNidFilter::EhFrameReader:

  • Validates version 4 CIE address/segment field bounds and return address register column (strictly 16, representing %rip / return address (RA) per System V AMD64 psABI section 3.7 Figure 3.36 for x86-64 console binaries).
  • Bounds CIE augmentation strings, guards against unverified lengths, handles zero-byte S (signal frame) markers cleanly without demanding extra payload bytes, and skips trailing augmentation bytes up to augmentationEnd per LSB specifications.
  • Validates narrow relative displacements (DW_EH_PE_udata2, DW_EH_PE_udata4) against 64-bit integer overflow, while permitting DW_EH_PE_uleb128, DW_EH_PE_udata8, and DW_EH_PE_absptr to wrap modulo 2^64 for backward displacements as documented in docs/dev/debt/relinker.md.
  • Enforces that the entire half-open FDE interval [begin, end) is strictly enclosed within a single executable segment rather than merely checking endpoints, rejecting FDE ranges that cross segment gaps, while safely dropping empty FDEs (zero length) from removed functions.
  • Uses segment.FileSize consistently in EhFrameReader.
  • Updates test_tls_function_coverage.py expected message for the unwind metadata variant to match the reader's check.
  • Extends unwind_record_bounds_tests covering boundary cases for relative displacements (value 0xFFF0 wrapping modulo 2^64 for DW_EH_PE_uleb128 and DW_EH_PE_udata8), preserving upstream test additions, disjoint segment gaps, positive zS and zRS augmentations, extra augmentation skipping, return address register column 16 (psABI x86-64 RA), unterminated augmentation strings, text-segment bounds, and valid landing pads.
  • Records technical debt in docs/dev/debt/relinker.md.

Tested

  • Rebased on current upstream/main.
  • Unit test unwind_record_bounds_tests.
  • Integration test suite test_tls_function_coverage.py.
  • python tools/check_conventions.py --base upstream/main --head HEAD passed with 0 findings.
  • git diff --check upstream/main...HEAD clean (exit 0).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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:5069429158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-10-29T14:02:48Z. --- ### What Audits and enforces DWARF Call Frame Information (`.eh_frame`) validation in `Relinker::UnusedNidFilter::EhFrameReader`: - Validates version 4 CIE address/segment field bounds and return address register column (strictly 16, representing `%rip` / return address (RA) per System V AMD64 psABI section 3.7 Figure 3.36 for x86-64 console binaries). - Bounds CIE augmentation strings, guards against unverified lengths, handles zero-byte `S` (signal frame) markers cleanly without demanding extra payload bytes, and skips trailing augmentation bytes up to `augmentationEnd` per LSB specifications. - Validates narrow relative displacements (`DW_EH_PE_udata2`, `DW_EH_PE_udata4`) against 64-bit integer overflow, while permitting `DW_EH_PE_uleb128`, `DW_EH_PE_udata8`, and `DW_EH_PE_absptr` to wrap modulo 2^64 for backward displacements as documented in docs/dev/debt/relinker.md. - Enforces that the entire half-open FDE interval `[begin, end)` is strictly enclosed within a single executable segment rather than merely checking endpoints, rejecting FDE ranges that cross segment gaps, while safely dropping empty FDEs (zero length) from removed functions. - Uses `segment.FileSize` consistently in `EhFrameReader`. - Updates `test_tls_function_coverage.py` expected message for the `unwind` metadata variant to match the reader's check. - Extends `unwind_record_bounds_tests` covering boundary cases for relative displacements (value `0xFFF0` wrapping modulo 2^64 for `DW_EH_PE_uleb128` and `DW_EH_PE_udata8`), preserving upstream test additions, disjoint segment gaps, positive `zS` and `zRS` augmentations, extra augmentation skipping, return address register column 16 (psABI x86-64 RA), unterminated augmentation strings, text-segment bounds, and valid landing pads. - Records technical debt in `docs/dev/debt/relinker.md`. ### Tested - Rebased on current `upstream/main`. - Unit test `unwind_record_bounds_tests`. - Integration test suite `test_tls_function_coverage.py`. - `python tools/check_conventions.py --base upstream/main --head HEAD` passed with 0 findings. - `git diff --check upstream/main...HEAD` clean (exit 0). ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-29 14:12:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T14:12:16Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The focused unwind tests pass, but the new executable-segment check accepts an FDE whose range crosses an unmapped gap between executable segments.

What I ran

Reviewed head 362aa93e6530d63ef16cbadae63adb96f25e6beb against main at bb04a4f1ea0175e9e4f149f0359a764d62ff3296. The merge preview is clean (tree 2959c1942bf13024dee34b3fcbea4b277df981f5). Environment: Linux 6.1.0-54-amd64, GCC 12.2.0.

g++ -std=c++23 -O2 -Wall -Wextra -Werror \
  -Icore/relinker/relinker/include \
  -Icore/relinker/domain/include \
  -Icore/relinker/io/include \
  core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp \
  core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp \
  core/relinker/io/src/BufferUtils.cpp \
  -o /tmp/anyps5-unwind-12910
/tmp/anyps5-unwind-12910
python3 tools/check_conventions.py --base upstream/main --head upstream/pr-12910
git diff --check upstream/main...upstream/pr-12910

Results

Check Result
unwind_record_bounds focused executable Passed: 25 cases
Conventions Passed
Diff check Passed (exit 0; no output)
Hosted eligibility, conventions, intake, labels Pending at last check
Unedited output
$ /tmp/anyps5-unwind-12910
25 unwind record cases passed

$ python3 tools/check_conventions.py --base upstream/main --head upstream/pr-12910
All conventions checks passed.

$ git diff --check upstream/main...upstream/pr-12910

Negative control

Assertion Change made to the test input Outcome
An FDE range must remain within executable mapped memory. A temporary fixture used FDE [0x2000, 0x3010) with executable segments [0x2000, 0x2010) and [0x3000, 0x3010). The reader accepted the range across the unmapped gap [0x2010, 0x3000). This probe was not added to the PR test suite.

Findings

Blocking

  • inTextSegment checks individual addresses, and readFde checks only the first and final byte of the FDE range. Thus two endpoints in separate executable segments let the FDE cover a non-executable or unmapped gap. The focused fixture above reproduces this. Validate that the entire half-open range is covered by executable mapped memory (or otherwise reject ranges crossing segment gaps), and add a regression test for this case.

Non-blocking

  • The 25-case focused test passes on Linux. Hosted checks were still pending when queried.

Sources

Not verified

A full CMake build/CTest run, other operating systems, sanitizer builds, and PS5 behavior were not run or confirmed here.

To get this to a good state

Check full-range executable coverage and add a disjoint-segment gap regression case. I will rerun the same focused compile, conventions, and diff-check commands on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5699140214 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-5699140214). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T14:12:16Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The focused unwind tests pass, but the new executable-segment check accepts an FDE whose range crosses an unmapped gap between executable segments. ## What I ran Reviewed head `362aa93e6530d63ef16cbadae63adb96f25e6beb` against `main` at `bb04a4f1ea0175e9e4f149f0359a764d62ff3296`. The merge preview is clean (tree `2959c1942bf13024dee34b3fcbea4b277df981f5`). Environment: Linux 6.1.0-54-amd64, GCC 12.2.0. ```sh g++ -std=c++23 -O2 -Wall -Wextra -Werror \ -Icore/relinker/relinker/include \ -Icore/relinker/domain/include \ -Icore/relinker/io/include \ core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp \ core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp \ core/relinker/io/src/BufferUtils.cpp \ -o /tmp/anyps5-unwind-12910 /tmp/anyps5-unwind-12910 python3 tools/check_conventions.py --base upstream/main --head upstream/pr-12910 git diff --check upstream/main...upstream/pr-12910 ``` ## Results | Check | Result | |---|---| | `unwind_record_bounds` focused executable | Passed: 25 cases | | Conventions | Passed | | Diff check | Passed (exit 0; no output) | | Hosted eligibility, conventions, intake, labels | Pending at last check | <details> <summary>Unedited output</summary> ```text $ /tmp/anyps5-unwind-12910 25 unwind record cases passed $ python3 tools/check_conventions.py --base upstream/main --head upstream/pr-12910 All conventions checks passed. $ git diff --check upstream/main...upstream/pr-12910 ``` </details> ## Negative control | Assertion | Change made to the test input | Outcome | |---|---|---| | An FDE range must remain within executable mapped memory. | A temporary fixture used FDE `[0x2000, 0x3010)` with executable segments `[0x2000, 0x2010)` and `[0x3000, 0x3010)`. | The reader accepted the range across the unmapped gap `[0x2010, 0x3000)`. This probe was not added to the PR test suite. | ## Findings ### Blocking - `inTextSegment` checks individual addresses, and `readFde` checks only the first and final byte of the FDE range. Thus two endpoints in separate executable segments let the FDE cover a non-executable or unmapped gap. The focused fixture above reproduces this. Validate that the entire half-open range is covered by executable mapped memory (or otherwise reject ranges crossing segment gaps), and add a regression test for this case. ### Non-blocking - The 25-case focused test passes on Linux. Hosted checks were still pending when queried. ## Sources - [PR-head `EhFrameReader.cpp`, executable-segment membership and FDE range checks](https://github.com/boykopovar/AnyPS5/blob/362aa93e6530e9e4f16cbadae63adb96f25e6beb/core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp#L56-L66) - [PR-head FDE range validation](https://github.com/boykopovar/AnyPS5/blob/362aa93e6530e9e4f16cbadae63adb96f25e6beb/core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp#L238-L245) ## Not verified A full CMake build/CTest run, other operating systems, sanitizer builds, and PS5 behavior were not run or confirmed here. ## To get this to a good state Check full-range executable coverage and add a disjoint-segment gap regression case. I will rerun the same focused compile, conventions, and diff-check commands on the updated head.
adriadam10 commented 2026-10-29 16:27:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T16:27:43Z.

Review: CHANGES_REQUESTED


Thanks for the PR. The relinker (ubuntu-latest), relinker (windows-latest) and relinker-asan jobs fail, and I agree with the points already raised by @oneandonlydean, @MarcZX10 and @rooklz. To fix:

  • CI red: tls_function_coverage_metadata fails (unwind-outside.elf, test_tls_function_coverage.py:580). The new FDE check in ReadExceptionFunctions fires before Code analysis: function exceeds executable segment (CodeInstructionCollector.cpp:217). Keep one source of truth for this case and update the test expectation for the unwind variant only if the reader keeps the check.
  • Valid zS/zRS CIEs are rejected: EhFrameReader.cpp:208 requires remaining augmentation bytes before every character, but S consumes none. Move the bounds checks into the fields that read bytes and add positive zS and zRS tests (a real Linux libc.so.6 CIE uses zRS).
  • position != augmentationEnd (:258) rejects extra augmentation bytes that LSB lets readers skip. Skip to augmentationEnd instead, unless real data says otherwise.
  • FDE range (:244): only begin and end - 1 are checked, so [0x2000,0x3010) across executable segments [0x2000,0x2010) and [0x3000,0x3010) passes. Validate the whole interval against one containing segment, add that regression test, and say what you want for a leftover FDE of a removed function (begin 0 or outside text), which was accepted before.
  • Same bound in both layers: inTextSegment uses max(MemorySize, FileSize); the collector uses FileSize.
  • Real executables: run the converter from this head over at least one SCE module and one game executable and report that no new error appears. Give the source for requiring return-address column 16, or label it an assumption.
  • Description: the CIE identifier check is already on main (EhFrameReader.cpp:163) and no CFA/register-rule validation was added, only the return-address column. Also compute the case count in the test output instead of printing a literal 25, and state which rule you intend for full-width ULEB128 (rejected) versus udata8 (wraps), with a boundary test.

Welcome to push an updated head with these addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5701274314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-5701274314). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-29T16:27:43Z. **Review:** CHANGES_REQUESTED --- Thanks for the PR. The `relinker (ubuntu-latest)`, `relinker (windows-latest)` and `relinker-asan` jobs fail, and I agree with the points already raised by @oneandonlydean, @MarcZX10 and @rooklz. To fix: - **CI red:** `tls_function_coverage_metadata` fails (`unwind-outside.elf`, `test_tls_function_coverage.py:580`). The new FDE check in `ReadExceptionFunctions` fires before `Code analysis: function exceeds executable segment` (`CodeInstructionCollector.cpp:217`). Keep one source of truth for this case and update the test expectation for the `unwind` variant only if the reader keeps the check. - **Valid `zS`/`zRS` CIEs are rejected:** `EhFrameReader.cpp:208` requires remaining augmentation bytes before every character, but `S` consumes none. Move the bounds checks into the fields that read bytes and add positive `zS` and `zRS` tests (a real Linux `libc.so.6` CIE uses `zRS`). - **`position != augmentationEnd` (`:258`)** rejects extra augmentation bytes that LSB lets readers skip. Skip to `augmentationEnd` instead, unless real data says otherwise. - **FDE range (`:244`):** only `begin` and `end - 1` are checked, so `[0x2000,0x3010)` across executable segments `[0x2000,0x2010)` and `[0x3000,0x3010)` passes. Validate the whole interval against one containing segment, add that regression test, and say what you want for a leftover FDE of a removed function (begin 0 or outside text), which was accepted before. - **Same bound in both layers:** `inTextSegment` uses `max(MemorySize, FileSize)`; the collector uses `FileSize`. - **Real executables:** run the converter from this head over at least one SCE module and one game executable and report that no new error appears. Give the source for requiring return-address column 16, or label it an assumption. - **Description:** the CIE identifier check is already on `main` (`EhFrameReader.cpp:163`) and no CFA/register-rule validation was added, only the return-address column. Also compute the case count in the test output instead of printing a literal `25`, and state which rule you intend for full-width ULEB128 (rejected) versus `udata8` (wraps), with a boundary test. Welcome to push an updated head with these addressed.
adriadam10 commented 2026-10-30 13:03:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-30T13:03:33Z.

Review: CHANGES_REQUESTED


Thanks for the update. The zS/zRS, extra-augmentation, whole-interval FDE and FileSize points look addressed. Still open from the previous review:

  • Real executables: no run of the converter from this head over an SCE module and a game executable is reported. Please run at least one of each and state that no new error appears (or list the new ones). The new checks (return-address column, FDE and landing pad inside text) are exactly what real data could trip.
  • Return-address column 16: EhFrameReader.cpp:209 rejects every other column. Give the source (psABI x86-64 register 16 is RA) in the description, or label it an assumption for console binaries.
  • ULEB128 vs udata8: the description says ULEB128 relative overflow is covered by a test, but I find no boundary test for it in UnwindRecordBoundsTests.cpp. Add one (value just under and over the limit) so the rule "uleb128 throws, udata8 wraps" is pinned.

CI on this head was still running when I reviewed; it needs to be green before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5712636680 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-5712636680). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-30T13:03:33Z. **Review:** CHANGES_REQUESTED --- Thanks for the update. The `zS`/`zRS`, extra-augmentation, whole-interval FDE and `FileSize` points look addressed. Still open from the previous review: - **Real executables:** no run of the converter from this head over an SCE module and a game executable is reported. Please run at least one of each and state that no new error appears (or list the new ones). The new checks (return-address column, FDE and landing pad inside text) are exactly what real data could trip. - **Return-address column 16:** `EhFrameReader.cpp:209` rejects every other column. Give the source (psABI x86-64 register 16 is RA) in the description, or label it an assumption for console binaries. - **ULEB128 vs `udata8`:** the description says ULEB128 relative overflow is covered by a test, but I find no boundary test for it in `UnwindRecordBoundsTests.cpp`. Add one (value just under and over the limit) so the rule "uleb128 throws, udata8 wraps" is pinned. CI on this head was still running when I reviewed; it needs to be green before merge.
MarcZX10 commented 2026-11-14 06:17:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T06:17:56Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change based on the source reviewed; the claimed runtime checks were not independently run.

What I ran

Reviewed head d3ef816a61c8100b3b8e4cd499d3e6872de8b330. No commands or tests were run; repository access was read-only through repo_read.py.

Results

Check Result Note
Diff and changed-file review passed Four changed files read
Test execution not run Author-reported results not independently verified
Security and edge-case audit passed Reviewed reader and test changes

Findings

Blocking

None identified in the reviewed source.

Non-blocking

None.

Not verified

The complete text of the four changed files listed in the manifest was read. files.json was unavailable; the prepared file listing shows all four changed files included. The author-reported test runs, platform builds, converter runs, and convention checks were not independently run. The rest of the repository and excluded files were not read.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902214232 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-5902214232). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T06:17:56Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change based on the source reviewed; the claimed runtime checks were not independently run. ## What I ran Reviewed head `d3ef816a61c8100b3b8e4cd499d3e6872de8b330`. No commands or tests were run; repository access was read-only through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Diff and changed-file review | passed | Four changed files read | | Test execution | not run | Author-reported results not independently verified | | Security and edge-case audit | passed | Reviewed reader and test changes | ## Findings ### Blocking None identified in the reviewed source. ### Non-blocking None. ## Not verified The complete text of the four changed files listed in the manifest was read. `files.json` was unavailable; the prepared file listing shows all four changed files included. The author-reported test runs, platform builds, converter runs, and convention checks were not independently run. The rest of the repository and excluded files were not read. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-17 18:40:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T18:40:44Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head: 1372b5ece42487f324e2948d8ce5cb39e15e018b, base main.
  • Read the diff, description, commits and manifest from the review folder, then read the head of the encoded() function and the start of CodeInstructionCollector.cpp through the reader:
python3 repo_read.py search FileSize core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp
python3 repo_read.py search "uleb|Uleb|ULEB|0xFFF0|0xFFEF" core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp
  • No build, no unit test and no convention script were run.

Results

Check Result Note
Build and unit tests not run No builds in this review
check_conventions.py, git diff --check not run Author-reported only
Description vs code (uleb128 overflow) failed Not implemented, see Findings
Description vs code (FileSize) not applicable This PR does not touch the other file
Raw reader output
search FileSize in CodeInstructionCollector.cpp: 35 matching lines at 1372b5ece424
search uleb in EhFrameReader.cpp: 0 matching lines at 1372b5ece424

Findings

Blocking

None verified.

Non-blocking

  • The description says the PR pins DW_EH_PE_uleb128 displacements so that 0xFFF0 "throws overflow". The code does not do that. encoded() checks the overflow only for udata2, udata4 and the function-based absptr/udata8 cases (EhFrameReader.cpp:170, unchanged by this PR). uleb128 wraps silently. The test at UnwindRecordBoundsTests.cpp:102 asserts the wrap (no throw), and docs/dev/debt/relinker.md:350 documents it as wrapping. The code, test and debt note agree with each other, so the wrong part is the description. Fix the description wording before merge.
  • The description says the PR makes FileSize consistent between EhFrameReader and CodeInstructionCollector. This PR does not change CodeInstructionCollector.cpp, which already uses FileSize at head. The sentence is misleading but harmless.
  • inTextSegment() returns true when the binary has no executable PT_LOAD segment (EhFrameReader.cpp:67). The strict FDE and landing-pad checks then pass silently for such a binary. Probably intended, but worth a comment in the debt note if so.

Not verified

  • Build, unit tests and test_tls_function_coverage.py were not run. The test expectations are read from the diff only.
  • readCie() and readLsda() were not read in full at head. Only encoded() (EhFrameReader.cpp:141-182) was read.
  • The fixture assumptions for the new test cases (for example the case-18 expectation that an unchanged fixture is rejected) were not traced.
  • The debt entry's claim that CIE identifier 0 is required was not checked against the code.
  • files.json was not read. No exclusions are listed in the manifest.
  • Files read: EhFrameReader.cpp (diff, plus encoded() at head). Files read from the diff only: UnwindRecordBoundsTests.cpp, test_tls_function_coverage.py, docs/dev/debt/relinker.md.

Sources

To get this to a good state

Nothing is required. Correcting the uleb128 sentence in the description is optional, but recommended before an approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5944462694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-5944462694). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T18:40:44Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. ## What I ran - Head: `1372b5ece42487f324e2948d8ce5cb39e15e018b`, base `main`. - Read the diff, description, commits and manifest from the review folder, then read the head of the `encoded()` function and the start of `CodeInstructionCollector.cpp` through the reader: ``` python3 repo_read.py search FileSize core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp python3 repo_read.py search "uleb|Uleb|ULEB|0xFFF0|0xFFEF" core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp ``` - No build, no unit test and no convention script were run. ## Results | Check | Result | Note | |---|---|---| | Build and unit tests | not run | No builds in this review | | `check_conventions.py`, `git diff --check` | not run | Author-reported only | | Description vs code (uleb128 overflow) | failed | Not implemented, see Findings | | Description vs code (FileSize) | not applicable | This PR does not touch the other file | <details> <summary>Raw reader output</summary> ``` search FileSize in CodeInstructionCollector.cpp: 35 matching lines at 1372b5ece424 search uleb in EhFrameReader.cpp: 0 matching lines at 1372b5ece424 ``` </details> ## Findings **Blocking** None verified. **Non-blocking** - The description says the PR pins `DW_EH_PE_uleb128` displacements so that 0xFFF0 "throws overflow". The code does not do that. `encoded()` checks the overflow only for udata2, udata4 and the function-based absptr/udata8 cases (`EhFrameReader.cpp:170`, unchanged by this PR). uleb128 wraps silently. The test at `UnwindRecordBoundsTests.cpp:102` asserts the wrap (no throw), and `docs/dev/debt/relinker.md:350` documents it as wrapping. The code, test and debt note agree with each other, so the wrong part is the description. Fix the description wording before merge. - The description says the PR makes FileSize consistent between `EhFrameReader` and `CodeInstructionCollector`. This PR does not change `CodeInstructionCollector.cpp`, which already uses `FileSize` at head. The sentence is misleading but harmless. - `inTextSegment()` returns true when the binary has no executable PT_LOAD segment (`EhFrameReader.cpp:67`). The strict FDE and landing-pad checks then pass silently for such a binary. Probably intended, but worth a comment in the debt note if so. ## Not verified - Build, unit tests and `test_tls_function_coverage.py` were not run. The test expectations are read from the diff only. - `readCie()` and `readLsda()` were not read in full at head. Only `encoded()` (`EhFrameReader.cpp:141-182`) was read. - The fixture assumptions for the new test cases (for example the case-18 expectation that an unchanged fixture is rejected) were not traced. - The debt entry's claim that CIE identifier 0 is required was not checked against the code. - `files.json` was not read. No exclusions are listed in the manifest. - Files read: `EhFrameReader.cpp` (diff, plus `encoded()` at head). Files read from the diff only: `UnwindRecordBoundsTests.cpp`, `test_tls_function_coverage.py`, `docs/dev/debt/relinker.md`. ## Sources - [`encoded()` at head](https://github.com/boykopovar/AnyPS5/blob/1372b5ece42487f324e2948d8ce5cb39e15e018b/core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp#L141-L182) ## To get this to a good state Nothing is required. Correcting the uleb128 sentence in the description is optional, but recommended before an approval.
catminou4 commented 2026-11-25 06:56:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by catminou4 on 2026-11-25T06:56:07Z.

Review: CHANGES_REQUESTED


Reviewed at 1372b5ece4, applied on main 7a1c9bbccf, relinker-only Release build (GCC, Ubuntu 22.04).

  • Build failure on current main: unwind_record_bounds_tests no longer compiles:
    UnwindRecordBoundsTests.cpp:1137:35: error: redeclaration of 'std::vector<unsigned char> validLsdaBytes'
    UnwindRecordBoundsTests.cpp:1165:31: error: redeclaration of 'Domain::ProgramHeader validLsdaLoad'
    
    main has since added tests to the same main() with these names (for example #14573 and the CFI landing-pad coverage), so the merge is textually clean but does not build.
  • When the rest is built with -k 0, the 34 tls_function_coverage_* tests pass with the PR's EhFrameReader.cpp and the updated test_tls_function_coverage.py. With EhFrameReader.cpp from main, tls_function_coverage_metadata fails (function exceeds executable segment instead of the new FDE diagnostic), so the script change depends on the fix.
  • Requiring the CIE return-address register to be 16 matches x86-64, but it rejects any other value. Worth a line in the debt fragment if a module with another register is ever seen.

Not mergeable until it is rebased and unwind_record_bounds_tests builds and passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6053132457 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-6053132457). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T06:56:07Z. **Review:** CHANGES_REQUESTED --- Reviewed at 1372b5ece4, applied on `main` 7a1c9bbccf, relinker-only Release build (GCC, Ubuntu 22.04). - **Build failure on current `main`:** `unwind_record_bounds_tests` no longer compiles: ``` UnwindRecordBoundsTests.cpp:1137:35: error: redeclaration of 'std::vector<unsigned char> validLsdaBytes' UnwindRecordBoundsTests.cpp:1165:31: error: redeclaration of 'Domain::ProgramHeader validLsdaLoad' ``` `main` has since added tests to the same `main()` with these names (for example #14573 and the CFI landing-pad coverage), so the merge is textually clean but does not build. - When the rest is built with `-k 0`, the 34 `tls_function_coverage_*` tests pass with the PR's `EhFrameReader.cpp` and the updated `test_tls_function_coverage.py`. With `EhFrameReader.cpp` from `main`, `tls_function_coverage_metadata` fails (`function exceeds executable segment` instead of the new FDE diagnostic), so the script change depends on the fix. - Requiring the CIE return-address register to be 16 matches x86-64, but it rejects any other value. Worth a line in the debt fragment if a module with another register is ever seen. Not mergeable until it is rebased and `unwind_record_bounds_tests` builds and passes.
ligmaSec commented 2026-12-03 22:54:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:54:32Z.

Review: COMMENTED


The trial merge with main is clean. I reviewed the CFI decode bounds and per-record rule validation in source. Please retain positive fixtures for both a normal compiler-emitted .eh_frame and an FDE that restores previously saved state, with their expected unwind rules checked. They would guard against tightening a record boundary at the expense of supported output. Please move the direct relinker debt edit to a fragment. I did not run the relinker suite for this head.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6180074146 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12910#pullrequestreview-6180074146). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T22:54:32Z. **Review:** COMMENTED --- The trial merge with `main` is clean. I reviewed the CFI decode bounds and per-record rule validation in source. Please retain positive fixtures for both a normal compiler-emitted `.eh_frame` and an FDE that restores previously saved state, with their expected unwind rules checked. They would guard against tightening a record boundary at the expense of supported output. Please move the direct relinker debt edit to a fragment. I did not run the relinker suite for this head. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/12910:upstream-pr/12910'
git switch 'upstream-pr/12910'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/12910'
git switch 'upstream-pr/12910'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/12910'
git switch 'upstream-pr/12910'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/12910'
git switch 'main'
git merge --squash 'upstream-pr/12910'
git switch 'main'
git merge --ff-only 'upstream-pr/12910'
git switch 'main'
git merge 'upstream-pr/12910'
git push origin 'main'
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!12910
No description provided.