fix(relinker): handle overlapping relocation tables #6607
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6607"
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 jweidenh on 2026-10-15T22:42:05Z.
What
An ELF file can include its PLT relocations in the range described by
DT_RELAand also name them throughDT_JMPREL. The relinker currently reads those shared entries twice: executable conversion rejects them as duplicateJUMP_SLOTrelocations, guest-module parsing rejects overlapping targets, and Windows/macOS code analysis rejects duplicate pointers to defined functions.Process each shared source entry once, keeping it in the PLT pass to preserve slot ordering. Validate that intersecting tables share whole 24-byte entries; distinct entries that target the same location still encounter the existing conflict checks. This covers executable and guest-module inputs with SysV or SCE dynamic tags and Linux, Windows, and macOS output.
LLVM's x86-64 combined-relocation fixture generates the motivating layout with
.rela.dyn : { *(.rela.dyn) *(.rela.plt) }; its linker implementation documents the overlapping ranges. No real-title compatibility claim is made.Tested
185fa9687, rebased onto main atfcde2cf95. macOS arm64, Apple Clang, Release relinker-only build: all 202 tests pass. The nested CMake test required Ninja on PATH and passed on rerun.Duplicate JUMP_SLOT relocation. An independent Windows validation also confirmed that reverting the fix makes the regression fail.tools/check_conventions.py --base origin/mainandgit diff --checkpass.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 github-actions[bot] on 2026-10-15T23:30:02Z.
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/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/pipeline/RelinkerPipeline.cppcore/relinker/CMakeLists.txtcore/relinker/CMakeLists.txtcore/relinker/relinker/src/analysis/CodeInstructionCollector.cppcore/relinker/relinker/src/guest/GuestImageReader.cppcore/relinker/relinker/src/pipeline/RelinkerPipeline.cppcore/relinker/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by DProkos on 2026-10-18T19:43:59Z.
Windows check of af1a15622 merged onto current
main(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.overlapping_relocations: passed (3.0 s).Negative control: with
CodeInstructionCollector.cpp,GuestImageReader.cppandRelinkerPipeline.cpprestored tomainand the new test kept,overlapping_relocationsfails on the first case (alias, non-SCE, executable, Linux output):FAIL: Duplicate JUMP_SLOT relocation for the same original .rela.plt slot (offset 0x740).Not run: titles or homebrew.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by DProkos on 2026-10-19T19:12:03Z.
Windows re-check of the rebased head
185fa9687merged onto currentmain(585075cb7, 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.overlapping_relocations: passed (3.3 s).Negative control: with
CodeInstructionCollector.cpp,GuestImageReader.cppandRelinkerPipeline.cpprestored tomain,overlapping_relocationsstill fails on its first case (alias, non-SCE, executable, Linux output), as before the rebase.Not run: titles or homebrew.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T08:38:46Z.
Re-checked against current main (new null-symbol relocation handling and header cache in
CodeInstructionCollector.cpp): the changes touch different regions from this PR's, the merge is clean and the code is the head I reviewed. Merged.