Repository navigation
feat(libkernel): sceKernelGetModuleInfoFromAddr on macOS hosts, without reading st_size - #8
Conversation
|
Thank you, this is exactly what the port needs. |
…ut reading st_size The unwinder in a title's own libc.prx asks sceKernelGetModuleInfoFromAddr for the eh_frame of the frame it is in. On macOS the call was not implemented, and on every host it threw when the caller's st_size was not the full size. Cloudberry Kingdom (PPSA23827) passes a stale st_size (8, or a pointer), so its first C++ throw, a minute or two in, ended the process with `unsupported st_size`. - The caller's st_size is no longer read: shadPS4's process.cpp fills the structure whatever it holds. The result still carries the full size. - On macOS the image is found through dl_iterate_phdr over the program headers a converted image keeps, with the code the Linux branch uses for the name, the load segments, the TLS image and the eh_frame. The id comes from the image's Mach-O header. tls_index, init_proc_addr and fini_proc_addr stay 0, and an image opened through the loader gets a stable id of its own; TechnicalDebt.md records both. The module-info fixture asks for its own information with flags 2 and st_size 8 and exits with eh_frame_size, 20 with the terminator; it is the unwind-info fixture with another import. guest_module_info expects a short st_size to succeed; it is not built on macOS and was not run. The title now runs past its first throw (230 s without a stop). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51711d7 to
1f02b19
Compare
|
Rebased onto
AI-assisted: yes |
|
Merged #7 and #8 into |
|
@vladbondarenko97 Thank you again for this one. I am sending the macOS port to boykopovar/AnyPS5 as single-topic pull requests (series announced on boykopovar#1: boykopovar#1 (comment)). This change is one of them: I will open it upstream as it is, with your commit and authorship kept, and mention you in the description. If you would rather open it yourself, tell me and I leave it out. |
|
I checked #8 against current upstream main and it looks like it still depends on some of the macOS groundwork you’re already upstreaming, so I’m not gonna try to force a standalone PR. Feel free to handle it whenever it fits your series. I’d just appreciate keeping my commit/authorship attached where it still applies. Thanks again for carrying this stuff upstream bro. |
What
sceKernelGetModuleInfoFromAddrworks on macOS hosts, and no longer reads the caller'sst_sizeon any host.sceKernelGetModuleListandsceKernelGetModuleInfoare untouched and still throw as not implemented on macOS.Why
The unwinder in a title's own
libc.prxasks this function for theeh_frameof the frame it is in. Onmacos-portthe call was not implemented, and it threw before that whenst_sizewas not the full size. Cloudberry Kingdom (PPSA23827) passes a stalest_size(8 on one run, a pointer on another), so its first C++ throw, a minute or two in, ended the process:Implementation
st_sizeis not read. shadPS4'sprocess.cppfills the structure whatever the caller left there; the result still carries the full size.dl_iterate_phdrover the program headers a converted image keeps, through theFillandFindImagetemplates the Linux branch already has for the name, the load segments, the TLS image and theeh_frame(now read withEhFrame::ReadTables). The id comes from the image's Mach-O header.TechnicalDebt.md:tls_index,init_proc_addrandfini_proc_addrstay 0 on macOS, and an image opened through the loader gets a stable id of its own instead of itssceKernelLoadStartModulehandle.Tested
All on an M4 Pro, macOS 26.5.1, under Rosetta, on this branch rebased onto
macos-portat 21930ce:module-infofixture (new, inrun_macos_fixtures.py): theunwind-infofixture with this import, flags 2 andst_size8; it exits witheh_frame_size, 20 with the terminator. The byte-built fixtures all pass: argv, import, tls, mprotect-slide, mprotect-pages, unwind-info, module-info. The compiled fixtures were skipped (no LLVM toolchain here).ctest: 712 tests. Two runs passed everything and one had a single failure,guest_socket_read_write, which aborts intermittently on its own here (check failed at line 101, errno 54, about 1 run in 20) and does not touch this code. 264 tests report skipped, nearly all for want oflibvulkan.1.dylibon the test path.guest_module_info, whose expectation for a shortst_sizeI changed; it is not built on macOS, so the Linux and Windows result of that change is unverified by me.Checklist
main(throughmacos-portat 21930ce); no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code