feat(libc): declare fundamental typeinfo records and their vtable #10548

Merged
akkadbakkad89 merged 5 commits from upstream-pr/10548 into main 2026-11-02 10:23:07 +00:00
akkadbakkad89 commented 2026-10-24 09:32:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-24T09:32:19Z.


What

Declares the Itanium __fundamental_type_info family that titles import from libc: the __cxxabiv1::__fundamental_type_info vtable export and the typeinfo records for the primitive types (v w b c a h s t i j l m x y n o f d e plus Dn, Ds, Di, Du).

Each record is the standard two-slot {vtable, name} layout pointing at the exported vtable, matching how the class/pointer/function typeinfo records in the same file are built. Catch matching needs no runtime change: Bases/VisitBases only recurse for __si_class_type_info/__vmi_class_type_info kinds, so a fundamental record matches itself by name and a thrown int is caught by catch (int)/catch (...).

PPSA30528 (RDR) imports _ZTIi and _ZTIf; the audit flagged them as absent imports that stop the module from resolving. The other records complete the canonical set so any primitive typeid/catch reference resolves the same way.

Tested

Windows 11, MinGW build: libc.prx links; the new records and the __fundamental_type_info vtable are present in the export table (_ZTIi_nid_postfix, _ZTIf_nid_postfix, _ZTVN10__cxxabiv123__fundamental_type_infoE_nid_postfix, …). windows_exception_tests and guest_locale_tests pass. Guest catch matching for the records relies on the existing Bases/Equal machinery, which treats non-class kinds as self-matching.

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: PPSA30528 #9914 (resolves the two absent libc imports _ZTIi/_ZTIf; the title has further blockers unrelated to this change); PPSA99925 (Beetle PCE, undefined symbol: _ZTIi on main -> loads and draws its library screen, confirmed by @milescoviello)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4994262811 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10548). Originally posted by [akkadbakkad89](https://github.com/akkadbakkad89) on 2026-10-24T09:32:19Z. --- ### What Declares the Itanium `__fundamental_type_info` family that titles import from libc: the `__cxxabiv1::__fundamental_type_info` vtable export and the `typeinfo` records for the primitive types (`v w b c a h s t i j l m x y n o f d e` plus `Dn`, `Ds`, `Di`, `Du`). Each record is the standard two-slot `{vtable, name}` layout pointing at the exported vtable, matching how the class/pointer/function typeinfo records in the same file are built. Catch matching needs no runtime change: `Bases`/`VisitBases` only recurse for `__si_class_type_info`/`__vmi_class_type_info` kinds, so a fundamental record matches itself by name and a thrown `int` is caught by `catch (int)`/`catch (...)`. PPSA30528 (RDR) imports `_ZTIi` and `_ZTIf`; the audit flagged them as absent imports that stop the module from resolving. The other records complete the canonical set so any primitive `typeid`/catch reference resolves the same way. ### Tested <!-- 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. --> Windows 11, MinGW build: `libc.prx` links; the new records and the `__fundamental_type_info` vtable are present in the export table (`_ZTIi_nid_postfix`, `_ZTIf_nid_postfix`, `_ZTVN10__cxxabiv123__fundamental_type_infoE_nid_postfix`, …). `windows_exception_tests` and `guest_locale_tests` pass. Guest catch matching for the records relies on the existing `Bases`/`Equal` machinery, which treats non-class kinds as self-matching. ### 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 - [x] Fixes: none - [x] Unblocks: PPSA30528 #9914 (resolves the two absent libc imports `_ZTIi`/`_ZTIf`; the title has further blockers unrelated to this change); PPSA99925 (Beetle PCE, `undefined symbol: _ZTIi` on main -> loads and draws its library screen, confirmed by @milescoviello) - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-24 10:39:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T10:39:07Z.

Review: APPROVED


