feat(libc): export the ctype facet vtable as data #9735

Merged
mazen320 merged 2 commits from upstream-pr/9735 into main 2026-10-28 04:36:29 +00:00
mazen320 commented 2026-10-22 10:53:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-22T10:53:40Z.


What

Export ctype<char>'s vtable (NID GKWcAz6-G7k) as fourteen zeroed uintptr_t slots so titles that resolve it as data get a 112-byte object matching console title libc.prx (PPSA16833). Facet calls through the slots still fault until methods are wired (debt note). Orthogonal to #9466 (_Getctype helpers).

Open #8880 and #9038 also edit GuestLocale.cpp near the same insert points; they do not export _ZTVSt5ctypeIcE. Prefer landing this first so those PRs rebase over the new test/debt lines (they compose by retaining both). Not a stack: Depends on stays none. Wide follow-up is #9761 (`Depends on: none

Tested

  • ctest --test-dir build-win -R guest_locale — passed (Windows MinGW) after rebase onto upstream/main b7d1d47a5.
  • python tools/check_conventions.py --base upstream/main — passed.
  • Console: GKWcAz6-G7k is STT_OBJECT st_size 112 in PPSA16833 sce_module/libc.prx (dynsym).

Checklist

  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4966188254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9735). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-22T10:53:40Z. --- ### What Export `ctype<char>`'s vtable (NID `GKWcAz6-G7k`) as fourteen zeroed `uintptr_t` slots so titles that resolve it as data get a 112-byte object matching console title `libc.prx` (PPSA16833). Facet calls through the slots still fault until methods are wired (debt note). Orthogonal to #9466 (`_Getctype` helpers). Open #8880 and #9038 also edit `GuestLocale.cpp` near the same insert points; they do not export `_ZTVSt5ctypeIcE`. Prefer landing this first so those PRs rebase over the new test/debt lines (they compose by retaining both). Not a stack: **Depends on** stays none. Wide follow-up is #9761 (`Depends on: none ### Tested - `ctest --test-dir build-win -R guest_locale` — passed (Windows MinGW) after rebase onto `upstream/main` `b7d1d47a5`. - `python tools/check_conventions.py --base upstream/main` — passed. - Console: `GKWcAz6-G7k` is STT_OBJECT `st_size` 112 in PPSA16833 `sce_module/libc.prx` (dynsym). ### Checklist - Depends on: none - Fixes: none - Unblocks: none - GPUs tested: n/a - AI-assisted: yes
harisibrar1 commented 2026-10-22 13:06:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T13:06:31Z.

Review: APPROVED


