feat(libc): export scriptingGetMem and scriptingFreeMem from application heap #1611

Closed
neuralsin wants to merge 1 commit from upstream-pr/1611 into main
neuralsin commented 2026-10-08 14:31:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by neuralsin on 2026-10-08T14:31:20Z.


What

Certain titles perform a process-wide lookup for scripting heap entry points at runtime via dlsym(NULL, "scriptingGetMem") and dlsym(NULL, "scriptingFreeMem") (NIDs ayuoL6Vjz2k and yV45DG6ei28). The entry points were not exported.

This exports scriptingGetMem(alignment, size) and scriptingFreeMem(pointer) from libc, backed by ApplicationHeapAlign_nid_no_patch and ApplicationHeapFree_nid_no_patch. The names are the real symbols, so the NID comes from the name and no APS5_EXPORT alias is needed.

Closes #694.

Tested

Linux: application_heap_tests (asserts the allocator callback gets the size and alignment, and that free reaches it), plus the libc and libs ctest set (71 tests) on the PR rebased onto current main. Windows (MinGW GCC 15.2, Release) run by @popcoder565 reported the duplicate-export failure fixed by dropping the aliases. Not run on a title.

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 in TechnicalDebt
  • 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
  • AI-assisted:
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4788362306 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611). Originally posted by [neuralsin](https://github.com/neuralsin) on 2026-10-08T14:31:20Z. --- ### What Certain titles perform a process-wide lookup for scripting heap entry points at runtime via `dlsym(NULL, "scriptingGetMem")` and `dlsym(NULL, "scriptingFreeMem")` (NIDs `ayuoL6Vjz2k` and `yV45DG6ei28`). The entry points were not exported. This exports `scriptingGetMem(alignment, size)` and `scriptingFreeMem(pointer)` from `libc`, backed by `ApplicationHeapAlign_nid_no_patch` and `ApplicationHeapFree_nid_no_patch`. The names are the real symbols, so the NID comes from the name and no `APS5_EXPORT` alias is needed. Closes #694. ### Tested Linux: `application_heap_tests` (asserts the allocator callback gets the size and alignment, and that free reaches it), plus the `libc` and `libs` ctest set (71 tests) on the PR rebased onto current `main`. Windows (MinGW GCC 15.2, Release) run by @popcoder565 reported the duplicate-export failure fixed by dropping the aliases. Not run on a title. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [ ] AI-assisted: <!-- yes / no -->
oneandonlydean commented 2026-10-09 09:22:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:21Z.


Which title calls scriptingGetMem, and which console library exports it? #694 doesn't name the title, and if the symbol comes from the title's own modules it doesn't belong in libc. Please also fill in the PR template (Tested, AI-assisted).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6078121638 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611#issuecomment-6078121638). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T09:22:21Z. --- Which title calls `scriptingGetMem`, and which console library exports it? #694 doesn't name the title, and if the symbol comes from the title's own modules it doesn't belong in libc. Please also fill in the PR template (Tested, AI-assisted).
popcoder565 commented 2026-10-09 15:44:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:44:45Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 39159bb4, merged onto main d70b8998 in one build with 38 other PRs that had no Windows run.

libc.prx fails its NID patch on Windows, so the build stops:

FAIL: .../libc.prx: duplicate patched export name: ayuoL6Vjz2k
  • scriptingGetMem and scriptingFreeMem are extern "C" and named after the real symbols. The patcher derives ayuoL6Vjz2k and yV45DG6ei28 from those names.
  • MinGW exports every global symbol, so libc.prx exports both the plain names and the APS5_EXPORT aliases (ayuoL6Vjz2k_nid_no_patch_cut). Both patch to the same NID.
  • Dropping the two APS5_EXPORT lines (and the ExportMacros.hpp include) fixes it on Windows. The patched libc.prx then exports ayuoL6Vjz2k and yV45DG6ei28. The four application_heap_* tests pass, and so does the full suite in that build (519 of 519). I haven't checked Linux with that change.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084244747 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611#issuecomment-6084244747). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:44:45Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `39159bb4`, merged onto `main` d70b8998 in one build with 38 other PRs that had no Windows run. **`libc.prx` fails its NID patch on Windows**, so the build stops: ``` FAIL: .../libc.prx: duplicate patched export name: ayuoL6Vjz2k ``` - `scriptingGetMem` and `scriptingFreeMem` are `extern "C"` and named after the real symbols. The patcher derives `ayuoL6Vjz2k` and `yV45DG6ei28` from those names. - MinGW exports every global symbol, so `libc.prx` exports both the plain names and the `APS5_EXPORT` aliases (`ayuoL6Vjz2k_nid_no_patch_cut`). Both patch to the same NID. - Dropping the two `APS5_EXPORT` lines (and the `ExportMacros.hpp` include) fixes it on Windows. The patched `libc.prx` then exports `ayuoL6Vjz2k` and `yV45DG6ei28`. The four `application_heap_*` tests pass, and so does the full suite in that build (519 of 519). I haven't checked Linux with that change. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-09 21:25:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:25:37Z.

Review: CHANGES_REQUESTED


Thanks. Changes needed:

  • Windows build breaks (native run by @popcoder565, MinGW GCC 15.2, Release): libc.prx fails the NID patch with duplicate patched export name: ayuoL6Vjz2k. scriptingGetMem/scriptingFreeMem are extern "C" and already named after the real symbols, so the patcher derives the NID from the plain name; MinGW exports every global, so the APS5_EXPORT alias (ApplicationHeap.cpp:240, :245) yields the same NID twice. Drop both APS5_EXPORT lines and the ExportMacros.hpp include; with that the patched libc.prx exports ayuoL6Vjz2k/yV45DG6ei28 and the full suite passes on Windows (519/519 in that build). Please confirm on Linux too.
  • @oneandonlydean's question is still open: which title calls scriptingGetMem, and which console library exports it? If it comes from the title's own modules it doesn't belong in libc (see CONTRIBUTING: modules titles ship themselves are not reimplemented). Please answer it in the PR.
  • Fill in the PR template (Tested, AI-assisted).
  • #1656 touches ApplicationHeap.cpp; list it in Depends on if you build on it, and rebase after it lands.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5475495559 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611#pullrequestreview-5475495559). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:25:37Z. **Review:** CHANGES_REQUESTED --- Thanks. Changes needed: - **Windows build breaks** (native run by @popcoder565, MinGW GCC 15.2, Release): `libc.prx` fails the NID patch with `duplicate patched export name: ayuoL6Vjz2k`. `scriptingGetMem`/`scriptingFreeMem` are `extern "C"` and already named after the real symbols, so the patcher derives the NID from the plain name; MinGW exports every global, so the `APS5_EXPORT` alias (`ApplicationHeap.cpp:240`, `:245`) yields the same NID twice. Drop both `APS5_EXPORT` lines and the `ExportMacros.hpp` include; with that the patched `libc.prx` exports `ayuoL6Vjz2k`/`yV45DG6ei28` and the full suite passes on Windows (519/519 in that build). Please confirm on Linux too. - @oneandonlydean's question is still open: which title calls `scriptingGetMem`, and which console library exports it? If it comes from the title's own modules it doesn't belong in libc (see CONTRIBUTING: modules titles ship themselves are not reimplemented). Please answer it in the PR. - Fill in the PR template (`Tested`, `AI-assisted`). - #1656 touches `ApplicationHeap.cpp`; list it in **Depends on** if you build on it, and rebase after it lands.
github-actions[bot] commented 2026-10-09 21:42:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T21:42:25Z.


Progress report (9f4bd71 → 39159bb)

📈 System libraries: 84.77% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc scriptingFreeMem
libc scriptingGetMem
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089743645 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611#issuecomment-6089743645). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T21:42:25Z. --- <!-- progress-report --> ### Progress report (9f4bd71 → 39159bb) 📈 **System libraries**: 84.77% (+0.01%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libc | `scriptingFreeMem` | | libc | `scriptingGetMem` | </details>
adriadam10 commented 2026-10-11 09:21:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:21:55Z.


Ready to merge from my side, but the PR description fails the conventions check:

  • [pr-template] Fill in the pull request template: unchecked: AI-assisted:
  • [pr-template] Fill in the pull request template: answer AI-assisted with yes or no

Please fill those template lines in (only you can answer AI-assisted); it merges once they pass.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107539805 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611#issuecomment-6107539805). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T09:21:55Z. --- Ready to merge from my side, but the PR description fails the conventions check: - [pr-template] Fill in the pull request template: unchecked: AI-assisted: - [pr-template] Fill in the pull request template: answer AI-assisted with yes or no Please fill those template lines in (only you can answer AI-assisted); it merges once they pass.
oneandonlydean commented 2026-10-12 07:37:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T07:37:20Z.


Closing: the questions from 10-09 are still open (which title calls scriptingGetMem, and which console library exports it), the Windows build fails on the duplicate ayuoL6Vjz2k export, and the branch conflicts with main. If you decide to continue, please reopen.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6119860686 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1611#issuecomment-6119860686). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T07:37:20Z. --- Closing: the questions from 10-09 are still open (which title calls `scriptingGetMem`, and which console library exports it), the Windows build fails on the duplicate `ayuoL6Vjz2k` export, and the branch conflicts with main. If you decide to continue, please reopen.

Pull request closed

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!1611
No description provided.