fix(relinker): read LSDA call-site tables only under a personality routine #1944

Merged
babyhuey merged 1 commit from upstream-pr/1944 into main 2026-10-10 04:43:07 +00:00
babyhuey commented 2026-10-09 01:33:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T01:33:29Z.


What

EhFrameReader reads an FDE's LSDA as an Itanium C++ call-site table only when its CIE names a personality routine (P in the augmentation). An LSDA under a CIE without one is skipped.

The C++ LSDA format is defined by the personality routine that reads it. With no personality the unwinder never consults the LSDA, so its contents need not be a C++ table. .NET NativeAOT writes exactly this: every CIE is zLR, and each LSDA points at the runtime's own EH info, which its runtime reads instead of a C++ personality routine. Its catch and finally funclets are separate functions with their own FDEs, so no code is lost by not reading these LSDAs.

Three catalog titles are C# NativeAOT builds (System.Private.CoreLib in the executable) and fail to relink with --windows on main:

  • PPSA99109 Prospero Explorer: FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x1f5950)
  • PPSA99110 Prospero Multi Tools: the same, at 0x1ffd0b
  • PPSA99920 Prospero Vibrate: the same, at 0x153c03

In these three, every CIE is zLR, and 4474, 4699 and 2731 of their LSDAs respectively do not parse as call-site tables. The 38 other catalog titles I could relink use only zPLR CIEs, and all of their roughly 65,000 LSDAs parse as call-site tables, so this change does not affect them.

exceptionLandingPads used a zLR CIE to exercise call-site parsing. It now uses zPLR, with the personality as an extra target. The new exceptionDataWithoutPersonality checks that an LSDA that is not a call-site table, under a zLR CIE, is accepted and adds no targets.

Tested

Linux (Ubuntu 24.04, GCC 13, Release, ANYPS5_RELINKER_ONLY=ON): all 38 relinker tests pass. strict_nid_filter fails when the personality check is removed. The three titles above now relink with --windows (exit 0); Linux output was already unaffected. check_conventions.py passes. Windows: not run with this branch; the failure and its absence are both in the relinker, which I ran on Linux with --windows.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4794833639 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1944). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T01:33:29Z. --- ### What `EhFrameReader` reads an FDE's LSDA as an Itanium C++ call-site table only when its CIE names a personality routine (`P` in the augmentation). An LSDA under a CIE without one is skipped. The C++ LSDA format is defined by the personality routine that reads it. With no personality the unwinder never consults the LSDA, so its contents need not be a C++ table. .NET NativeAOT writes exactly this: every CIE is `zLR`, and each LSDA points at the runtime's own EH info, which its runtime reads instead of a C++ personality routine. Its catch and finally funclets are separate functions with their own FDEs, so no code is lost by not reading these LSDAs. Three catalog titles are C# NativeAOT builds (`System.Private.CoreLib` in the executable) and fail to relink with `--windows` on `main`: - PPSA99109 Prospero Explorer: `FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x1f5950)` - PPSA99110 Prospero Multi Tools: the same, at `0x1ffd0b` - PPSA99920 Prospero Vibrate: the same, at `0x153c03` In these three, every CIE is `zLR`, and 4474, 4699 and 2731 of their LSDAs respectively do not parse as call-site tables. The 38 other catalog titles I could relink use only `zPLR` CIEs, and all of their roughly 65,000 LSDAs parse as call-site tables, so this change does not affect them. `exceptionLandingPads` used a `zLR` CIE to exercise call-site parsing. It now uses `zPLR`, with the personality as an extra target. The new `exceptionDataWithoutPersonality` checks that an LSDA that is not a call-site table, under a `zLR` CIE, is accepted and adds no targets. ### Tested Linux (Ubuntu 24.04, GCC 13, Release, `ANYPS5_RELINKER_ONLY=ON`): all 38 relinker tests pass. `strict_nid_filter` fails when the personality check is removed. The three titles above now relink with `--windows` (exit 0); Linux output was already unaffected. `check_conventions.py` passes. Windows: not run with this branch; the failure and its absence are both in the relinker, which I ran on Linux with `--windows`. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
babyhuey commented 2026-10-09 01:34:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T01:34:46Z.


Windows run of the three titles. Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release, main f1451396 with this branch (and my other open PRs) merged; relinked with --windows and run.

