feat(libc): export std::__sce_v2::_Locinfo #11450

Merged
edubox merged 3 commits from upstream-pr/11450 into main 2026-10-29 22:37:12 +00:00
edubox commented 2026-10-26 14:06:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by edubox on 2026-10-26T14:06:51Z.


What

Exports the versioned C-locale std::__sce_v2::_Locinfo constructor and destructor.

The console libc.prx in PPSA02530 (0xcfe10/0xcfe50) and PPSA28416 (0xd10c0/0xd1100) stores the current C-locale pointer at offsets 8 and 0x10; the constructor writes offset 8 before validating the name. It accepts an empty or "C" name and throws std::__sce_v2::runtime_error("bad locale name") for a null or any other name, leaving offset 0x10 untouched on rejection. The destructor passes the stored offset-8 pointer to setlocale. Offset 0 is caller-owned and preserved.

The console exports the pair with NIDs K+YIrBadUlc (constructor) and taOj6NIm7DM (destructor); firmware 13.42's libSceLibcInternal.sprx exports both with sizes 0x3a and 0x19, the same as PPSA02530's libc.prx.

Tested

Linux x86-64, GCC 16.2.1, Release, BUILD_TESTING=ON.

  • guest_sce_v2_exceptions passes: both fields point to "C" for empty and "C" names; a null or non-C name writes offset 8 with "C", leaves offset 0x10 untouched and throws the versioned runtime_error with bad locale name; offset 0 keeps the caller value.
  • python3 tools/check_conventions.py --base origin/main and git diff --check pass.
  • Not tested with a title: PPSA28416 stops at sceNpGetSandboxInfo before these imports are reached.

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 (PPSA28416 has no Game bring-up discussion; this is groundwork for the versioned locale)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5018799156 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11450). Originally posted by [edubox](https://github.com/edubox) on 2026-10-26T14:06:51Z. --- ### What Exports the versioned C-locale `std::__sce_v2::_Locinfo` constructor and destructor. The console `libc.prx` in PPSA02530 (`0xcfe10`/`0xcfe50`) and PPSA28416 (`0xd10c0`/`0xd1100`) stores the current C-locale pointer at offsets 8 and `0x10`; the constructor writes offset 8 before validating the name. It accepts an empty or `"C"` name and throws `std::__sce_v2::runtime_error("bad locale name")` for a null or any other name, leaving offset `0x10` untouched on rejection. The destructor passes the stored offset-8 pointer to `setlocale`. Offset 0 is caller-owned and preserved. The console exports the pair with NIDs `K+YIrBadUlc` (constructor) and `taOj6NIm7DM` (destructor); firmware 13.42's `libSceLibcInternal.sprx` exports both with sizes `0x3a` and `0x19`, the same as PPSA02530's `libc.prx`. ### Tested Linux x86-64, GCC 16.2.1, Release, `BUILD_TESTING=ON`. - `guest_sce_v2_exceptions` passes: both fields point to `"C"` for empty and `"C"` names; a null or non-C name writes offset 8 with `"C"`, leaves offset `0x10` untouched and throws the versioned `runtime_error` with `bad locale name`; offset 0 keeps the caller value. - `python3 tools/check_conventions.py --base origin/main` and `git diff --check` pass. - Not tested with a title: PPSA28416 stops at `sceNpGetSandboxInfo` before these imports are reached. ### 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 (PPSA28416 has no Game bring-up discussion; this is groundwork for the versioned locale) - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-26 14:13:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T14:13:56Z.

Review: CHANGES_REQUESTED


The implementation and Linux test report are clear, and the current hosted Linux/Windows relinker and Ubuntu register-context checks pass. The branch and tested base are 99b8446cbc, while current main is 51f5c57dd9; CONTRIBUTING requires keeping PRs based on current main. Please sync the branch and rerun the focused locale/exception test and conventions on the rebased head. The macOS relinker/register-context/write-watch jobs are still queued, so I will revisit after they complete.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5653354799 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11450#pullrequestreview-5653354799). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T14:13:56Z. **Review:** CHANGES_REQUESTED --- The implementation and Linux test report are clear, and the current hosted Linux/Windows relinker and Ubuntu register-context checks pass. The branch and tested base are `99b8446cbc`, while current `main` is `51f5c57dd9`; CONTRIBUTING requires keeping PRs based on current `main`. Please sync the branch and rerun the focused locale/exception test and conventions on the rebased head. The macOS relinker/register-context/write-watch jobs are still queued, so I will revisit after they complete.
MarcZX10 commented 2026-10-26 16:21:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T16:21:18Z.

Review: DISMISSED


Re-reviewed exact head 571af22666a8, now based on live main 518d36eaec0a. The author reports rebuilding guest_sce_v2_exceptions and guest_locale on this head with both passing; current-main conventions and whitespace checks also pass. The requested independent ABI evidence remains unanswered: GuestLocale::SceV2Locinfo and its 24-byte size/offset assertions are newly defined here, while the test constructs that same definition, so those assertions do not independently verify the guest layout. The PR describes offsets 8 and 0x10 observed in two console libc.prx images, but does not provide a reproducible call-site, object-byte observation, or other supporting artifact, and the reason offset 0 is intentionally preserved is still unclear. Please add that evidence and clarify the constructor's treatment of offset 0. I am not asserting the layout is incorrect; without that evidence I cannot complete ABI review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5655337562 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11450#pullrequestreview-5655337562). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T16:21:18Z. **Review:** DISMISSED --- Re-reviewed exact head `571af22666a8`, now based on live `main` `518d36eaec0a`. The author reports rebuilding `guest_sce_v2_exceptions` and `guest_locale` on this head with both passing; current-main conventions and whitespace checks also pass. The requested independent ABI evidence remains unanswered: `GuestLocale::SceV2Locinfo` and its 24-byte size/offset assertions are newly defined here, while the test constructs that same definition, so those assertions do not independently verify the guest layout. The PR describes offsets 8 and 0x10 observed in two console libc.prx images, but does not provide a reproducible call-site, object-byte observation, or other supporting artifact, and the reason offset 0 is intentionally preserved is still unclear. Please add that evidence and clarify the constructor's treatment of offset 0. I am not asserting the layout is incorrect; without that evidence I cannot complete ABI review.
BunnyFl commented 2026-10-29 04:10:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-10-29T04:10:58Z.

Review: APPROVED


Approving this head (an automatic rebase of adc7b5a70e; the PR's changes to its four files are identical). I read the whole diff against my firmware 13.42 run above (the decrypted system libSceLibcInternal.sprx's two exports, natively on a PC, not a console):

  • The constructor now stores setlocale(0x3f, NULL) at +8 before it checks the name, rejects a null name and every name other than "" and "C" through _Xruntime_error("bad locale name") with +0x10 left alone, and otherwise stores the same pointer at +0x10. That is what the module did for every name I ran (NULL, "", "C", "POSIX", "c", "C.UTF-8", "CX").
  • The destructor calls setlocale(0x3f, <+8>) when +8 is not null, as the module's disassembly does.
  • The new test checks those cases (plus "en_US.UTF-8"), including the +8 write and the untouched +0x10 on rejection, and that offset 0 is kept, as the module kept it in the cases that return.

Not covered by my run: what setlocale itself returns outside the C locale, and the null-object throws, which the module doesn't have (per its disassembly it would fault).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692759618 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11450#pullrequestreview-5692759618). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-10-29T04:10:58Z. **Review:** APPROVED --- Approving this head (an automatic rebase of `adc7b5a70e`; the PR's changes to its four files are identical). I read the whole diff against my firmware 13.42 run above (the decrypted system `libSceLibcInternal.sprx`'s two exports, natively on a PC, not a console): - The constructor now stores `setlocale(0x3f, NULL)` at +8 before it checks the name, rejects a null name and every name other than `""` and `"C"` through `_Xruntime_error("bad locale name")` with +0x10 left alone, and otherwise stores the same pointer at +0x10. That is what the module did for every name I ran (NULL, `""`, `"C"`, `"POSIX"`, `"c"`, `"C.UTF-8"`, `"CX"`). - The destructor calls `setlocale(0x3f, <+8>)` when +8 is not null, as the module's disassembly does. - The new test checks those cases (plus `"en_US.UTF-8"`), including the +8 write and the untouched +0x10 on rejection, and that offset 0 is kept, as the module kept it in the cases that return. Not covered by my run: what `setlocale` itself returns outside the C locale, and the null-object throws, which the module doesn't have (per its disassembly it would fault).
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!11450
No description provided.