fix(relinker): analyze referenced code beyond SCE scan boundaries #10861
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10861"
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 Felipebmaitan on 2026-10-25T06:02:38Z.
What
SCE scan cutoffs can omit explicitly referenced code, leaving TLS instructions unchanged or forbidden syscalls unchecked. Follow supported entry/lifecycle/function/control-flow roots beyond the cutoff and use the discovered ranges for syscall checks and Windows/macOS TLS processing. Strong code roots inside recognized data tables retain the tested refusal.
Current head
ef92693f7218066d9eb983d1c4bb4171994daabamerges mainbab5bc6b9828b24b799add9dac6b768365f82125into published6f07b2b376aaf3e7c5e53bef4719e0a4048c27c6, preserving published history and authorship. This addresses the integration part of Dean's November 11 request and adriadam10's review.The resolutions keep main's LEA code-pointer/data classification with this PR's narrow-address reference protection and separate ordinary/authoritative traversal; retain numbered pathconf-191 routing with main's SDK-stub diagnostics and interrupt-table handling; and register both the routing and new address-data regressions. Main's deprecated-option documentation and this PR's routing documentation are combined. Existing jump-table masking, function-symbol roots, generated-trap continuations and strong-root regression remain.
Merge order: #10792 lands first, then #10861. The pathconf-routing prerequisite remains bundled until it lands; it is not being split out or presented as a separate implementation. #10479 and #9549 have now landed in main. No other author's branch was modified and no new author agreement is asserted.
Tested
Windows 11 Pro 10.0.26300, Ryzen 7 9800X3D, supported WinLibs GCC 15.2.0 r7, Python 3.11, Ninja Release, relinker-only. Main and candidate builds were serialized with at most two compiler jobs.
Exact head
ef92693f7218066d9eb983d1c4bb4171994daaba: full registered relinker suite 281/281 passed, zero failures/skips, 113.81 seconds. This includessce_referenced_code_*, code extent/gaps, relative jump tables,syscall_scanner, SDK/guest syscall routing/traps,code_analysis_address_data, function-symbol roots, strong-root conversion controls and TLS coverage. Windows-native execution is included where registered; Linux/Mach-O format checks do not establish guest execution on those OSes.Pinned main
bab5bc6b9828b24b799add9dac6b768365f82125: the 19-test focused SCE/code-analysis/syscall/function-root/control-flow selection 19/19 passed, 7.83 seconds.python tools/check_conventions.py --base origin/mainandgit diff --check origin/main...HEAD: pass.Refreshed overlap scan: 1,569 open heads, 71 shared-file candidates, exit 2. Direct rows include the declared #10792 prerequisite and shared-line changes in #14411/#18085; 35 base-conflicted comparisons remain inconclusive. No blanket overlap clearance or new merge-order agreement is claimed. Read-only composition with newer main
752c0f776bfa689bac02aca3c30afac4b0b8378dis clean; no files undercore/relinkerchanged between the pinned and newer main.Remaining conversion evidence: the requested fresh Sonic Superstars PPSA06888 and Dead Cells PPSA15552 comparison is pending. Their original
games/andbuild-relinker/resume-20261107/inputsdirectories are absent from the replacement checkout. Current input locations have been requested. The November 7 result (six bundle pairs, 198 byte-identical output files) applies only to its recorded old head/main; it is not reused as evidence for this integration. The separately unnamed gate-image manifest remains unavailable.No title gameplay, console behavior, fresh native Linux/macOS execution, GPU or performance qualification. Fresh hosted checks and collaborator re-review remain pending. Requesting adriadam10, oneandonlydean and MarcZX10 again was rejected by GitHub:
Felipebmaitan does not have the correct permissions to execute RequestReviewsByLogin. A collaborator must request the re-review; no review was dismissed.Executed relinker commands and artifact hashes
SHA-256: candidate converter
5b2931b9851c4b8e92ddb572ae9b9d2f5f5d8950a8ef5cd0b54313ec2c553a57; main converter182c67ed433ed2e9c3526fe19471192ed9fc8098e6def47a50b1979f2808e00e; candidate CTest log7e09d6fb748126797f0de230a2cc3dcaaf067107b2f3ae90a22f19892fecd022.Overlap notification reviewed: November 13, 23:21 UTC
The refreshed bot report adds no overlap relative to the pre-push scan. The remaining direct peer heads are unchanged: #14411
6527e2ff82d023f0ee501bd8e29828c4d17a9a58, #1808568df14da9cdf15ee9b79f71aa7e30719c604e6de.Inspected their shared changes. #14411 changes the public code-analysis policy for identical dynamic tags; this branch currently relaxes that check only in its internal auxiliary scans. A later composition must retain the chosen public policy, conflicting-value rejection and referenced-code traversal. #18085 adds replaced-PLT diagnostics around the syscall scan; a later composition must preserve those diagnostics alongside this branch's routed-stub output and tail scan. Neither supplies a helper this head requires, so no new functional dependency is established by these shared lines.
#10792 and #11628/#11661/#11689/#11698 disappeared from the report but are all confirmed OPEN at unchanged heads. Their absence is not evidence of a merge or clearance. #10792 remains the declared predecessor. The 30 remaining base-conflicted comparisons are inconclusive; no combined-runtime pass or new author ordering agreement is claimed. This notification requires no source change or repeated runtime tests.
Checklist
Based on current
main; no other open PR implements the same functionsOne 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 under Silent stubs in their library's technical debt fileNo notes, investigation
.mdfiles 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: #10792
Fixes: none
Unblocks: none
GPUs tested: n/a
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T06:08:16Z.
Review: DISMISSED
I reviewed the exact head
f1b6e32c18f7de1606dc3956ac27388dd9761d3c. The relinker-only Release configure and full build pass on this Linux host. The eight focused SCE/extent/scanner tests pass, including all three newsce_referenced_code_{linux,windows,macos}cases. The full relinker CTest suite passes 178/180;masked_store_loweringandamd64_only_converterterminate withSIGILLon this Xeon E5-1620 v2 host, and neither test's source is changed here, so I cannot attribute those two failures to this patch. Hosted eligibility, conventions, intake, labels, Ubuntu/macOS relinker and ASan checks pass; Windows relinker was still pending at my check. Product jobs are skipped by path policy.I found one repository-rule blocker in the overlap with #10792. Although this PR's body says merge-order coordination and composition testing remain necessary and the new scanner interface must preserve #10792's guest routing, its checklist currently says
Depends on: none. I tested the two current heads withgit merge-tree --write-tree; the composition has content conflicts incore/relinker/relinker/include/relinker/domain/ISyscallScanner.hppandcore/relinker/relinker/src/analysis/SyscallScanner.cpp. Please agree a merge order with #10792's author and update the affected checklist line(s) to show the dependency, then rebase and rerun the focused route/scanner tests on the composed result. The PR does merge cleanly with currentmainby itself; this request concerns the confirmed open-PR composition conflict.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T06:12:02Z.
Review: COMMENTED
CI update for the exact head remains green: the Windows relinker job has now completed successfully. Together with the already-passing Ubuntu/macOS relinker matrix and relinker ASan, all four hosted relinker platform jobs and ASan pass. The local focused tests and full-suite result are recorded in my review above; the two local
SIGILLfailures remain limited to unchanged instruction-lowering tests on this host. The only outstanding review request is the confirmed composition conflict with #10792 and the missing agreed dependency/order in the checklist.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-26T23:01:50Z.
Review: CHANGES_REQUESTED
This conflicts with
mainin code, not only in docs, so it needs a rebase from you before it can go further:core/relinker/relinker/src/guest/GuestModuleBuilder.cpp:397andcore/relinker/relinker/src/pipeline/RelinkerPipeline.cpp:387:mainnow has the relative jump table masking (RelativeJumpTables.cpp,unwindRanges,scanCodemasked with0x90,hasEhFrame/sceImagesplit) in the same blocks where this PR addshasCodeTailand the tail scan. Please combine them so the masked buffer is what the syscall scan and the new referenced-code scan both see, and rerunsce_referenced_code_*plus the jump-table tests on the result.docs/dev/debt/relinker.md:mainhas an entry saying code after the last unwind function or PLT is not analyzed ("a TLS access in it is not rewritten ... a function symbol or init/fini array entry pointing into it fails the conversion"). This PR changes exactly that, so that entry has to be rewritten to what remains true after the change, next to theRelativeJumpTablesentry (keep both).ISyscallScanner.hppandSyscallScanner.cpp(as @MarcZX10 found withgit merge-tree). Agree the order with its author and put it inDepends onin the checklist (currentlynone); after the rebase, rerun the guest routing and scanner tests on the composed result.The rest (CI on the relinker matrix, the negative control and the homebrew runs from @wachi35676) looks good; I did not find other problems in the diff. Happy to look again once it is rebased.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T09:43:29Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
ef92693f7218066d9eb983d1c4bb4171994daaba. No merged-preview check against main.description.md,commits.md,manifest.json,files.jsonand all ofdiff.patch(2,515 lines, 30 files).Results
Findings
Blocking
None.
Non-blocking
core/relinker/relinker/tests/test_sce_code_extent.py:249changes thesce-entry-after-codecase for the Windows and macOS targets. The call previously expected a successful conversion and now expectsUnsupported Windows/macOS guest TLS instruction(helper attest_sce_code_extent.py:167-168). The description does not mention this narrowing. Fix: state it in the description or in the debt file.core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp:303makesaddStrongRootthrow for any strong root inside a recognized data table.core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp:421routes the ELF entry point through it. Before,addRootsilently ignored such roots.ConversionTests.cppcovers entry,DT_INITandDT_FINI, so the behaviour is tested. The description (description.md:5) should say these roots were previously ignored and are now refused.Not verified
check_conventions.py, overlap scan) were not reproduced.retis replaced by a jump into libkernelpathconf), and the claim that routing preserves the stub's semantics. Not measured.pe_bytes_at,elf_bytes_at,elf_loads,guest_fixture,main_fixture, and thelinux=keyword onno_tail_fixture) were not checked at head.GuestModuleBuilder.cppmasks relative jump tables only inside the code range beforeFindSceCodeEnd. Tail bytes stay unmasked inscanBytes. WhetherScanReferencedTailForSyscallscan decode table bytes as code was not traced.ValidateSyscallRoutesandScanReferencedTailForSyscallseach rerun the fullCodeInstructionCollectoranalysis. Not measured.Files: the 30 files in
files.jsonreviewedwere read through their diff hunks. No full file text was read.files.jsonlists no excluded files; the rule patterns are*lock*,*.min.*,dist/*,build/*,*.svg.Sources
github.com/boykopovar/AnyPS5@ef92693f72/core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp (L303)github.com/boykopovar/AnyPS5@ef92693f72/core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp (L421)github.com/boykopovar/AnyPS5@ef92693f72/core/relinker/relinker/tests/test_sce_code_extent.py (L248)To get this to a good state
Nothing is required. The points under Findings are optional.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:10:06Z.
Review: COMMENTED
Built the exact head in relinker-only mode.
sce_code_extentand the Linux, Windows, and macOS referenced-code output tests passed on Linux. Native Windows and macOS execution were outside this run. A trial merge againstmainat67962e3245conflicts in the code collector, syscall scanner, and PE patcher, among other files.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.