fix(relinker): preserve LSDA landing pads in filter roots and guard displacement overflow #15896

Merged
slopgobblercobbler merged 1 commit from upstream-pr/15896 into main 2026-11-22 13:38:11 +00:00
slopgobblercobbler commented 2026-11-04 22:44:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-11-04T22:44:56Z.


What

  • In core/relinker/relinker/src/analysis/CallSiteResolver.cpp, guard against negative displacement underflow and positive displacement overflow when computing RIP-relative call-site instruction target addresses.
  • In core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp, ensure function.ExtraTargets (personality routines and landing pads) extracted from unwindFunctions are preserved in exportedFunctions filter roots, without erroneously rooting dead function beginnings.
  • In core/relinker/relinker/tests/StrictNidFilterTests.cpp, add defaultFilterExtraLandingPadRoots() verifying that the default CFG-backed unused NID filter keeps GLOB_DAT imports accessed by LSDA landing pads when passed as extra roots.

Tested

  • Verified strict_nid_filter_tests via CTest.
  • Verified conventions via python tools/check_conventions.py --base upstream/main --head HEAD (0 errors).

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:5162834610 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15896). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-11-04T22:44:56Z. --- ### What - In `core/relinker/relinker/src/analysis/CallSiteResolver.cpp`, guard against negative displacement underflow and positive displacement overflow when computing RIP-relative call-site instruction target addresses. - In `core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp`, ensure `function.ExtraTargets` (personality routines and landing pads) extracted from `unwindFunctions` are preserved in `exportedFunctions` filter roots, without erroneously rooting dead function beginnings. - In `core/relinker/relinker/tests/StrictNidFilterTests.cpp`, add `defaultFilterExtraLandingPadRoots()` verifying that the default CFG-backed unused NID filter keeps GLOB_DAT imports accessed by LSDA landing pads when passed as extra roots. ### Tested - Verified `strict_nid_filter_tests` via CTest. - Verified conventions via `python tools/check_conventions.py --base upstream/main --head HEAD` (0 errors). ### 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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-18 10:24:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T10:24:47Z.

Review: COMMENTED


Reviewed — no blocking findings

The review covered head 73e27c8ee54c651f19bd034c2445faddedae7b67; I found no verified blocking defect, but could not run the reported checks.

What I ran

  • Inspected the prepared diff and reviewed the changed parser, resolver, pipeline, unwind reader, header, and CMake sections at the pinned head.
  • No build or tests were run; the author-reported results were not independently verified.

Results

Check Result Note
Diff and code review passed Relevant implementation inspected
Build and tests not run Reported results not independently verified

Findings

Blocking

None verified.

Non-blocking

None.

Sources

Not verified

  • Build, CTest, conventions check, and DWARF audit were not run; their reported results come from the PR description.
  • The full 1,399-line UnwindRecordBoundsTests.cpp was not inspected in one complete read; its changed test additions were reviewed from the diff. No changed files were excluded by manifest rule.

To get this to a good state

Nothing is required. Run the reported checks on this head if independent verification is needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5954741964 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15896#pullrequestreview-5954741964). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T10:24:47Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The review covered head `73e27c8ee54c651f19bd034c2445faddedae7b67`; I found no verified blocking defect, but could not run the reported checks. ## What I ran - Inspected the prepared diff and reviewed the changed parser, resolver, pipeline, unwind reader, header, and CMake sections at the pinned head. - No build or tests were run; the author-reported results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Diff and code review | passed | Relevant implementation inspected | | Build and tests | not run | Reported results not independently verified | ## Findings ### Blocking None verified. ### Non-blocking None. ## Sources - [ExceptionTableParser.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/73e27c8ee54c651f19bd034c2445faddedae7b67/core/relinker/relinker/src/analysis/ExceptionTableParser.cpp) - [RelinkerPipeline.cpp at reviewed head](https://github.com/boykopovar/AnyPS5/blob/73e27c8ee54c651f19bd034c2445faddedae7b67/core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp) ## Not verified - Build, CTest, conventions check, and DWARF audit were not run; their reported results come from the PR description. - The full 1,399-line `UnwindRecordBoundsTests.cpp` was not inspected in one complete read; its changed test additions were reviewed from the diff. No changed files were excluded by manifest rule. ## To get this to a good state Nothing is required. Run the reported checks on this head if independent verification is needed.
MarcZX10 commented 2026-11-21 03:37:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T03:37:08Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: avoid signed overflow when validating an action displacement of INT64_MIN.