Reviewed the current RTTI record and vtable layout against the neighboring Itanium typeinfo records and runtime matching path. The two-slot records point at the new vtable address point and use the expected builtin type encodings; the reported _ZTIi/_ZTIf imports are included. Hosted eligibility, conventions, intake, labels, report, relinker/ASAN, register-context, and write-watch checks pass; Linux/Windows full builds were skipped by the eligibility gate. The contributor reports the libc link and Windows exception/locale tests passing; I did not rerun those locally. I left a non-blocking completeness note about _ZTIg (__float128) and the direct guest-record test coverage.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5637951765 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10548#pullrequestreview-5637951765). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T10:39:07Z. **Review:** APPROVED --- Reviewed the current RTTI record and vtable layout against the neighboring Itanium typeinfo records and runtime matching path. The two-slot records point at the new vtable address point and use the expected builtin type encodings; the reported `_ZTIi`/`_ZTIf` imports are included. Hosted eligibility, conventions, intake, labels, report, relinker/ASAN, register-context, and write-watch checks pass; Linux/Windows full builds were skipped by the eligibility gate. The contributor reports the libc link and Windows exception/locale tests passing; I did not rerun those locally. I left a non-blocking completeness note about `_ZTIg` (`__float128`) and the direct guest-record test coverage.
MarcZX10 commented 2026-10-24 12:23:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:23:21Z.

Review: APPROVED


The current head adds the missing __float128 and remaining canonical builtin records (g, z, and Dh) alongside the previously reviewed type records. Each uses the same two-slot RTTI record layout and the new fundamental-type vtable address point; the existing matching path compares these non-class records by name. Hosted eligibility, conventions, labels, report, the full relinker matrix, ASAN, register-context, and write-watch checks pass. Linux/Windows product build jobs were skipped; the Windows exception and locale tests are author-reported and not independently reproduced here. Direct guest tests for every record would improve coverage, but the export and layout changes are consistent with the surrounding RTTI implementation.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638223513 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10548#pullrequestreview-5638223513). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:23:21Z. **Review:** APPROVED --- The current head adds the missing __float128 and remaining canonical builtin records (`g`, `z`, and `Dh`) alongside the previously reviewed type records. Each uses the same two-slot RTTI record layout and the new fundamental-type vtable address point; the existing matching path compares these non-class records by name. Hosted eligibility, conventions, labels, report, the full relinker matrix, ASAN, register-context, and write-watch checks pass. Linux/Windows product build jobs were skipped; the Windows exception and locale tests are author-reported and not independently reproduced here. Direct guest tests for every record would improve coverage, but the export and layout changes are consistent with the surrounding RTTI implementation.
ahmadmuj commented 2026-11-01 17:28:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-01T17:28:01Z.

Review: COMMENTED


