fix(relinker): collect reachable branch targets without signed overflow #11033
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11033"
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 mzaeemnasir on 2026-10-25T14:38:37Z.
What
CodeInstructionCollector::Collectadds a reachable instruction's branch displacement to the next instruction's address asstd::int64_t(CodeInstructionCollector.cpp:499). For a code segment mapped across 2^63 the sum overflows, which is undefined behaviour. The target is now added as an unsigned value, as the function-symbol sweep in the same collector (line 396) andControlFlowGraphalready do. Without a sanitizer the computed target is unchanged.This is the same class as #10653, at a site #10680 does not touch. #10861 also rewrites this line as part of a larger change. Order: this PR first, proposed to #10861's author here; #10861 then resolves the conflict by keeping its own version of the hunk. If its author prefers to land first, this PR is cut down to the test.
relinker_conversiongainsbranchAcrossSignedBoundary: a segment at0x7ffffffffffffff0whose entry at0x8000000000000000jumps back below the boundary.Tested
Windows 11 Home build 26300, MSYS2 UCRT64 GCC 14.2.0, CMake 4.0.0, relinker-only build.
ctest --test-dir build-relinker: 292/292 pass onmain3a2c51afdand with this change; 295/295 after rebasing ontomain5a2744c55e.relinker_conversionpasses in the signed-overflow trap build.-fsanitize=signed-integer-overflow -fsanitize-trap=undefined:relinker_conversionwith the new test traps (ILLEGAL) without the fix and passes with it.python3 tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyreports #10861 (same line, see above) and #8076 (not comparable, conflicts withmain; it adds new signed branch-target sums elsewhere in this file but does not change line 499).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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-25T14:38:47Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T14:40:55Z.
Review: CHANGES_REQUESTED
Requesting merge-order coordination for the confirmed open-PR conflict with #10861 before approval. I fetched both current heads and
git merge-tree --write-treereports a content conflict incore/relinker/relinker/src/analysis/CodeInstructionCollector.cpp, the line changed here. CONTRIBUTING.md requires agreeing the order with the other PR author and declaring a dependency when this PR needs that PR first. The body currently says either can rebase, but does not record an agreed order. Please coordinate with #10861’s author, then update this PR and rebase/test the chosen composition as needed. The exact-head local diff and conventions checks pass; the focused relinker test is still building, and the author-reported Windows test is not independently verified here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:19:11Z.
Review: APPROVED
Reviewed exact head 90a62a9f191c332612bb9a20ca4205fa34c2ab67. The unsigned addition implements x86-64 modulo address arithmetic for a signed branch displacement and avoids signed overflow. The regression places the instruction and target across the 2^63 boundary and checks both roots are collected. I compiled the changed collector and test translation units with GCC 12.2 syntax-only. The author reports the full relinker suite passing and a signed-overflow sanitizer negative control. Hosted conventions, intake, and labels pass; I did not independently run the full suite.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:35:52Z.
Review: CHANGES_REQUESTED
The focused regression passes locally: I configured the relinker-only Release build, built
relinker_conversion_tests, and ranctest -R '^relinker_conversion$'(1/1 passed). The code change and its boundary test look sound in isolation.The overlap blocker remains unresolved, so I cannot approve this PR yet. I fetched current heads for #11033 and #10861 and reran
git merge-tree --write-tree refs/review/11033 refs/review/10861; the composition still has a content conflict incore/relinker/relinker/src/analysis/CodeInstructionCollector.cpp. This PR's body says either branch can rebase over the other, but it does not record an agreed order or aDepends onentry. Please coordinate the order with #10861's author, declare the resulting dependency, then rebase and run the focused test on the chosen composition. This is the only blocker I found; it is a repository coordination requirement, not a defect in the unsigned-address change.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:36:00Z.
Review: DISMISSED
The focused regression passes locally: I configured the relinker-only Release build, built
relinker_conversion_tests, and ranctest -R '^relinker_conversion$'(1/1 passed). The code change and its boundary test look sound in isolation.The overlap blocker remains unresolved, so I cannot approve this PR yet. I fetched current heads for #11033 and #10861 and reran
git merge-tree --write-tree refs/review/11033 refs/review/10861; the composition still has a content conflict incore/relinker/relinker/src/analysis/CodeInstructionCollector.cpp. This PR's body says either branch can rebase over the other, but it does not record an agreed order or aDepends onentry. Please coordinate the order with #10861's author, declare the resulting dependency, then rebase and run the focused test on the chosen composition. This is the only blocker I found; it is a repository coordination requirement, not a defect in the unsigned-address change.Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-25T20:56:55Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.