What I ran

Reviewed head 8ca26db603fff8d94bb1d3c6fd8f441248a6e486. No commands or tests were run; repo_read.py was unavailable as a command, so I used the prepared diff and reader tools.

Results

Check Result Note
Diff review passed Prepared patch inspected
Tests not run No test execution
Full-file review not run See Not verified

Findings

Blocking

  • core/relinker/relinker/src/analysis/ExceptionTableParser.cpp:189: If an action record contains the valid SLEB128 value INT64_MIN, evaluating -displacement overflows signed int64_t, which is undefined behavior before the underflow check can reject the malformed chain. Handle the minimum value without signed negation (for example, calculate its magnitude in unsigned arithmetic).

Non-blocking

None.

Sources

Not verified

No tests, build, or conventions checks were run. The full text of the changed test file, CMake file, and pipeline file was not read; only their diffs or relevant pipeline ranges were inspected. No changed files were excluded by the prepared manifest; all seven changed files were listed as included, but not all were read in full.

To get this to a good state

Handle INT64_MIN safely in the action displacement underflow check, then rerun the unwind record bounds tests and review the changed files in full.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6002604897 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15896#pullrequestreview-6002604897). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T03:37:08Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: avoid signed overflow when validating an action displacement of `INT64_MIN`. ## What I ran Reviewed head `8ca26db603fff8d94bb1d3c6fd8f441248a6e486`. No commands or tests were run; `repo_read.py` was unavailable as a command, so I used the prepared diff and reader tools. ## Results | Check | Result | Note | |---|---|---| | Diff review | passed | Prepared patch inspected | | Tests | not run | No test execution | | Full-file review | not run | See Not verified | ## Findings ### Blocking - `core/relinker/relinker/src/analysis/ExceptionTableParser.cpp:189`: If an action record contains the valid SLEB128 value `INT64_MIN`, evaluating `-displacement` overflows signed `int64_t`, which is undefined behavior before the underflow check can reject the malformed chain. Handle the minimum value without signed negation (for example, calculate its magnitude in unsigned arithmetic). ### Non-blocking None. ## Sources - [ExceptionTableParser.cpp at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/8ca26db603fff8d94bb1d3c6fd8f441248a6e486/core/relinker/relinker/src/analysis/ExceptionTableParser.cpp#L189) ## Not verified No tests, build, or conventions checks were run. The full text of the changed test file, CMake file, and pipeline file was not read; only their diffs or relevant pipeline ranges were inspected. No changed files were excluded by the prepared manifest; all seven changed files were listed as included, but not all were read in full. ## To get this to a good state Handle `INT64_MIN` safely in the action displacement underflow check, then rerun the unwind record bounds tests and review the changed files in full.
MarcZX10 commented 2026-11-22 04:51:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T04:51:14Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected code and test additions support the stated fixes.

What I ran

Reviewed head 84b837c03d2c27fe9c2993ae05bf2b6ad136d5c0 using repo_read.py to inspect the prepared diff and relevant source context. No commands or tests were run.

Results

Check Result Note
Diff and source review passed All three changed files read
Automated tests not run Not executed in this review
Conventions check not run Not executed in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests or convention checks were run; the PR description reports that strict_nid_filter_tests via CTest and the conventions check passed. Inspected files: CallSiteResolver.cpp, RelinkerPipeline.cpp, and StrictNidFilterTests.cpp. The manifest lists all three as included, and all three full texts were read. No excluded files were listed in the manifest; files.json was not available through the reader.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010443543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15896#pullrequestreview-6010443543). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T04:51:14Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected code and test additions support the stated fixes. ## What I ran Reviewed head `84b837c03d2c27fe9c2993ae05bf2b6ad136d5c0` using `repo_read.py` to inspect the prepared diff and relevant source context. No commands or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and source review | passed | All three changed files read | | Automated tests | not run | Not executed in this review | | Conventions check | not run | Not executed in this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests or convention checks were run; the PR description reports that `strict_nid_filter_tests` via CTest and the conventions check passed. Inspected files: `CallSiteResolver.cpp`, `RelinkerPipeline.cpp`, and `StrictNidFilterTests.cpp`. The manifest lists all three as included, and all three full texts were read. No excluded files were listed in the manifest; `files.json` was not available through the reader. ## To get this to a good state Nothing is required.
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!15896
No description provided.