fix(relinker): pass module start arguments to macOS guest initializers #3492

Merged
fable-void merged 1 commit from upstream-pr/3492 into main 2026-10-11 11:54:49 +00:00
fable-void commented 2026-10-11 11:35:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fable-void on 2026-10-11T11:35:53Z.


What

On macOS, a guest module started with sceKernelLoadStartModule never receives its start arguments: the image initializer calls DT_INIT with none and drops its result. On current main (0f863c10), the extended guest_module_args stops at:

AssertionError: the macOS module does not bind __aps5_get_pending_module_args_nid_no_patch

Linux modules already call DT_INIT through libkernel's pending argument handoff (__aps5_get_pending_module_args_nid_no_patch, __aps5_set_module_init_result_nid_no_patch). main does not start guests on macOS yet; on the macOS port, the PSN plugin of Hollow Knight: Silksong (PPSA12544) refuses to start without its argument block, and the title then crashes:

PSN is an old version that cannot be used by the current player runtime

The macOS writer now binds the same two helpers for a module with DT_INIT, and the initializer calls DT_INIT with the recorded args and argp, with the same instruction sequence as the Linux stub, then hands the result back. The TechnicalDebt sentence about the missing arguments on macOS is removed.

Tested

macOS on Apple silicon, relinker-only build for x86-64 (ANYPS5_RELINKER_ONLY=ON, Release).

  • guest_module_args fails on main with the line above and passes with this change, both with an arm64 Python (structure only) and with an x86-64 Python under Rosetta 2, which loads the converted module and checks that DT_INIT receives the arguments and that its result is returned.
  • Relinker tests: 105 of 105 pass with either Python.
  • The Linux branch of the test only moved into load_and_record; not run here.
  • With the same change on the macOS port, PPSA12544 starts its plugins and reaches the title menu.

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: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818758083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3492). Originally posted by [fable-void](https://github.com/fable-void) on 2026-10-11T11:35:53Z. --- ### What On macOS, a guest module started with `sceKernelLoadStartModule` never receives its start arguments: the image initializer calls `DT_INIT` with none and drops its result. On current `main` (`0f863c10`), the extended `guest_module_args` stops at: ``` AssertionError: the macOS module does not bind __aps5_get_pending_module_args_nid_no_patch ``` Linux modules already call `DT_INIT` through libkernel's pending argument handoff (`__aps5_get_pending_module_args_nid_no_patch`, `__aps5_set_module_init_result_nid_no_patch`). `main` does not start guests on macOS yet; on the macOS port, the PSN plugin of Hollow Knight: Silksong (PPSA12544) refuses to start without its argument block, and the title then crashes: ``` PSN is an old version that cannot be used by the current player runtime ``` The macOS writer now binds the same two helpers for a module with `DT_INIT`, and the initializer calls `DT_INIT` with the recorded `args` and `argp`, with the same instruction sequence as the Linux stub, then hands the result back. The TechnicalDebt sentence about the missing arguments on macOS is removed. ### Tested macOS on Apple silicon, relinker-only build for x86-64 (`ANYPS5_RELINKER_ONLY=ON`, Release). - `guest_module_args` fails on `main` with the line above and passes with this change, both with an arm64 Python (structure only) and with an x86-64 Python under Rosetta 2, which loads the converted module and checks that `DT_INIT` receives the arguments and that its result is returned. - Relinker tests: 105 of 105 pass with either Python. - The Linux branch of the test only moved into `load_and_record`; not run here. - With the same change on the macOS port, PPSA12544 starts its plugins and reaches the title menu. ### 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 - [x] AI-assisted: yes
adriadam10 commented 2026-10-11 11:54:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:54:47Z.


Checked the macOS initializer against the Linux stub (same instruction sequence: args getter, rdi/rsi from the block, edx=0, call DT_INIT, result setter; stack aligned by the frame push), guest_module_args fails on main without the change and passes with it, and the relinker ctest (101 tests) is green on Linux. The macOS execution path itself isn't something we can run here. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108749821 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3492#issuecomment-6108749821). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:54:47Z. --- Checked the macOS initializer against the Linux stub (same instruction sequence: args getter, `rdi`/`rsi` from the block, `edx`=0, call `DT_INIT`, result setter; stack aligned by the frame push), `guest_module_args` fails on `main` without the change and passes with it, and the relinker ctest (101 tests) is green on Linux. The macOS execution path itself isn't something we can run here. Merging.
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!3492
No description provided.