feat(libc): implement sceLibcMspaceReallocalign #107

Merged
asimplestray merged 1 commit from upstream-pr/107 into main 2026-09-28 22:46:20 +00:00
asimplestray commented 2026-09-28 22:15:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by asimplestray on 2026-09-28T22:15:35Z.


What

Implements sceLibcMspaceReallocalign(handle, pointer, size, alignment) (was the only missing function of the mspace family a real game needs at load: the relinked Hades binary died with undefined symbol: p6lrRW8-MLY under BIND_NOW).

Semantics mirror the existing neighbors: null pointer behaves like Memalign, zero size frees, invalid (zero/non-power-of-two) alignment reports EINVAL, an in-place resize keeps the pointer only when capacity and effective alignment (floored at 16, like Memalign) both hold, otherwise allocate-copy-release preserving min(used, size) bytes.

Identified by hashing candidate Sony names with the PS5 NID suffix against the game's import NIDs (same method as #106).

Tested

Linux (GCC 16, BUILD_TESTING=ON): full build, ctest 56/56 pass, including extended mspace_tests (aligned fresh alloc, grow with content preservation, invalid alignments, free-on-zero). The lazy-bound Hades binary advances past this symbol at load.

Checklist

  • Based on current main; no other open PR implements the same functions (checked #77-86, #98, #101, #102, #106)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (no new stubs)
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4669937208 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/107). Originally posted by [asimplestray](https://github.com/asimplestray) on 2026-09-28T22:15:35Z. --- ### What Implements `sceLibcMspaceReallocalign(handle, pointer, size, alignment)` (was the only missing function of the mspace family a real game needs at load: the relinked Hades binary died with `undefined symbol: p6lrRW8-MLY` under `BIND_NOW`). Semantics mirror the existing neighbors: null pointer behaves like `Memalign`, zero size frees, invalid (zero/non-power-of-two) alignment reports `EINVAL`, an in-place resize keeps the pointer only when capacity and effective alignment (floored at 16, like `Memalign`) both hold, otherwise allocate-copy-release preserving `min(used, size)` bytes. Identified by hashing candidate Sony names with the PS5 NID suffix against the game's import NIDs (same method as #106). ### Tested Linux (GCC 16, `BUILD_TESTING=ON`): full build, `ctest` 56/56 pass, including extended `mspace_tests` (aligned fresh alloc, grow with content preservation, invalid alignments, free-on-zero). The lazy-bound Hades binary advances past this symbol at load. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (checked #77-86, #98, #101, #102, #106) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (no new stubs) - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-09-28 22:43:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-28T22:43:49Z.


Progress report (4c2b052 → 02b431e)

📈 System libraries: 67.23% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc sceLibcMspaceReallocalign_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5880064578 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/107#issuecomment-5880064578). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-28T22:43:49Z. --- <!-- progress-report --> ### Progress report (4c2b052 → 02b431e) 📈 **System libraries**: 67.23% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `sceLibcMspaceReallocalign_nid_postfix` | </details>
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!107
No description provided.