feat(libSceLibcInternal): answer the codecvt and messages queries as firmware 13.42 does #15582

Merged
BunnyFl merged 3 commits from upstream-pr/15582 into main 2026-11-07 20:46:29 +00:00
BunnyFl commented 2026-11-03 20:18:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T20:18:19Z.


What

Ten libSceLibcInternal exports for C++ locale facets threw. In firmware 13.42 each one returns a constant or nothing, reading none of its arguments, and this change does the same:

Export NID Returns
codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const KheIhkaSrlA false
codecvt<wchar_t, char, mbstate_t>::do_max_length() const 5BQIjX7Y5YU 6
codecvt<wchar_t, char, mbstate_t>::do_encoding() const 4fPIrH+z+E4 0
codecvt<char16_t, char, mbstate_t>::do_always_noconv() const 9Vyfb-I-9xw false
codecvt<char16_t, char, mbstate_t>::do_encoding() const Mo6K-pUyNhI 0
codecvt<char32_t, char, mbstate_t>::do_always_noconv() const NQ81EZ7CL6w false
messages<char>::do_open(const string&, const locale&) const HeBwePMtuFs -1
messages<wchar_t>::do_open(const string&, const locale&) const zSehLdHI0FA -1
messages<char>::do_close(catalog) const rRmMX83UL1E nothing
messages<wchar_t>::do_close(catalog) const AjkxQBlsOOY nothing

Names and NIDs match tools/nid_names.py. The return types are the standard ones for these members: bool for do_always_noconv, int for do_encoding, do_max_length and do_open (messages_base::catalog), void for do_close.

The exports keep their helper names in core/libs/prx/libSceLibcInternal/Err.cpp and Export.cpp, and now each has one declaration in include/Api.hpp, next to the other implemented _nid_no_patch helpers there. The ten "prototype and behavior are unverified" entries in docs/dev/debt/libSceLibcInternal.md are removed: their gaps are closed.

Source

Firmware 13.42 system/common/lib/libSceLibcInternal.sprx (sha256 a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285), read from disassembly, not run on a console. Each body, to its return:

c0010: xor %eax,%eax          ; codecvt<wchar_t>::do_always_noconv
c0012: ret
c0020: mov $0x6,%eax          ; codecvt<wchar_t>::do_max_length
c0025: ret
c0030: xor %eax,%eax          ; codecvt<wchar_t>::do_encoding
c0032: ret
c0500: xor %eax,%eax          ; codecvt<char16_t>::do_always_noconv
c0502: ret
c0530: xor %eax,%eax          ; codecvt<char16_t>::do_encoding
c0532: ret
c0b90: xor %eax,%eax          ; codecvt<char32_t>::do_always_noconv
c0b92: ret
99c40: mov $0xffffffff,%eax   ; messages<char>::do_open
99c45: ret
99ca0: ret                    ; messages<char>::do_close
aaa50: mov $0xffffffff,%eax   ; messages<wchar_t>::do_open
aaa55: ret
aaaf0: ret                    ; messages<wchar_t>::do_close

No argument is read, this included, and nothing is written. A null or invalid pointer is never dereferenced, here or in firmware.