Linux leg of the check @oneandonlydean asked for, on head a361119ae15ac0ae8ba2ac619898ae764a7a872e (merge-base cc8226475b20; current main f2d874c1fdcc hasn't touched TypeInfo.cpp, the exception headers or this test since, so the head build matches the merged tree for these files).

What I ran (WSL2 Ubuntu 24.04, GCC 13.3, Release, Ninja):

  • ctest -R guest_bad_optional_access: passes.
  • ctest -R '^public_headers': public_headers plus public_headers_compile_0..63, 65/65 pass.
  • Red control: main f2d874c1fdcc with only this PR's GuestBadOptionalAccess.cpp fails to link on _ZTIi, _ZTIj, _ZTIf, _ZTIDn and _ZTVN10__cxxabiv123__fundamental_type_infoE.
  • Mutation: pointing _ZTIi_nid_postfix at the __class_type_info vtable address point makes the test abort, so it does catch a record on the wrong vtable.
  • nm -D on libc.prx: all 26 records and the vtable are exported; after nid_patcher, e.g. _ZTIi is St4apgcBNfo and the vtable is G4XM-SS1wxE.
  • Read Kind/Equal/Match in Runtime.cpp: fundamental records resolve to the fundamental kind and match by name only, and the slot [4] the test calls is catchType in TypeInfoVtable.

Two small things, neither blocking:

  1. _ZTIz probably shouldn't be exported. ... isn't a type, so neither clang nor GCC ever emits a _ZTIz reference (catch (...) uses a null type entry). Its NID Je-wkqG37fc is also the only one of the 27 missing from the aerolib.csv that tools/nid_names.py pins; the other 25 records and the vtable are all there. I'd drop it unless you've seen it in a module. Side note on the PR text: Dh is the half-precision __fp16; _Float16 mangles as DF16_. The "Dh" string is right either way.
  2. The 26 records are dynamically initialized. FundamentalVtable() isn't a constant expression, so GCC leaves the vptr zero in .data and _GLOBAL__sub_I_Exports.cpp stores all 26 at load (the exported records in StandardExceptions.cpp are static). It works, since the test passes through copy relocations. Still, {&_ZTVN10__cxxabiv123__fundamental_type_infoE_nid_postfix.destroy, "i"} with a const void* vtable field would make them constant data, like ClassTypeVtable + 2 in StandardExceptions.cpp.

Not checked: Windows (you already ran it), real guest titles, and any console module listing which of these PS5 libc actually exports.

AI-assisted: yes (Claude Code); everything above was run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729346861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10548#pullrequestreview-5729346861). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-11-01T17:28:01Z. **Review:** COMMENTED --- Linux leg of the check @oneandonlydean asked for, on head `a361119ae15ac0ae8ba2ac619898ae764a7a872e` (merge-base `cc8226475b20`; current main `f2d874c1fdcc` hasn't touched TypeInfo.cpp, the exception headers or this test since, so the head build matches the merged tree for these files). What I ran (WSL2 Ubuntu 24.04, GCC 13.3, Release, Ninja): - `ctest -R guest_bad_optional_access`: passes. - `ctest -R '^public_headers'`: `public_headers` plus `public_headers_compile_0..63`, 65/65 pass. - Red control: main `f2d874c1fdcc` with only this PR's `GuestBadOptionalAccess.cpp` fails to link on `_ZTIi`, `_ZTIj`, `_ZTIf`, `_ZTIDn` and `_ZTVN10__cxxabiv123__fundamental_type_infoE`. - Mutation: pointing `_ZTIi_nid_postfix` at the `__class_type_info` vtable address point makes the test abort, so it does catch a record on the wrong vtable. - `nm -D` on `libc.prx`: all 26 records and the vtable are exported; after `nid_patcher`, e.g. `_ZTIi` is `St4apgcBNfo` and the vtable is `G4XM-SS1wxE`. - Read `Kind`/`Equal`/`Match` in Runtime.cpp: fundamental records resolve to the fundamental kind and match by name only, and the slot `[4]` the test calls is `catchType` in `TypeInfoVtable`. Two small things, neither blocking: 1. `_ZTIz` probably shouldn't be exported. `...` isn't a type, so neither clang nor GCC ever emits a `_ZTIz` reference (`catch (...)` uses a null type entry). Its NID `Je-wkqG37fc` is also the only one of the 27 missing from the aerolib.csv that `tools/nid_names.py` pins; the other 25 records and the vtable are all there. I'd drop it unless you've seen it in a module. Side note on the PR text: `Dh` is the half-precision `__fp16`; `_Float16` mangles as `DF16_`. The `"Dh"` string is right either way. 2. The 26 records are dynamically initialized. `FundamentalVtable()` isn't a constant expression, so GCC leaves the vptr zero in `.data` and `_GLOBAL__sub_I_Exports.cpp` stores all 26 at load (the exported records in StandardExceptions.cpp are static). It works, since the test passes through copy relocations. Still, `{&_ZTVN10__cxxabiv123__fundamental_type_infoE_nid_postfix.destroy, "i"}` with a `const void*` vtable field would make them constant data, like `ClassTypeVtable + 2` in StandardExceptions.cpp. Not checked: Windows (you already ran it), real guest titles, and any console module listing which of these PS5 libc actually exports. AI-assisted: yes (Claude Code); everything above was run on this machine.
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!10548
No description provided.