fix(relinker): accept matching defined relative symbols #6357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6357"
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 MarcZX10 on 2026-10-15T13:04:16Z.
What
Some PS4
libc.prxfiles useR_X86_64_RELATIVErelocations with a nonzero symbol index. The six reported entries reference defined function or object symbols whosest_valueequals the nonnegative relocation addend. The relocation still resolves to the module base plus that addend, so the guest reader can canonicalize this exact form to a symbol-zero RELATIVE entry, and code analysis can follow the same target.The reader rejects undefined symbols and defined symbols whose value differs from the addend. The change is related to #3093. It does not claim the remaining PS4 relinker work in that issue is complete.
Tested
Linux x86-64, GCC 12.2.0, Release, relinker-only build:
relinkertarget.ctest --test-dir /tmp/AnyPS5-3093-build --output-on-failure -R '^(guest_none_relocations|none_relocations)$'— 2/2 passed.guest_none_relocationscovers SysV and SCE dynamic tables, function and object symbols, and generated ELF, PE and Mach-O outputs. Native execution was tested on Linux only.python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEADpassed.Checklist
main; no open PR implements this matching-defined-symbol case.mdfiles or images addedImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T13:19:46Z.
I manually checked the shared
GuestImageReader.cppchange against #6112. #6112 addsreadLifecycleArray(32, 33, image.PreInitArray)in the lifecycle-array parsing block. This PR only changes theR_X86_64_RELATIVErelocation validation/normalization block earlier in the function. The diff hunks do not overlap and I found no behavioral interaction between preinit-array parsing and relative-symbol relocation handling.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T18:42:45Z.
Review: COMMENTED
Ran this on macOS, including executing the Mach-O output under Rosetta 2, since the PR's native load check only runs on Linux.
Setup: Apple M2 Max, macOS 27.2, head
32fe3aa8bmerged without a commit ontomainb7cedd900(clean). Relinker-only Release builds for arm64 and for x86_64 under Rosetta (/usr/bin/python33.9.6).pr_overlap_tools,release_package,linux_fixed_base) fail the same way onmain(Python 3.9 issues unrelated to this PR).guest_none_relocationswith only the test change applied tomainfails on both arches withRELATIVE relocation has a symbolforrelative-defined-symbol; with the fix it passes.Execution of the macOS output: for
baseline,relative-defined-symbol,relative-defined-objectandmixed, each with SysV and SCE dynamic tables (8 cases), I converted the test's module with--macos, put an empty x86_64libkernel.prxdylib inlibs/to satisfy the@rpath/libkernel.prxload command, anddlopenedmodule.prx.guest.prxfrom an x86_64 Python under Rosetta. In all 8 cases dyld rebased the image to a slid address,shared#guestreturned 42, the slot atTARGETheld the slid function address, and calling through that pointer returned 42. Same result with the arm64-built and the x86_64-built relinker.So the canonicalized symbol-index RELATIVE entry is rebased correctly by dyld on macOS, not only by the Linux loader.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:34:26Z.
Thanks for checking the generated Mach-O on Apple silicon and under Rosetta 2. That adds useful execution coverage beyond the Linux load test.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T18:39:10Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/guest/GuestImageReader.cppcore/relinker/relinker/tests/test_guest_none_relocations.pycore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/guest/GuestImageReader.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T20:51:50Z.
I checked the overlap notice against both heads. #6977 independently contains the same matching-defined-symbol
R_X86_64_RELATIVEacceptance inGuestImageReader.cppandCodeInstructionCollector.cppas this PR; its larger PS4 integration therefore overlaps this PR’s production behavior. #6977 does not appear to carry this PR’s focusedguest_none_relocationsregression fixture. The #6447 hunk is separate: it adds overflow checking forheader.Offset + relative. I’ll leave both PRs open per the standing instruction; please preserve the focused regression coverage or coordinate the merge order if #6977 lands first.Imported from boykopovar/AnyPS5. Originally posted by DProkos on 2026-10-18T19:44:00Z.
Windows check of
32fe3aa8bmerged onto currentmain(48d61f53b, clean merge).Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7 UCRT, Ninja, Release,
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON, Python 3.11.0.guest_none_relocations: passed.Negative control: with
CodeInstructionCollector.cppandGuestImageReader.cpprestored tomainand the updated test kept,guest_none_relocationsfails on therelative-defined-symbolcase (non-SCE, Linux output):FAIL: ...\sce_module\module.prx: RELATIVE relocation has a symbol.Not run: titles or homebrew.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-18T20:59:49Z.
Second-title data point: Hasbro Family Fun Pack (CUSA03312, my own dump) needs this PR, on Linux and Windows.
Relinker-only Release build, Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7. Starting from
mainf3059421f, I merged, in this order: #7660, #6619 (a9fa0e8b0), #5138 (5f5641732), #6381 (6f8d9a09d),3b158c1e4from #6977, #6354 (81561867f), #6357 (32fe3aa8b), #6684 (ab9d21afc) and #6618 (bf06a8e5c). With that stack, the Linux and--windowsconversions of the eboot and its 9 bundled modules complete. I then rebuilt the relinker once per member with only that member left out. Without this PR, both targets stop inlibc.prx:With #5138 also in the stack, the two conflict in
GuestImageReader.cpp. I resolved it by accepting either form: a zero-value section symbol (#5138) or a defined symbol whose value equals the addend (this PR).The other members each stop at their own step, so every one of them is needed for this title; the whole table is on #6977.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T22:09:28Z.
Thanks for the second-title report. The leave-one-out conversions show Hasbro Family Fun Pack needs this relative-defined-symbol handling on both Linux and Windows within the composed dependency stack, and the omission control stops at the reported relocation in
libc.prx. This adds title-level evidence alongside the existing relinker tests; I’ve recorded it.