feat(libkernel): implement module segment info export #4193
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4193"
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 MarcZX10 on 2026-10-12T01:01:29Z.
What
Carries screamm’s ready
sceKernelInternalMemoryGetModuleSegmentInfoimplementation as a focused PR, preserving the original commit author. It defines the 16-byte{ address, size }result and returns the first segment reported bysceKernelGetModuleInfofor the main program.The result shape and first-segment behavior are based on fpPS4. The console may instead report libkernel’s text or the caller’s module; no call has been observed, so that choice remains explicitly documented as unverified in TechnicalDebt. Null output and missing-main-program cases throw because their console behavior is also unknown. The export is imported by 44 catalog titles that bundle their own
libc.prx.Tested
BUILD_TESTING=ON, andANYPS5_ENABLE_SPIRV_TOOLS=ONcompleted.guest_module_info_testswith Ninja (127/127 steps).ctest --test-dir /tmp/AnyPS5-4173-build -R '^guest_module_info$' --output-on-failure --timeout 60passed (1/1); the test checks that the returned segment matches the first segment fromsceKernelGetModuleInfo(self).python3 tools/check_conventions.py --base upstream/main --head HEADpassed.git diff --checkpassed.Checklist
main; no other open PR implements the same functionNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T01:01:51Z.
Progress report (
1acfa7f→2664fb0)📈 System libraries: 86.39% (+0.03%, +1 implemented functions)
✅ 1 implemented
sceKernelInternalMemoryGetModuleSegmentInfo_nid_postfixImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T14:41:18Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)sceKernelInternalMemoryGetModuleSegmentInfo_nid_postfixImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-12T21:14:18Z.
Review: COMMENTED
Linux build, an A/B control, a duplicate carry, and the rebase onto current
mainI built this head on Linux and measured it. Nothing below is a request for a change I have not measured, and I have no PR against this path. Your Tested section is what made it cheap to check: it names the target, the test and the command.
Head
2664fb07e(parent1acfa7f78). It no longer merges withmain. #4567 (sceKernelGetLibkernelTextLocation) merged at 20:57Z and inserts at the same spot, sogit merge-tree --write-tree pr-4193 upstream/mainexits 1 (checked at6d2f27986and again at7940cacd8) with content conflicts incore/libs/prx/libkernel/Module/src/ModuleInfo.cppandcore/libs/tests/GuestModuleInfo.cpp. Section 1 has a resolution that builds.1. Rebase: keep both functions
Both sides are additions, so the resolution keeps main's whole
sceKernelGetLibkernelTextLocation_nid_postfixand this PR's whole export (the two conflict hunks inModuleInfo.cppinterleave inside the function bodies, so taking both sides of each hunk blindly would give one mangled function), and in the test keeps both blocks. I resolved it that way on top ofmain5efd09afc, initialised the new submodules (3rdparty/libusb-cmake,3rdparty/tracy), and rebuilt (binary newer than the source; nothing else in the 200-odd files frommainneeded touching):One thing the rebase makes visible: the two bodies run the same lookup (
GuestImages, the sameFill/dl_iterate_phdrsearch,segments[0], return 0) and differ only in the signature, the null-argument check, the message text, and how the result is stored (two out-parameters with a cast, against one{address, size}struct). fpPS4 defines this export as a call tosceKernelGetLibkernelTextLocation(ps4_libkernel.pas:349-355), so having it call the one already onmainis an option, if you want a single body.2. On the pre-rebase head: it builds, its test passes, and the test needs the change
(
-DFFMPEG_PREBUILT_DIRpoints at a sibling clone's already-unpackedffmpeg-9ac4cfd195f1.) Ten consecutive direct runs, invoked the wayctestinvokes it (argumentlibguest_module_fixture.so, working directorybuild/core/libs/prx/libkernel), exit 0 each.Control: implementation reverted to the parent (the
// unknown signaturestub back atcore/libs/prx/libkernel/Module/src/Module.cpp:244-249, the definition gone fromcore/libs/prx/libkernel/Module/src/ModuleInfo.cpp), test kept. The test aborts, exit 134, andctestreports0% tests passed, 1 tests failed out of 1: the stub'sNotImplemented_nid_no_patchthrows out ofmain.Two mutations of my own:
info.segments[1]in place ofsegments[0]at:445aborts 134, andstd::runtime_errorin place ofstd::invalid_argumentat:432aborts 134. A marker on the:105assertion confirmed it is the one that fires for the first. That assertion compares the export withsceKernelGetModuleInfofor the same main program, and the pre-existingRequire(handles.front() == self.id)atcore/libs/tests/GuestModuleInfo.cpp:72is what pins that the first guest image is the main program.3. #4524 is the same patch, and merging both breaks the build
Compared blob for blob against
bacf50be4:The only difference in
SceTypes.hppis where the six-lineInternalSegmentInfosits.git merge-tree --write-tree pr-4193 pr-4524exits 0 with no conflict, and the merged tree declares the struct twice, atcore/libs/SceTypes.hpp:233and:289:The overlap bot already lists #4524 for the shared export; what it cannot show is that the merged tree fails to compile. #4524 conflicts with
mainin the same two files. For context rather than as a recommendation: this PR is the earlier one (01:01:29Z against 14:21:49Z) and keeps screamm's authorship (2664fb07e), whilebacf50be4is authored by jagrat Singh. Which one closes is for the two of you.4. What
segments[0]is, and a dependency worth knowingFill(core/libs/prx/libkernel/Module/src/ModuleInfo.cpp:125-132) records the firstPT_LOADin program-header order. fpPS4's body (pinned04cefd43e6,ps4_libkernel.pas:338-339) returns the eboot's first segment, which on the four eboots inrea-work/unwrapped(PPSA03671, PPSA26344, PPSA28997, PPSA35169) is the text:p_offset 0x4000, vaddr 0, flags E. #4567 was merged as matching that behaviour (the merger: "first segment of the main program, 0 on success … same behaviour"), with the console's own value left recorded as unverified in its debt entry.For current relinker output the first
PT_LOADis that text:core/relinker/elfpatcher/src/general/ProgramHeaderLayoutBuilder.cpp:196-206pushes the kept title loads first and the offset-0 header block last among thePT_LOADs. Program headers fromreadelf -lWon relinked executables here:run-trails/app.elf(PPSA35169),run-gow/app.elf(PPSA28997) andrun-wolv/app.elf(PPSA03671), all relinked 2026-10-12, start withoff 0x4000 vaddr 0x0(the title text) and have the0x350-byte block atoff 0x0as the seventhPT_LOAD. The exception is an older relink:run/app.elf(PPSA26344, 2026-10-09) leads with a0x318-byteRblock atp_offset 0. I read program headers only; I did not call the export against these executables.So the answer depends on the relinker keeping that block out of first place. The tree already has a rule for skipping it,
p_offset == 0(ModuleInfo.cpp:197, inAddGuestSegmentBytes), if you ever want it not to. This applies equally to the sibling already onmain.5. Null output pointer: a convention question
Three older exports in this file return the library's own error for a null output pointer:
This export throws
std::invalid_argumentat:432, and:106pins the throw. So does the sibling #4567 just put onmain(sceKernelGetLibkernelTextLocation: null argument). Both conventions are now in the file, and the debt entry notes that a null result throws, in an entry that lists the console's behaviour as unknown, so this is a question and not a finding.6. The title bar
Your body is straight about this: no call observed, the console's value unverified, the import list as the only evidence. I can corroborate the kind:
tools/nid_names.pymaps the name to-YTW+qXc3CQ, and that literal occurs exactly once in thesce_module/libc.prxof each of the five title trees on this box (PPSA02929, PPSA26344, PPSA03671, PPSA28997, PPSA35169), counted withgrep -a -o. That is an import, not a call. The audit's figure of 44 I cannot check from here.What I could not check: the Windows arm (
Fill(address)at:437), the console's own value, and any title reaching the call.AI-assisted review; every number above comes from a command run here.
Hermes Agent 🤖 at your service
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:36:01Z.
Closing: #4524 implements the same export on top of
sceKernelGetLibkernelTextLocation(#4567) and merges cleanly, while this one conflicts with main inModuleInfo.cppandGuestModuleInfo.cpp.Pull request closed