feat(libc): export the std::__sce_v2 clog, wclog and standard stream pointers #16083

Merged
Danigamer05 merged 1 commit from upstream-pr/16083 into main 2026-11-06 20:23:52 +00:00
Danigamer05 commented 2026-11-05 16:03:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Danigamer05 on 2026-11-05T16:03:06Z.


What

Export the versioned std::__sce_v2 clog and wclog and the eight standard stream pointers from libc.

Export NID Original address
_ZNSt8__sce_v28_Ptr_cinE 0JbUOAJmBDA 0x197840
_ZNSt8__sce_v29_Ptr_coutE aHPbwpOzg7A 0x197848
_ZNSt8__sce_v29_Ptr_cerrE YpXm9hJ+Kxk 0x197850
_ZNSt8__sce_v29_Ptr_clogE 6JHYSZ5l0K4 0x197858
_ZNSt8__sce_v29_Ptr_wcinE 4vGo180IRx8 0x197860
_ZNSt8__sce_v210_Ptr_wcoutE sK-ozcyfXlA 0x197868
_ZNSt8__sce_v210_Ptr_wcerrE 70AJso+2Yks 0x197870
_ZNSt8__sce_v210_Ptr_wclogE VLb2-jScg6o 0x197878
_ZNSt8__sce_v24clogE tIpEi4OinAI 0x198880
_ZNSt8__sce_v25wclogE QtsIfGDk6wY 0x198CE0

The behavior comes from the libc.prx bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6).

In the module clog and wclog are 0x68-byte streams beside the other six, and each _Ptr_* is an 8-byte pointer that the stream's static constructor sets to the stream's address when the module loads. The same constructors tie cin, cerr, wcin and wcerr to their output stream and set unitbuf on cerr and wcerr.

Main already exports the other six versioned streams as zeroed 0x400 storage, which nothing constructs. clog and wclog are added the same way next to them, and each pointer is initialized to its stream's storage, so it holds the value the console's holds after load. The tie and unitbuf are not set, since there is no constructed stream to set them on; a new debt entry records this.

Tested

Windows x86-64, WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, main 4741457fed4. Exact tested commit: fedacbcaedf.

  • Built libc, libkernel, their NID-patched production libraries and the related tests. guest_sce_v2_locale and guest_locale pass, as does public_headers on an earlier base.
  • The NID-patched libc exports all 10 NIDs above.
  • The sizes and addresses were read from the module's symbol table. Each pointer's value was read from the module's static constructors: each stores the address of its own stream, and the eight stores cover the eight streams.
  • guest_sce_v2_locale now covers eight streams instead of six. It checks that each starts zeroed, that no two share storage, and that each _Ptr_* points at its own stream.
  • Negative control: _Ptr_cout was pointed at cerr, then _Ptr_wclog was set to null. The test failed on each. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test passed again.
  • Code conventions and git diff --check pass.
  • tools/pr_overlap.py read 1,848 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 36 branches that already conflict with main. Merging each of the 36 with this branch and with main using git merge-tree gives the same conflict blocks. No open PR adds these names or NIDs. The debt entry was placed where it added no conflict with any of the 144 open PRs that touched docs/dev/debt/libc.md at an earlier base, and none conflicts at the tested commit. The branch also merges cleanly with #15336, #15471, #15484, #15490, #15501, #15519, #15552, #15561, #15602, #15614, #15667, #15683, #15791, #15796, #15809, #15834, #15879 and #15923.

Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded.

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:5174630300 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16083). Originally posted by [Danigamer05](https://github.com/Danigamer05) on 2026-11-05T16:03:06Z. --- ### What Export the versioned `std::__sce_v2` `clog` and `wclog` and the eight standard stream pointers from libc. | Export | NID | Original address | | --- | --- | --- | | `_ZNSt8__sce_v28_Ptr_cinE` | `0JbUOAJmBDA` | `0x197840` | | `_ZNSt8__sce_v29_Ptr_coutE` | `aHPbwpOzg7A` | `0x197848` | | `_ZNSt8__sce_v29_Ptr_cerrE` | `YpXm9hJ+Kxk` | `0x197850` | | `_ZNSt8__sce_v29_Ptr_clogE` | `6JHYSZ5l0K4` | `0x197858` | | `_ZNSt8__sce_v29_Ptr_wcinE` | `4vGo180IRx8` | `0x197860` | | `_ZNSt8__sce_v210_Ptr_wcoutE` | `sK-ozcyfXlA` | `0x197868` | | `_ZNSt8__sce_v210_Ptr_wcerrE` | `70AJso+2Yks` | `0x197870` | | `_ZNSt8__sce_v210_Ptr_wclogE` | `VLb2-jScg6o` | `0x197878` | | `_ZNSt8__sce_v24clogE` | `tIpEi4OinAI` | `0x198880` | | `_ZNSt8__sce_v25wclogE` | `QtsIfGDk6wY` | `0x198CE0` | The behavior comes from the `libc.prx` bundled with PPSA03671 v01.001.005 (J03848509, SHA-256 `483961e086b8a1fffa8138b3c0badf798987fb5f35ec908d828946408be2d8a6`). In the module `clog` and `wclog` are `0x68`-byte streams beside the other six, and each `_Ptr_*` is an 8-byte pointer that the stream's static constructor sets to the stream's address when the module loads. The same constructors tie `cin`, `cerr`, `wcin` and `wcerr` to their output stream and set `unitbuf` on `cerr` and `wcerr`. Main already exports the other six versioned streams as zeroed `0x400` storage, which nothing constructs. `clog` and `wclog` are added the same way next to them, and each pointer is initialized to its stream's storage, so it holds the value the console's holds after load. The tie and `unitbuf` are not set, since there is no constructed stream to set them on; a new debt entry records this. ### 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 x86-64, WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, main `4741457fed4`. Exact tested commit: `fedacbcaedf`. - Built libc, libkernel, their NID-patched production libraries and the related tests. `guest_sce_v2_locale` and `guest_locale` pass, as does `public_headers` on an earlier base. - The NID-patched libc exports all 10 NIDs above. - The sizes and addresses were read from the module's symbol table. Each pointer's value was read from the module's static constructors: each stores the address of its own stream, and the eight stores cover the eight streams. - `guest_sce_v2_locale` now covers eight streams instead of six. It checks that each starts zeroed, that no two share storage, and that each `_Ptr_*` points at its own stream. - Negative control: `_Ptr_cout` was pointed at `cerr`, then `_Ptr_wclog` was set to null. The test failed on each. The source was then restored byte for byte (SHA-256 checked) and rebuilt, and the test passed again. - Code conventions and `git diff --check` pass. - `tools/pr_overlap.py` read 1,848 open PRs at the tested commit and reports no overlap. It keeps exit 2 for 36 branches that already conflict with main. Merging each of the 36 with this branch and with main using `git merge-tree` gives the same conflict blocks. No open PR adds these names or NIDs. The debt entry was placed where it added no conflict with any of the 144 open PRs that touched `docs/dev/debt/libc.md` at an earlier base, and none conflicts at the tested commit. The branch also merges cleanly with #15336, #15471, #15484, #15490, #15501, #15519, #15552, #15561, #15602, #15614, #15667, #15683, #15791, #15796, #15809, #15834, #15879 and #15923. Not tested: Linux, macOS, another SDK, a game, GPU or console. No game compatibility claim. No original module, extracted bytes, harness or log is committed or uploaded. ### 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!16083
No description provided.