fix(relinker): accept an identical duplicate pointer relocation in the strict filter #11923
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11923"
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 rooklz on 2026-10-27T12:40:51Z.
What
9673868d5f(fix(relinker): accept an identical duplicate relocation in Windows executables) settled the semantics of a RELA entry repeated with the same target, type and addend: it writes the same value twice, so applying it once is equivalent. The Windows relocation builder and the code analysis accept such a duplicate, distinct entries at one target are still refused, and the Linux output already passed it through (measured trigger: Forever Launcher's game-child.bin, PPSA99030, repeats one RELATIVE entry).The strict unused-NID filter (
unused-filter=2) re-readsDT_RELAon its own and was missed by that fix:StrictNidFilterrefuses a second pointer relocation at a slot unconditionally, so the same ELF converts withunused-filter=0andunused-filter=1but fails withunused-filter=2on "Strict filter: overlapping pointer relocations".Build()now records a pointer relocation only when its slot is new or its target is identical to the recorded one — the same comparison9673868d5fadded toCodeInstructionCollector— and still refuses a distinct entry at one slot and a slot that an import relocation already owns.Tested
macOS 26.2, Apple M5 (arm64), CMake/Ninja,
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON(Python 3.13). Base:eece5da035(upstream/main), tested head:0f75fd0662.End-to-end against the relinker binary on this Mac, before/after:
GLOB_DATplus two identicalRELATIVEentries at one slot:unused-filter=1converts;unused-filter=2failed before withStrict filter: overlapping pointer relocations (offset 0x4e08)and converts after, with the sameStrict filtering totalandFunction graphreports as the single-entry image — the duplicate changes no reachability outcome;Conflicting relative relocation targetsat 1,Strict filter: overlapping pointer relocationsat 2).Tests, red on the base source with only the tests applied, green at head:
core/relinker/relinker/tests/test_duplicate_relocations.py: the strict-filter duplicate now converts and reports identically to the single-entry image; a conflicting duplicate is still refused;StrictNidFilterTests.cppduplicatePointerRelocations: an identical duplicate pointer relocation keeps its import throughFilter(); a conflicting duplicate and a pointer relocation at an import slot are refused.Full relinker ctest 361/361;
check_conventionsandpr_overlapclean. Host-only change to the relinker; no title, GPU or console involved. No performance claim.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-10-27T12:45:57Z.
Review: COMMENTED
I reviewed the duplicate-slot condition and the added C++/end-to-end cases. The filter now keeps a repeated RELATIVE relocation only when the recorded addend matches, while still rejecting conflicting duplicates and import-slot overlap. Locally on Linux with GCC 12.2 Release,
strict_nid_filter_testspassed and CTest passedduplicate_relocationsplusstrict_nid_filter(2/2). Hosted Ubuntu and ASan are also green; Windows and both macOS relinker jobs were still running/queued when I checked. I will revisit the final status before approval.