fix(relinker): drop unwind ranges that begin inside a decoded instruction #20387
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20387"
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 oneandonlydean on 2026-11-15T04:01:14Z.
What
The relinker stopped on a PPSA03977 build with
Code analysis: Instruction truncated after prefixes (offset 0x3957a)at "Output image 19%". Address 0x3957a is byte 1 of ajmp rel32(E9 64 FE FF FFat 0x39579), and its0x64is the low byte of the displacement.Cause: an unwind function range whose begin lies inside an instruction that an enclosing function already decoded was decoded again from that byte, and its begin was also kept as a code root. A one byte range starting on the
0x64leaves a tail that is only a segment prefix, so the decoder throws and the FS prefix rule in the tail check turns the throw into a failed relink. A longer range from the same byte fails later withoverlapping instruction boundariesbecause the root decodes over the enclosing instruction.Fix:
CodeInstructionCollectordrops such a range and its root before decoding it. It only checks ranges that start before the end of an earlier range, so ordinary functions pay nothing. A range with no enclosing decoded instruction is rejected as before.The exact unwind data of the user's eboot was not available. The test builds the same bytes and ranges synthetically; which source produced the range in that build was not confirmed.
Tested
Linux, release build. New case
unwindRangeInsideInstructioninrelinker_game_patch_tests:E9 64 FE FF FFinside a function with a one byte range at the0x64(and a nested longer range) converts now. Without the change it fails withInstruction truncated after prefixes. A lone one byte range at the0x64is still rejected.relinker_conversion,control_flow_graphandrelinker_game_patchpass.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T04:41:43Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes blocks merging; the new range filtering is covered by synthetic conversion cases.
What I ran
Reviewed head
082070994d64a5aa54da43b1d104610d7a3cba9dusingrepo_read.py. I did not run build or test commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and test results reported in the PR description were not independently verified. The user's eboot and the source of its unwind range were not available for review. Both changed files listed in
manifest.jsonwere read; no files were excluded by the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T05:03:27Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
082070994d:tools/check_conventions.pypassed;git diff --checkclean.relinker_game_patch_testsbuilt cleanly.relinker_game_patch):core/relinker/relinker/src/analysis/CodeInstructionCollector.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by catminou4 on 2026-11-25T06:56:06Z.
Review: CHANGES_REQUESTED
Reviewed at
082070994d, relinker-only Release build (GCC, Ubuntu 22.04).4b5344fc89):relinker_game_patchpasses.main7a1c9bbccf:relinker_game_patchfails: The last case ofunwindRangeInsideInstruction({0x1200, 0x1209}, {0x1205, 0x120f}) is now accepted. Onmaintheoverlapping instruction boundariesthrow inCodeInstructionCollector.cpp(line 801) only fires whenspanHasFsPrefix, so this expectation is stale. WithCodeInstructionCollector.cppfrommainthe test fails as well, so I could not isolate the fix on currentmain.ctest: onlyrelinker_game_patchand the environmentaltools_headers_manifest).Not mergeable as is: rebase on
mainand update or drop the overlapping case.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T00:23:37Z.
Review: APPROVED
Reviewed — looks good
The change at head
715ec7213a00bfcda03dd0ef7b9c62661f9b9fe8adds filtering for unwind function entries that begin inside a decoded instruction; I found no verified blocking defect in the changed code. The prepared bundle reports tests, but I did not run them.What I ran
Read the prepared description, commits, manifest, diff, and both changed files at the pinned head using
repo_read.py. I did not execute tests or other commands.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the reported Linux release tests or independently check the behavior against the user’s eboot. The manifest lists two changed files and both were read:
core/relinker/relinker/src/analysis/CodeInstructionCollector.cppandcore/relinker/relinker/tests/GamePatchTests.cpp. No changed files were excluded by the prepared manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T00:27:35Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
e34cf942-77b6-4b88-bdd4-4bf824f6626dReviewing files that changed from the base of the PR and between
4b0f137c86and715ec7213a.core/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/tests/GamePatchTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:55:25Z.
Review: COMMENTED
Built this head with
ANYPS5_RELINKER_ONLY=ONand ranrelinker_game_patchon Linux. It passed, including the branch’s unwind-range regression inGamePatchTests.cpp.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.