Tested

  • Merged main cdf371df68 into the branch; the head is now d0ac18c921. The only conflict was in core/libs/prx/libSceLibcInternal/CMakeLists.txt, where main registered its guest_libc_internal_memory_resource test next to this branch's guest_libc_internal_facet_queries; both are kept. The branch's added and removed lines against main are the same as before the merge, so the negative control below was not repeated.
    • On d0ac18c921, Windows 11 Pro 10.0.26300, WinLibs GCC, Release: 68 of 68 pass, none Not Run, the same suite as below with every executable rebuilt.
    • tools/check_conventions.py --base upstream/main on the committed head d0ac18c921: all checks pass.
  • Windows 11, WinLibs GCC, Release, head 9719108c9f (main 9e432fbfa4 merged in): 68 of 68 pass, none Not Run. That is the new guest_libc_internal_facet_queries, guest_err (same source files), guest_libc_internal_numpunct (added on main, same library), public_headers and the 64 public_headers_compile_* batches.
  • New core/libs/tests/GuestLibcInternalFacetQueries.cpp (registered after guest_err_tests in core/libs/prx/libSceLibcInternal/CMakeLists.txt):
    • It checks each return value in the table, using a filled facet buffer and dummy name and locale buffers.
    • It checks that the facet buffer is unchanged afterwards.
  • Negative control (run at the earlier head 40c1005030; the branch's added and removed lines against main are identical at that head and at 9719108c9f): I put NotImplemented_nid_no_patch(__func__) back at the top of the ten bodies, which is main's behaviour, and kept this branch's signatures and test. The new test then aborts with sceLibcInternalPending3_039_nid_no_patch not implemented (1 of 1 failed).
  • tools/check_conventions.py --base upstream/main on the committed head 9719108c9f: all checks pass.
  • tools/pr_overlap.py --branch feat/libcinternal-facet-queries --jobs 8 at head 9719108c9f, against 1,889 open pull requests: 21 share files with the branch. Five have conflicting lines next to this branch's additions, CMakeLists.txt L274 and include/Api.hpp L155 on main (#14903, #15852, #16356, and my #15584 and #15588); no row reports a shared export or new file. The run failed closed (exit 2) for the other 16, which it lists without comparing them line by line. I grepped the added and removed lines of all 21 diffs for the ten helper names, NIDs and mangled member names: none names any of them.
  • Linux and macOS were not built or run. No title was run.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5143912774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15582). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T20:18:19Z. --- ### What Ten libSceLibcInternal exports for C++ locale facets threw. In firmware 13.42 each one returns a constant or nothing, reading none of its arguments, and this change does the same: | Export | NID | Returns | |---|---|---| | `codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const` | `KheIhkaSrlA` | `false` | | `codecvt<wchar_t, char, mbstate_t>::do_max_length() const` | `5BQIjX7Y5YU` | `6` | | `codecvt<wchar_t, char, mbstate_t>::do_encoding() const` | `4fPIrH+z+E4` | `0` | | `codecvt<char16_t, char, mbstate_t>::do_always_noconv() const` | `9Vyfb-I-9xw` | `false` | | `codecvt<char16_t, char, mbstate_t>::do_encoding() const` | `Mo6K-pUyNhI` | `0` | | `codecvt<char32_t, char, mbstate_t>::do_always_noconv() const` | `NQ81EZ7CL6w` | `false` | | `messages<char>::do_open(const string&, const locale&) const` | `HeBwePMtuFs` | `-1` | | `messages<wchar_t>::do_open(const string&, const locale&) const` | `zSehLdHI0FA` | `-1` | | `messages<char>::do_close(catalog) const` | `rRmMX83UL1E` | nothing | | `messages<wchar_t>::do_close(catalog) const` | `AjkxQBlsOOY` | nothing | Names and NIDs match `tools/nid_names.py`. The return types are the standard ones for these members: `bool` for `do_always_noconv`, `int` for `do_encoding`, `do_max_length` and `do_open` (`messages_base::catalog`), `void` for `do_close`. The exports keep their helper names in `core/libs/prx/libSceLibcInternal/Err.cpp` and `Export.cpp`, and now each has one declaration in `include/Api.hpp`, next to the other implemented `_nid_no_patch` helpers there. The ten "prototype and behavior are unverified" entries in `docs/dev/debt/libSceLibcInternal.md` are removed: their gaps are closed. ### Source Firmware 13.42 `system/common/lib/libSceLibcInternal.sprx` (sha256 `a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285`), read from disassembly, not run on a console. Each body, to its return: ``` c0010: xor %eax,%eax ; codecvt<wchar_t>::do_always_noconv c0012: ret c0020: mov $0x6,%eax ; codecvt<wchar_t>::do_max_length c0025: ret c0030: xor %eax,%eax ; codecvt<wchar_t>::do_encoding c0032: ret c0500: xor %eax,%eax ; codecvt<char16_t>::do_always_noconv c0502: ret c0530: xor %eax,%eax ; codecvt<char16_t>::do_encoding c0532: ret c0b90: xor %eax,%eax ; codecvt<char32_t>::do_always_noconv c0b92: ret 99c40: mov $0xffffffff,%eax ; messages<char>::do_open 99c45: ret 99ca0: ret ; messages<char>::do_close aaa50: mov $0xffffffff,%eax ; messages<wchar_t>::do_open aaa55: ret aaaf0: ret ; messages<wchar_t>::do_close ``` No argument is read, `this` included, and nothing is written. A null or invalid pointer is never dereferenced, here or in firmware. ### 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. --> - Merged `main` `cdf371df68` into the branch; the head is now `d0ac18c921`. The only conflict was in `core/libs/prx/libSceLibcInternal/CMakeLists.txt`, where `main` registered its `guest_libc_internal_memory_resource` test next to this branch's `guest_libc_internal_facet_queries`; both are kept. The branch's added and removed lines against `main` are the same as before the merge, so the negative control below was not repeated. - On `d0ac18c921`, Windows 11 Pro 10.0.26300, WinLibs GCC, Release: **68 of 68 pass, none Not Run**, the same suite as below with every executable rebuilt. - `tools/check_conventions.py --base upstream/main` on the committed head `d0ac18c921`: all checks pass. - Windows 11, WinLibs GCC, Release, head `9719108c9f` (`main` `9e432fbfa4` merged in): 68 of 68 pass, none Not Run. That is the new `guest_libc_internal_facet_queries`, `guest_err` (same source files), `guest_libc_internal_numpunct` (added on `main`, same library), `public_headers` and the 64 `public_headers_compile_*` batches. - New `core/libs/tests/GuestLibcInternalFacetQueries.cpp` (registered after `guest_err_tests` in `core/libs/prx/libSceLibcInternal/CMakeLists.txt`): - It checks each return value in the table, using a filled facet buffer and dummy name and locale buffers. - It checks that the facet buffer is unchanged afterwards. - **Negative control** (run at the earlier head `40c1005030`; the branch's added and removed lines against `main` are identical at that head and at `9719108c9f`): I put `NotImplemented_nid_no_patch(__func__)` back at the top of the ten bodies, which is `main`'s behaviour, and kept this branch's signatures and test. The new test then aborts with `sceLibcInternalPending3_039_nid_no_patch not implemented` (1 of 1 failed). - `tools/check_conventions.py --base upstream/main` on the committed head `9719108c9f`: all checks pass. - `tools/pr_overlap.py --branch feat/libcinternal-facet-queries --jobs 8` at head `9719108c9f`, against 1,889 open pull requests: 21 share files with the branch. Five have conflicting lines next to this branch's additions, `CMakeLists.txt` L274 and `include/Api.hpp` L155 on `main` (#14903, #15852, #16356, and my #15584 and #15588); no row reports a shared export or new file. The run failed closed (exit 2) for the other 16, which it lists without comparing them line by line. I grepped the added and removed lines of all 21 diffs for the ten helper names, NIDs and mangled member names: none names any of them. - Linux and macOS were not built or run. No title was run. ### 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: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/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!15582
No description provided.