Title main with this branch
PPSA99109 Prospero Explorer FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x1f5950) relinks; stops loading libSceZlib.prx, which no module provides
PPSA99110 Prospero Multi Tools FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x1ffd0b) relinks; FAIL: unresolved ELF import JZKw5+Wrnaw from libkernel.prx (pthread_sigmask)
PPSA99920 Prospero Vibrate FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x153c03) relinks; FAIL: unresolved ELF import JZKw5+Wrnaw from libkernel.prx (pthread_sigmask)
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6072451294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1944#issuecomment-6072451294). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T01:34:46Z. --- Windows run of the three titles. Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release, `main` f1451396 with this branch (and my other open PRs) merged; relinked with `--windows` and run. | Title | `main` | with this branch | |---|---|---| | PPSA99109 Prospero Explorer | `FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x1f5950)` | relinks; stops loading `libSceZlib.prx`, which no module provides | | PPSA99110 Prospero Multi Tools | `FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x1ffd0b)` | relinks; `FAIL: unresolved ELF import JZKw5+Wrnaw from libkernel.prx` (`pthread_sigmask`) | | PPSA99920 Prospero Vibrate | `FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x153c03)` | relinks; `FAIL: unresolved ELF import JZKw5+Wrnaw from libkernel.prx` (`pthread_sigmask`) |
MarcZX10 commented 2026-10-09 02:03:31 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed the full diff against current main. The change is narrowly scoped to avoid parsing an LSDA as a C++ call-site table when its CIE has no personality routine; the fixture now explicitly covers both the personality and no-personality cases. I built the relinker-only configuration on Linux and ran all 38 CTests successfully, including strict_nid_filter. Conventions and diff checks pass, and the author has supplied Windows evidence for the three reported NativeAOT cases. The upstream workflow is not yet reported for this head, so normal CI evidence remains outstanding.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5464903065 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1944#pullrequestreview-5464903065). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T02:03:31Z. **Review:** APPROVED --- Reviewed the full diff against current main. The change is narrowly scoped to avoid parsing an LSDA as a C++ call-site table when its CIE has no personality routine; the fixture now explicitly covers both the personality and no-personality cases. I built the relinker-only configuration on Linux and ran all 38 CTests successfully, including strict_nid_filter. Conventions and diff checks pass, and the author has supplied Windows evidence for the three reported NativeAOT cases. The upstream workflow is not yet reported for this head, so normal CI evidence remains outstanding.
babyhuey commented 2026-10-09 03:31:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T03:31:15Z.


Fork CI for this head (547b4588) while the upstream run waits for approval: Build run, all jobs green (Linux, Windows, relinker on Linux, macOS and Windows).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073702607 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1944#issuecomment-6073702607). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T03:31:15Z. --- Fork CI for this head (547b4588) while the upstream run waits for approval: [Build run](https://github.com/babyhuey/AnyPS5/actions/runs/37870364067), all jobs green (Linux, Windows, relinker on Linux, macOS and Windows).
danielradosa commented 2026-10-09 18:34:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by danielradosa on 2026-10-09T18:34:29Z.


Windows run with a title for this PR. Prospero Vibrate PPSA99920 1.0 (catalog release, sha256 as in the record, eboot.bin and sce_module/libc.prx unwrapped from their SELF containers), Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

  • main 0fdda7be (and 4b005b22): relinker --windows fails with FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x153c03). Linux output relinks.
  • main 0fdda7be + this PR (+ #1650, #1748, #1911, which do not touch the LSDA reader): --windows relinks, and the converted executable loads its libraries and stops at its first absent import, FAIL: unresolved ELF import Jahsnh4KKkg from libkernel.prx (madvise, #1633).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086963563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1944#issuecomment-6086963563). Originally posted by [danielradosa](https://github.com/danielradosa) on 2026-10-09T18:34:29Z. --- Windows run with a title for this PR. Prospero Vibrate PPSA99920 1.0 (catalog release, sha256 as in the record, `eboot.bin` and `sce_module/libc.prx` unwrapped from their SELF containers), Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. - `main` 0fdda7be (and 4b005b22): `relinker --windows` fails with `FAIL: Strict filter: LSDA call-site table size mismatch (offset 0x153c03)`. Linux output relinks. - `main` 0fdda7be + this PR (+ #1650, #1748, #1911, which do not touch the LSDA reader): `--windows` relinks, and the converted executable loads its libraries and stops at its first absent import, `FAIL: unresolved ELF import Jahsnh4KKkg from libkernel.prx` (`madvise`, #1633). AI-assisted: yes (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!1944
No description provided.