feat(relinker): route ps5-payload-dev pathconf stub to libkernel export #10792
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10792"
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 SushiBirb on 2026-10-25T01:00:02Z.
What
Route ps5-payload-dev SDK numbered syscall stub 191 (
pathconf) to the imported libkernelpathconfexport (oc98+zOImus) across both the main executable and bundled guest modules.ps5-payload-dev compiles libc++ syscall stubs with raw syscall instructions (
48 C7 C0 BF 00 00 00 49 89 CA 0F 05 C3, 13 bytes) rather than delegating to libkernel wrappers. Homebrew binaries like Apotris and their bundled modules importpathconffrom libkernel (viaoc98+zOImus/pathconf), but the relinker rejected the raw stub.When
pathconfis imported, the relinker rewrites the 13-byte stub into an indirect tail jump (FF 25 <disp32>followed by 7 NOPs) directly referencingpathconfs GOT relocation address inRelinkerPipelineandGuestModuleBuilder. This does not require--trap-sdk-syscall-stubs. Ifpathconfis not imported, the stub is trapped asUD2if--trap-sdk-syscall-stubsis passed, or refused if omitted. Other unrouted syscall numbers (such as 9) remain refused.Tested
Linux (Arch Linux x86_64). Built Ninja relinker targets and ran complete test suite:
syscall_scanner_testschecking numbered stub detection, trap fallback, and rejection without import.test_guest_syscall_route.pychecking Linux ELF, Windows PE, and macOS Mach-O outputs across both the main executable and bundled guest modules (sce_module/*.prx), verifying the 13-byteFF 25tail jump rewrite, displacement calculations, unimported error/trap handling, and that a game patch overlapping the routed stub is rejected (with a control patch past the stub still routing).python3 tools/check_conventions.py --base origin/mainpassed cleanly.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T01:09:54Z.
Review: DISMISSED
The main-executable route is covered, but the same scanner is also used for every bundled guest module in
GuestModuleBuilder::Build(around theScanCodeSectionForSyscallsloop). That caller does not pass aroutedStubsoutput vector and only applies returned trap offsets. Consequently, an exact syscall-191 SDK stub in a bundled PRX still reaches the forbidden-syscall path when trapping is disabled, or is replaced withUD2when trapping is enabled, even if the module importspathconf. The new route is therefore not applied consistently to all executable code processed by the relinker. Please route this case in guest modules too, using the module's matchingpathconfimport/relocation, and add an integration regression with the stub in a bundled module; alternatively, document and substantiate that ps5-payload-dev can emit this stub only in the main executable and narrow the PR's stated scope.Validation on this exact head: relinker-only Release build completed with GCC 12.2;
guest_syscall_routeandsyscall_scannerpassed 2/2.git diff --checkandtools/check_conventions.pypass. A complete local CTest run completed 262/265:pr_overlap_encodingfailed because the build directory was outside the Git worktree;masked_store_loweringandamd64_only_converterterminated withSIGILLon this host. I did not verify those three failures against base. The two tests directly covering the new main-executable path passed. Hosted conventions, intake and labels checks pass; no hosted product test result was present when I checked.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T01:57:36Z.
Review: COMMENTED
Thanks for adding bundled-module routing and the cross-target integration fixtures. I rechecked the exact updated head
124980967196c7af6b53b76a5030298b05d61856:GuestModuleBuilder::Buildnow passes routed stubs to the module path, resolves the importedpathconfrelocation, applies the indirect tail jump, and has no-import failure/trap cases. This addresses my earlier review finding, so I am withdrawing that request for changes. Local validation:tools/check_conventions.pyandgit diff --checkpass, and the new Python test compiles withpy_compile. I could not configure the focused CMake build fromcore/relinkeralone because its CMake file expects project-leveladd_test_executable; I did not run the integration executable locally. Please keep the new fixture’s import/relocation layouts aligned with any parser changes.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T03:04:29Z.
Review: DISMISSED
The updated head fixes my earlier guest-module routing finding: the author added the import lookup, rewrite, trap/refusal cases and cross-format integration fixture. I have not independently run the updated integration executable; the 265/265 result is author-reported. One repository-rule blocker remains: the overlap check marks this PR and open #9549 and #10479 on the same
SyscallScanner.cpplines, while all three current checklists sayDepends on: none. CONTRIBUTING.md requires the authors to agree on merge order and record it withDepends on. Please coordinate with both authors and update the affected checklist lines. Current visible checks are conventions and labels pass; the build/test workflow has no current product result. I have not modified or rebased your branch.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T03:15:28Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The exact current head still routes through arbitrary matching
pathconfrelocation slots, which can make the new indirect jump load a non-function address or a truncated value.What I ran
Reviewed head
37d8c7579ffaa58669ee7fb829e1aa38fc0b54fe. PR base is1526c6aeaeee69361a2e89ab8bdabd68d0d707be; the currentmaintip wasdc9dc7eaaeaf99b1c491d426e68bb999def3da16, and the PR merge preview against that tip was clean. Environment: Debian 12 x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ tests were run.Results
git diff --checkmain, and current dependency heads are not included in dependent headstools/pr_test_quality.pyhelperCommand output
Negative control
Findings
Blocking
FindPathconfImportprefersR_X86_64_JUMP_SLOTbut falls back to any matchingNidReference;FindGuestPathconfImportAddresssimilarly falls back to any matching nonzero relocation type. Both then emitFF 25to load 8 bytes from that relocation address as a function pointer. For example, anR_X86_64_64slot containsS + A, so a nonzero addend routes to an interior address; narrower relocation slots are not valid 8-byte function-pointer slots. The fixtures only exercise zero-addendJUMP_SLOT. Please restrict both paths to relocation kinds and symbol forms that are verified to provide a full-width function pointer (and reject unsupported matches), then add main-executable and guest-module regressions for unsupported relocation types and a nonzeroR_X86_64_64addend.Non-blocking
#10479and#9549. The current stack report says #9549 conflicts withmain; resolve the dependency stack before landing, then refresh the overlap/dependency check. This is not the basis for the change request.Sources
Not verified
To get this to a good state
Restrict the route selectors to safe function-pointer relocations and add the two regression cases above in both executable and guest-module coverage. I will rerun the same checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T08:06:22Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
4030a8bc8c599211fc906d87e2fd20b86f289be3using the prepared diff and pinned reader. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full contents and added lines of the changed files were not all read, so this review is incomplete. Excluded by the prepared review folder: none. Read:
review/description.md,review/commits.md,review/manifest.json,review/diff.patch,review/README.md; inspected diff portions for the scanner, main pipeline, guest module builder, tests, and documentation. The remaining test diff and full changed file texts were not read. Reported build, test, and convention checks were supplied by the author and not run here.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T06:31:36Z.
Review: COMMENTED
Reviewed — no blocking findings
The routing implementation and its changed documentation/tests were reviewed at head
2ec85f2191dc45d352c9f22a54c391af513fb836; the diff shows no verified blocking defect, but I could not run checks here.What I ran
No commands were run; the review interface provides read-only access to the prepared review materials and repository reader. The author reports 265/265 ctest tests passed and the conventions check passed; these results were not independently verified.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build, test suite, conventions check, and runtime behavior were not run. The changed files reviewed were
core/relinker/CMakeLists.txt,core/relinker/relinker/include/relinker/domain/ISyscallScanner.hpp,core/relinker/relinker/src/analysis/SyscallScanner.cpp,core/relinker/relinker/src/guest/GuestModuleBuilder.cpp,core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp,core/relinker/relinker/tests/SyscallScannerTests.cpp,core/relinker/relinker/tests/test_guest_syscall_route.py,docs/dev/debt/relinker.md, anddocs/user/USAGE.md. No changed file was excluded from the prepared diff.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by catminou4 on 2026-11-25T06:20:25Z.
Review: COMMENTED
Reviewed the merge of this branch into current
main(3cab484efb) on Linux x86_64, relinker-only Release build (GCC).ctest -R syscall(7 tests, including the newguest_syscall_routeand the extendedsyscall_scanner) passes.ctest -j8: 1116/1117 pass. The one failure,tools_headers_manifest(test_hash_rejects_changes_that_preserve_file_size_and_mtime), is intools/, which this PR does not touch.pathconf, not a title-specific value. The 13-byte stub becomesjmp [rip+disp32]through the import's GOT slot plus 7 NOPs, with JUMP_SLOT preferred over GLOB_DAT/R_X86_64_64. Without an import it traps under--trap-sdk-syscall-stubsand fails with a clear message otherwise. Other numbers are still refused.Points to address:
RelinkerPipeline.cppnow also mirrors ordinaryUD2syscall traps intotextSectionforindex == 0. That changes the existing trap path, outside the pathconf routing. Split it out, or name and test it in the PR body.GamePatch::CheckOverlapscall that the guest-module path does, so a game patch over the stub is not detected there.FindPathconfImportandFindGuestPathconfImportAddressduplicate the name/NID matching (pathconf,oc98+zOImus,pathconf_nid_postfix). One shared helper would keep them in sync.Builds and its tests pass. Mergeable once the unrelated
textSectiontrap change is split out or justified.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T16:30:21Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and included tests support the stated routing behavior, though I did not run the checks.
What I ran
Read the prepared diff and targeted source at head
beb57b2878ccfb3d89b5bc4cff25fcf656f3bba7. No build or tests were run. Commands: none.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build, tests, convention check, physical console run, or generated binary behavior was verified in this review. I read all changed files listed in the manifest:
core/relinker/CMakeLists.txt,core/relinker/relinker/include/relinker/analysis/PathconfImport.hpp,core/relinker/relinker/include/relinker/domain/ISyscallScanner.hpp,core/relinker/relinker/src/analysis/SyscallScanner.cpp,core/relinker/relinker/src/guest/GuestModuleBuilder.cpp,core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp,core/relinker/relinker/tests/SyscallScannerTests.cpp,core/relinker/relinker/tests/test_guest_syscall_route.py,docs/dev/debt/relinker.md, anddocs/user/USAGE.md. No changed files were excluded by the manifest.To get this to a good state
Nothing is required.