Checked against main 3ca07d086d and ps5-payload-dev/sdk sce_stubs/libSceLibcInternal.c:

  • _ZTVSt5ctypeIcE is .type ..., @object in the SDK table (L11778-11780), and the NID calculator gives GKWcAz6-G7k, so exporting it as data is correct. It is not exported on main yet.
  • 14 slots (112 bytes) match the layout: offset-to-top, typeinfo, D1/D0, _Incref/_Decref (the same order as GuestLocale::FacetVtable), and the eight ctype<char> virtuals (do_tolower, do_toupper, do_widen, do_narrow, each in a single-character and a range form). It follows the zeroed codecvt/num_put arrays at LocaleSupport.cpp:298/300 and records the placeholder in the debt file.
  • Non-blocking, as on #9456: a virtual call through these slots jumps to address 0. Pointing slots 2..13 at a host function that calls NotImplemented_nid_no_patch would make a facet use fail with a named error.
  • Small checklist nit: "Unblocks" could be none (as you changed it on #9456 and #9698) unless there is a Game Bring-up stop to link.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5614663800 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9735#pullrequestreview-5614663800). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-22T13:06:31Z. **Review:** APPROVED --- Checked against main 3ca07d086d and ps5-payload-dev/sdk sce_stubs/libSceLibcInternal.c: - `_ZTVSt5ctypeIcE` is `.type ..., @object` in the SDK table (L11778-11780), and the NID calculator gives `GKWcAz6-G7k`, so exporting it as data is correct. It is not exported on main yet. - 14 slots (112 bytes) match the layout: offset-to-top, typeinfo, D1/D0, `_Incref`/`_Decref` (the same order as `GuestLocale::FacetVtable`), and the eight `ctype<char>` virtuals (`do_tolower`, `do_toupper`, `do_widen`, `do_narrow`, each in a single-character and a range form). It follows the zeroed codecvt/num_put arrays at LocaleSupport.cpp:298/300 and records the placeholder in the debt file. - Non-blocking, as on #9456: a virtual call through these slots jumps to address 0. Pointing slots 2..13 at a host function that calls `NotImplemented_nid_no_patch` would make a facet use fail with a named error. - Small checklist nit: "Unblocks" could be `none` (as you changed it on #9456 and #9698) unless there is a Game Bring-up stop to link. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
mazen320 commented 2026-10-22 14:57:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-22T14:57:35Z.


Rebased onto current main (b7d1d47a5); guest_locale and conventions still pass. Landing order with #9761: this char ctype PR first, then the wide one (Depends on: #9735 there).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6343861306 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9735#issuecomment-6343861306). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-22T14:57:35Z. --- Rebased onto current `main` (`b7d1d47a5`); `guest_locale` and conventions still pass. Landing order with #9761: this char ctype PR first, then the wide one (`Depends on: #9735` there).
MarcZX10 commented 2026-10-22 15:09:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T15:09:41Z.

Review: DISMISSED


The implementation is supported by the cited console object size and the test checks that the export is present, zero-initialized, and writable. I found no code defect.

I reviewed the rebased head 2c5483eb02be1365fafed2145f3b55b4bb30b5e7 based on current main (b7d1d47a5). Locally, g++ -std=c++20 -fsyntax-only -Icore/libs core/libs/prx/libc/src/LocaleSupport.cpp and the same command for core/libs/tests/GuestLocale.cpp passed; git diff --check and python3 tools/check_conventions.py --base upstream/main --head refs/review/pr9735 also passed. I could not run the linked guest_locale runtime test because this checkout has no configured build. The reported Windows guest_locale run after rebase is author-reported.

The current overlap report still lists open #8880 and #9038 for shared insertion points in GuestLocale.cpp, but this PR’s checklist says Depends on: none. CONTRIBUTING requires agreeing the order with authors of open overlapping PRs and recording the dependency. Please confirm the intended order with those authors and update the checklist (or explain why the refreshed overlap is no longer applicable). The nearby #9761 order is already documented in your comment.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5616410274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9735#pullrequestreview-5616410274). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T15:09:41Z. **Review:** DISMISSED --- The implementation is supported by the cited console object size and the test checks that the export is present, zero-initialized, and writable. I found no code defect. I reviewed the rebased head `2c5483eb02be1365fafed2145f3b55b4bb30b5e7` based on current `main` (`b7d1d47a5`). Locally, `g++ -std=c++20 -fsyntax-only -Icore/libs core/libs/prx/libc/src/LocaleSupport.cpp` and the same command for `core/libs/tests/GuestLocale.cpp` passed; `git diff --check` and `python3 tools/check_conventions.py --base upstream/main --head refs/review/pr9735` also passed. I could not run the linked `guest_locale` runtime test because this checkout has no configured build. The reported Windows `guest_locale` run after rebase is author-reported. The current overlap report still lists open #8880 and #9038 for shared insertion points in `GuestLocale.cpp`, but this PR’s checklist says `Depends on: none`. CONTRIBUTING requires agreeing the order with authors of open overlapping PRs and recording the dependency. Please confirm the intended order with those authors and update the checklist (or explain why the refreshed overlap is no longer applicable). The nearby #9761 order is already documented in your comment.
mazen320 commented 2026-10-22 15:15:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-22T15:15:39Z.


Updated the body for the overlap report: #8880 / #9038 share GuestLocale.cpp insert points only (no _ZTVSt5ctypeIcE). Prefer this landing first so they rebase over the new check/debt lines; not stacking, so Depends on stays none. #9761 already records Depends on: #9735 for the wide ctype follow-up. Head remains on main b7d1d47a5 with guest_locale + conventions green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6344256274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9735#issuecomment-6344256274). Originally posted by [mazen320](https://github.com/mazen320) on 2026-10-22T15:15:39Z. --- Updated the body for the overlap report: #8880 / #9038 share `GuestLocale.cpp` insert points only (no `_ZTVSt5ctypeIcE`). Prefer this landing first so they rebase over the new check/debt lines; not stacking, so **Depends on** stays none. #9761 already records `Depends on: #9735` for the wide ctype follow-up. Head remains on `main` `b7d1d47a5` with `guest_locale` + conventions green.
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!9735
No description provided.