feat(relinker): analyze function symbols as code roots #15032
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15032"
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 AZLisme on 2026-11-02T11:09:58Z.
What
Adds the explicit
--function-symbol-rootsmode for ELF companion modules whose function-symbolst_sizevalues describe different code. The default strict conversion is unchanged. Fixes #14893 without identifying a title, path, function name or fixed stub pattern.The mode preserves symbol metadata, validates defined function entries as executable and file-backed, and follows the existing control-flow roots and unwind ranges during Windows/macOS code analysis. It ignores only function-symbol extents; data, TLS and FDE bounds remain checked. In this mode, actual fall-through is followed through zero bytes, direct and resolved indirect targets are validated, and valid targets in another executable segment are analyzed. Unresolved computed jumps retain the existing discovery limits, recorded in
docs/dev/debt/relinker.md.The ELF symbol-table specification distinguishes a symbol address from its optional size. This is an explicit compatibility option for incorrect sizes, not a claim that the original metadata is correct or that all indirect control flow is known.
Integrated frozen main
1e24993fa3a7da25e8fc27152af654687ba64552in current headbb619a8abbc5ded501c4f368c61d3616e493922f. Preserve main's Windows executable exports, output name and TLS index while applying function-root extent handling to exported functions. Preserve both main's plain/SCE test split and this PR's target/rejection split; all eight groups retain their assertions and original timeouts.Tested
bb619a8abbc5ded501c4f368c61d3616e493922f, Linux x86-64/GCC 16.2.1 Release, relinker-only: built successfully. All 717 registered CTests passed, with no skips, across the full run and 14 corrected-environment retries. The initial 14 failures came from the incomplete CMake on PATH and sandbox restrictions on local HTTP/filesystem tests; the complete CMake and permitted test environment passed all 14 without source or assertion changes. All three function-symbol-root groups, eight guest None groups and Windows executable-export tests passed.bb619a8aplus frozen main1e24993f: Linux 717/717, macOS ARM64 706/706, macOS x86-64 under Rosetta 706/706, TLS-only ASan 34/34, all passed without skips. Windows job 127105049968 passed 720/721, withweb_releasetiming out at 20.24 seconds; no skips. All eight None groups, three roots groups and Windows executable-export tests passed there. The Windows aggregate remains failed; there is no proof that main also fails or that it is a flake. That packaging test, its registration/20-second timeout and the three tools it exercises are unchanged from frozen main. Earlier runs keep their original input scopes.web_releaseCTest in 3.17 seconds, with the unchanged 20-second timeout and all 34 internal unittests passing. Product source/tree and its main parent were checked. This was one isolated test on a Windows runner, without the original suite's concurrent workload; it does not erase the upstream timeout or make the full Windows job pass. A maintainer rerun of the failed upstream job has been requested because this account has READ access.git diff origin/main --checkandpython3 tools/check_conventions.py --base origin/mainpass. The overlap check was completed before opening. Known control-flow discovery and noreturn limitations remain indocs/dev/debt/relinker.md.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's 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-11-02T11:18:11Z.
Review: COMMENTED
Reviewed — no blocking findings
I reviewed all 28 changed files at head
11a32e87545102a39063593df201ce0e0506f8b3; source inspection found no blocker, and the hosted checks were still queued at the final refresh.What I ran
Reviewed head
11a32e87545102a39063593df201ce0e0506f8b3against base3c3b3cda739f9eb00a07fae50d94a3af5f6fb8f2. The exact head previews cleanly against currentmain. Environment: Debian 12 Linux, Python 3.11.2, GCC 12.2.0. I did not configure or build.The checks selected from the exact head found no test-quality heuristic findings. The precheck wrapper could not find the optional local heuristic script in its isolated snapshot; I reran that heuristic against the exact-head test and CMake files.
Results
Unedited outputs from the checks
Negative control
Findings
Blocking
None found in the complete source review.
Non-blocking
None.
Sources
Not verified
To get this to a good state
No code change is requested from this review. Once the hosted checks finish, I will re-check this exact head and its results, then approve if the required checks pass; if the head changes, I will review the new diff and rerun the affected checks.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T08:57:54Z.
Review: COMMENTED
Re-checked — new head, no blocking findings
I reviewed the full new head after its preserving merge from
main; the source and test changes have no blocking findings, but the new-head relinker checks are still queued, so this is not an approval.What I ran
Reviewed all 28 changed files at head
ad9c12659454d099fc989663202e5777cef0ef1aagainst base4f41f4c375f5abb487dbd184fbc150f31994d762. The exact-head stack preview is clean. Environment: Debian 12, Linux x86_64, Python 3.11.2, Git 2.39.5, GCC 12.2.0 available; I did not compile with GCC.Results
Commands and unedited output
Precheck summary:
The test-quality helper was then run from the workspace against the exact-head snapshot:
Hosted status at the final refresh:
Negative control
I did not run a local control because the test requires an exact-head relinker binary. The author reports that strict mode rejects address
22792while root mode converts the executable and companion; I did not independently reproduce those runs.Findings
Blocking
None found in the 28 changed files.
Non-blocking
The new-head relinker matrix, conventions check and label check are still pending. The reported 683-test Linux run is author-provided evidence, not a run I performed.
Sources
Not verified
I did not run a build, relinker tests, the test's negative control, Windows/macOS execution, or PS5 behavior. Hosted relinker jobs remain pending.
To get this to a good state
Please let the queued checks complete and address any failures. I will re-check this head and its results when those checks finish or if the head changes.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T09:39:44Z.
Review: APPROVED
Reviewed — approved
The opt-in
--function-symbol-rootsmode builds, its new tests pass and fail where they should, and the default strict conversion path is unchanged; I found nothing blocking.What I ran
Head
fd2d90bf77fa5b1bd0019b39c9af72a59a661aab,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree252127109c2b7452e83afaa79a422568c9b9ab95(merged with--no-ff). Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.Results
git diff --checkcheck_conventions.pyunwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group, which fails onmaintoo); no new failures or timeoutsfunction_symbol_roots_{executable,module,rejected}guest_none_relocations_{linux,windows,macos,rejected}test_guest_none_relocations.py(defaultall)gs_trap_entry_roots,windows_tls_protected_entries, all 34tls_function_coverage_*Focused ctest summary
Negative control
I restored all 24 changed production
.cpp/.hppfiles frommainand rebuiltrelinker:executable,module,rejected) failed. For example:AssertionError: (... 'overrun-linux-roots/output', 1, '', 'FAIL: unknown option: --function-symbol-roots\n'). Onmain, therejectedgroup fails only because the option is unknown.baselinemode, which runs only the strict-path assertions, passed onmainforexecutableandmodule. So the fixtures reproduce the strict rejection that the new mode is meant to avoid.On the merged tree, I also changed only the
strictFallThroughargument inCodeInstructionCollector.cpp:542tofalseand rebuilt.function_symbol_roots_rejectedthen failed withAssertionError: ('zero-tail', 'windows', 0, ''), so the new fall-through-through-zero-bytes behaviour is covered.After restoring the merged files and rebuilding, the three groups pass again, and
git status --porcelainis empty.Findings
Blocking
None.
Non-blocking
core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp:566-571andcore/relinker/relinker/src/analysis/UnusedNidFilter/ControlFlowGraph.cpp:171-174. In root mode, the analysis follows fall-through afterCallandIndirectCall, and it no longer trims trailing zero bytes. If a call to a noreturn function is followed by zero padding or non-code, conversion stops withInstruction truncatedorfall-through is not executable. This fails closed and only affects the opt-in flag. However, the debt entry (docs/dev/debt/relinker.md:5) lists only unresolved computed jumps as the limit. Suggestion: add one clause to the debt entry saying that noreturn calls are assumed to fall through in this mode.core/relinker/CMakeLists.txt:649-653splitsguest_none_relocationsinto four CTests to fix a macOS x86_64 timeout. That test script and its limit are identical onmain. The split itself looks correct: the ungrouped invocation still passes locally, and every group finishes in under 1 s here. Still, it is unrelated to function-symbol roots, and CONTRIBUTING asks for one topic per pull request. It is small and test-only, so I am not asking for it to be removed.Not verified
windows_image_runner.pyinside the test; the macOS outputs were only checked structurally.guest_none_relocations_*tests.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T11:00:06Z.
Review: APPROVED
Re-checked — approved
The only change since my last review (
fd2d90bf77fa) is commit59e8f2e00e47, which rewrites one debt entry to record the noreturn-call limitation I raised. Production and test sources are unchanged, and the checks and focused tests still pass.What changed since my last review
59e8f2e00e47docs(relinker): record noreturn call analysis limitchanges one line indocs/dev/debt/relinker.md, and nothing else (git diff --stat fd2d90bf77fa..59e8f2e00e47: 1 file, +1 −1).fd2d90bf77faand for59e8f2e00e47, both merged withmain4f41f4c375f5: Linux 686, Windows 690, macOS ARM64 675 and macOS x86_64 675 tests passed. I treat these numbers as author-reported. The Tested section was updated to match.What I ran
Head
59e8f2e00e477f1a3dd4e656de0408498887d3c5,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged treedb1bb0df9064f93453080ac51669841c31cfd5fa. Debian 13 VM, GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.git diff --checkcheck_conventions.pyunwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group, which also fails onmain); no new failures or timeoutsfunction_symbol_roots_*(3) andguest_none_relocations_*(4)I did not rerun the negative control. The tests and production sources are byte-identical to
fd2d90bf77fa, where the control already failed as expected (see my previous review).Previous findings
docs/dev/debt/relinker.md:5now says: "Calls, including indirect calls, are assumed to return, so a noreturn call followed by zero padding or non-code can be rejected." This matches the behaviour I described. The entry now states the gap first, as CONTRIBUTING asks.guest_none_relocationssplit is a separate topic. Still open, but I accept it as is. It is unchanged since my last review, and the author's CI report says it removed the macOS x86_64 timeout. I am not asking for a change.New findings
Blocking
None.
Non-blocking
None.
Not verified