fix(macos): read application process parameters from Mach-O images #10876
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10876"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by krishalivaibhav on 2026-10-25T07:10:12Z.
What
On macOS, any guest that uses the application heap threw
unsupported executable format. The reason is thatApplicationProcessParameters_nid_no_patchonly searched for the process parameters withdl_iterate_phdron Linux. macOS already providesdl_iterate_phdrthroughGuestImages.cpp, so this PR widens the two#elif defined(__linux__)checks inApplicationProcessParameters.cppto|| defined(__APPLE__).ProcessParametersFixture::Installhad no macOS branch and returned false. It now fills a__APS5DATA,__metasection with version-2 relinker metadata, which is the same layout the Linux branch builds.The Linux and Windows branches are unchanged. The fixture change follows iamthehimansh's
feat/macos-port(#8658), and iamthehimansh is credited as co-author.Tested
macOS: Apple Silicon M2, macOS 27.2, AppleClang, x86_64 Release, on a local integration of
main+ #10419 + #10366 + #10369 + #7631 + #7804 + #4630 + #10552 + #10853 + this commit:guest_http,guest_rtc,guest_rtc_ps5_titleandguest_sslpass (they failed before);guest_ssl_transport_kernelandguest_ssl_transport_netalso need the separate libSceSsl symbol PR;application_heap_*tests pass (with theApplicationHeap.cppcommit, from mugurc'sa5a9184e5c);ctest -R '^(guest_|libc_|libkernel_)': no new failures.Building on macOS needs #10552 and the PRs listed above.
Linux/Windows: not built locally. Only
__APPLE__branches are added.Checklist
main. Overlap: #5021 and #7201 also add the two__APPLE__conditions inApplicationProcessParameters.cpp; the test fixture and theApplicationHeap.cppchange are only hereNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by imellag on 2026-10-25T08:56:15Z.
Review: DISMISSED
Tested head
cb2416f8c2on Apple M4 Pro, macOS 27.0.1, Apple clang 21, x86-64 under Rosetta 2. The tree ismain61fc572ceeplus the open macOS build PRs and the parts of mugurc's series that #7201 also carries. Only this change was toggled, withmain's versions ofApplicationProcessParameters.cpp,ProcessParametersFixture.hppandApplicationHeap.cppas the base.ctest -R '^guest_' -j6(672 tests): 39 fail without this PR, 17 with it, and none fails only with it. The 22 that now pass are:guest_appcontent,guest_coredump_attach,guest_coredump_user_data,guest_hmd,guest_hmd2,guest_http,guest_kernel_sys_sdk_version;guest_np_commerce_dialog,guest_rtc,guest_rtc_ps5_title,guest_screenshot,guest_screenshot_large_overlay,guest_ssl,guest_usb_storage_dialog,guest_vr_tracker2;guest_convert_keycode*tests.Requested change.
application_heap_scriptingandapplication_heap_lazystill abort with this PR, becauseApplicationHeap.cppinstalls the process parameters itself and has no macOS branch. mugurc'sa5a9184e5cadds one with the fixture this PR now fills:With those four lines added to this PR, all 9
application_heap_*tests pass. Without them, 7 of 9 pass, the same as onmain. Since this PR is what makes the fixture work on macOS, could you add them here, so the application heap tests get the same fix as the others?AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by maximilianfv on 2026-10-25T13:20:33Z.
Review: APPROVED
Approving: on macOS the two
__APPLE__conditions and the fixture fix all 24 tests that abort for lack of process parameters, in 3 of 3 runs, and none of the 40 tests I ran fails with it. The three items below are small and none of them blocks merging.Tested on Apple M1 Pro, macOS 27.0.1 (x86_64 build under Rosetta 2)
Applied at
d1f5a3410ato mugurc's macOS series (27e968974) merged withmainat2742004ed2, with other open macOS fixes. The series already carries near-identical macOS branches in all three files this PR touches, so for both arms those three files were reset tomain's content. The rest of the series stayed in place, and only this PR's diff was toggled. 40 tests (application_heap_*plus everyguest_*test whose source includesProcessParametersFixture.hpp, plus 7 neighbouring tests the name prefixes matched), 3 runs per arm:application_heap_*(9)guest_*testsguest_ssl_transport_kernel,_netscriptingandlazyabort withapplication heap: unsupported executable formatInstallreturns false (process parameters were not installed)a server certificate without a loaded CA passed the initial verify optionsThe same results came up in all 3 runs of each arm. The SSL transport failure is the separate libSceSsl gap that the description already names.
Findings (non-blocking)
core/libs/tests/ProcessParametersFixture.hpp:96:headers[0].p_flagsis left at 0. In a fixture test that registers the main image (GuestAllocationsRegisterMainImage, reached fromsceKernelMapDirectMemory),collectImagePagesincore/libs/prx/libc/src/GuestAllocations.cpp:286-287then marks the page ofprocessas neither readable nor writable, although the test writes to it. None of the 40 tests fails from it. Fix:headers[0].p_flags = PF_W;(PF_Wis inmain'sElfTypes.hpp,PF_Ris not, andcollectImagePagestreatsPF_Was readable and writable).GuestFlexibleMemoryModule.cppsetsPF_R | PF_Won its header.ApplicationProcessParameters.cppchange (same blob pair,5efa1f00d31..8a556bd0e01) and the first macOS__APS5DATA,__metafixture. mugurc'sa5a9184e5cnames it ("#7332 makes the same change to the fixture"). Please link #7332 underWhatand add aCo-authored-by:for its author tocb2416f8c2, next to the #8658 credit.MacOsImage.cpp) andGuestImages.cppreads. The Linux branch builds no such layout: it rewrites a spare program header in place. "the same layout the Linux branch builds" should say so.ctest -R '^(guest_|libc_|libkernel_)': no test names start withlibc_orlibkernel_, so that run covered onlyguest_*.AI-assisted: yes (Claude Code applied the PR, ran the tests, read the code and wrote this review).