fix(relinker): accept identical repeated dynamic tags in code analysis #14411
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14411"
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 roboterspinne on 2026-11-01T11:51:44Z.
What
Code analysis, which every
--windowsand--macosconversion runs on the executable (WindowsTlsBuilder.cpp:125,MacOsImage.cpp:294on26fa1212b8; line numbers below refer to it), rejects every repeat of a dynamic tag it records, also when both entries carry the same value:CodeInstructionCollector.cpp:87throwsCode analysis: duplicate dynamic tagas soon astags.emplacefinds the tag. The rest of the relinker treats an identical repeat as one tag and fails only on a conflict in a tag it reads:getTagValueinRelinkerPipeline.cpp:145-185(#10752, throw at lines 176-177),RelativeRelocationIndex.cpp:208-250(#7768) andRelrRelocations.cpp:17-19throwConflicting duplicate <NAME> tagsonly when a later entry differs, and the maintainer-merged #11299 and #11923 accept an identical duplicate relocation as applying once. #1938, which rejected identical repeats, was closed because "no title is shown with a secondPT_DYNAMICor repeated table tags, and rejecting identical duplicates could refuse an input the console loads"; this change relaxes a check instead of adding one. On the fixture oftest_rela_size.py, a secondDT_RELASZ24, twoDT_FLAGS8 or twoDT_DEBUG0 entries converted for Linux, with--lazy-bindingand withunused-filter=1, and failed on--windowsand--macoswithFAIL: Code analysis: duplicate dynamic tag (offset 0x470)or(offset 0x480).Code analysis: conflicting duplicate dynamic tagwith the offset of the later entry, matching the pipeline'sConflicting duplicatewording; an identical repeat keeps the first entry, which is the same value, so every latertags.atand the standard/SCEambiguous dynamic tagcheck (line 92) read what they read for a single entry. The skip rule forDT_NEEDEDand the SCE range and theinvalid dynamic segmentandunterminated dynamic segmentchecks are unchanged. This deliberately reverses what the description of #10752 stated, that Windows and macOS keep rejecting an identical repeat. No title is known to carry such a repeat; the case is that an input with an identical repeat converts for Linux and fails on Windows and macOS. A conflicting repeat of a tag the pipeline does not read, such asDT_INIT, still converts for Linux and fails on Windows and macOS. Left out on purpose: the guest module reader (GuestImageReader.cpp:89,Duplicate dynamic tag <n>) and the opt-in strict filter (StrictNidFilter.cpp:46,unused-filter=2) still reject identical repeats; they are separate follow-ups.test_rela_size.py(registered asrela_size, no CMake change): the same-valueDT_RELASZcase, which required the code analysis failure on Windows and macOS, now requires exit 0 and an ELF, PE or Mach-O output on the default and--lazy-bindingLinux,--windowsand--macostargets, withDT_RELASZ24 in both Linux outputs; twoDT_FLAGS8 and twoDT_DEBUG0 entries, tags the pipeline does not read, must convert the same way on all four. TwoDT_INITentries with 0x200 and 0x210, a tag only code analysis reads (line 235), must fail on--windowsand--macoswith exit 2, no output and the single lineFAIL: Code analysis: conflicting duplicate dynamic tag (offset 0x480).pr_overlap.py --branchfinds no shared lines with the open pull requests it can compare and cannot compare #10861, #12154, #12282 and #14107, which also changeCodeInstructionCollector.cppbut do not merge withmain. Checked by hand: a trial merge of this branch with each of them conflicts only in the files thatmainwith it already conflicts in (CodeInstructionCollector.cppfor all four, plusSyscallScanner.cpp,UnusedNidFilter/ControlFlowGraph.cpp,ConversionTests.cppanddocs/dev/debt/relinker.mdfor #10861), andtest_rela_size.pyis in none of them. #10861 rewrites the same tag check (line 87) and keeps rejecting identical repeats unless its newallowIdenticalDynamicTagsis set, so whichever of the two lands second has to settle that line.Tested
Windows 11, WinLibs GCC 15.2.0, Python 3.13.9, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Ninja, Release), on6527e2ff82(based on26fa1212b8;mainate67cc81869changed neither file and merges cleanly); synthetic fixtures only, no title or homebrew.ctest --test-dir build-relinker -R '^rela_size$' --output-on-failurewith the new test and the untouchedCodeInstructionCollector.cppof26fa1212b8fails with 8 entries: the three identical-repeat inputs on--windowsand--macosexit 2 withFAIL: Code analysis: duplicate dynamic tag (offset 0x470)(DT_RELASZ) or(offset 0x480)(DT_FLAGS,DT_DEBUG), and the conflictingDT_INITinput fails with the old message instead of the new one; the Linux targets already pass. With the change it passes (rela_size8.3 s,dynamic_segment5.3 s,optional_plt1.8 s).--windowsoutputs of the three identical-repeat inputs, run by hand on this host, exit with 42 as theoptional_pltfixture they are built from does.ctest --test-dir build-relinker -j 6: 552 tests, 540 passed,long_pathsskipped.select_testsand its three partsselect_tests_SelectGraphStateTests,select_tests_SelectBuildTestsandselect_tests_SelectArgumentTestsfail with the Windows symlink fixture'sFileExistsError, as onmainon this machine.annotate_module,check_main_sync, its partsCheckMainSyncHistoryTests,PathTests,EncodingTests,GitTestsandtrace_digest_TraceDigestTests_test_cli_rejects_invalid_event_fields_without_partial_outputtimed out while the machine ran at 99 % CPU from other builds; run again alone, the fourcheck_main_sync_*parts passed and the other three timed out again at their 20 s and 30 s limits. They are Python tests oftools/, which this change does not touch.python tools/check_conventions.py --base 26fa1212b8 --head HEADwith this title and description passed.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-11-01T13:43:58Z.
Review: COMMENTED
Reviewed — no blocking findings
Identical repeats of a dynamic tag are now accepted in code analysis, and the change matches how the rest of the relinker already treats them; the one open question is a policy reversal for maintainers, not a defect.
What I ran
6527e2ff82d023f0ee501bd8e29828c4d17a9a58, baseba627802e2210187d417deb64c8f2fed8e33011f./usr/bin/python33.11.2, no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14411 --output-dir /dev/shm/reviewer-run/precheck/14411python3 tools/pr_test_quality.py --root /dev/shm/reviewer-run/src2/14411 --json core/relinker/relinker/tests/test_rela_size.pyCodeInstructionCollector.cpp(tag map, ambiguous-tag check) andRelinkerPipeline.cpp(getTagValue).Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/14411/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check ba627802e2210187d417deb64c8f2fed8e33011f...6527e2ff82d023f0ee501bd8e29828c4d17a9a58/usr/bin/python3 tools/check_conventions.py --base ba627802e2210187d417deb64c8f2fed8e33011f --head 6527e2ff82d023f0ee501bd8e29828c4d17a9a58 --title fix(relinker): accept identical repeated dynamic tags in code analysis --body /dev/shm/reviewer-run/precheck/14411/pr-body.mdNo changed source or public header under core/libs/prx./usr/bin/python3 -m py_compile core/relinker/relinker/tests/test_rela_size.pyNo changed tools/ module has an existing sibling tools/tests/test_<module>.py suite./usr/bin/python3 tools/check_test_registration.py --scripts/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14411 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14411/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /dev/shm/reviewer-run/precheck/14411/head-6527e2ff82d0-b2000752/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14411/head-6527e2ff82d0-b2000752 --json core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp core/relinker/relinker/tests/test_rela_size.pyNo changed Python test module in tools/ can be run as a no-build base-source control.Manual checks: the test-quality helper reported 0 findings for
test_rela_size.py.Negative control
Not run. The relinker test needs a built binary.
Findings
Blocking: none.
Non-blocking:
std::map, so an identical repeat keeps the first entry and the laterambiguous dynamic tagcheck still sees one entry per tag. A conflicting repeat throwsconflicting duplicate dynamic tagwith the later entry's offset.Sources
github.com/boykopovar/AnyPS5@6527e2ff82/core/relinker/relinker/src/analysis/CodeInstructionCollector.cpp (L72-L92)Conflicting duplicatebehaviour in the pipeline at head:github.com/boykopovar/AnyPS5@6527e2ff82/core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp (L145-L186)Not verified
test_rela_size.pywas not run (needs a build), so the PR's expected outputs for the four targets are unconfirmed here.