fix(relinker): report a NONE entry in DT_JMPREL as an unsupported PLT relocation #11041
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11041"
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 harisibrar1 on 2026-10-25T14:54:48Z.
What
An
R_X86_64_NONEentry in DT_JMPREL fails with a misleading error. The same happens when DT_JMPREL points at zeroed bytes:That message appears at
unused-filterlevels 0 and 1, on Linux, Windows and macOS output, even when nothing is being filtered.In
RelinkerPipeline.cpp's relocation reader, theR_X86_64_NONEcontinueruns before theplt && relType != R_X86_64_JUMP_SLOTcheck. So the NONE entry is skipped, its PLT slot is left without a JUMP_SLOT, and the dynamic section builder fails later with the filtering message. Every other non-JUMP_SLOT type in DT_JMPREL is already rejected at its entry with "Unsupported PLT relocation type (offset …)".This moves the PLT check above the NONE
continue, so a NONE entry in DT_JMPREL is reported at its offset like any other non-JUMP_SLOT type. A NONE entry in DT_RELA is still skipped, as before; the existing-data-symbol-nonecases cover that.This also changes what
unused-filter=2accepts, as @thepoppfish found: on main, strict filtering could compact away an unused DT_JMPREL table that held only NONE entries (or zeroed bytes) and then convert the file. Now the type check runs while the table is read, before any filtering, so that input is rejected at every filter level. That's intended: FreeBSD 11.4's loader refuses any PLT relocation that isn'tR_X86_64_JUMP_SLOTorR_X86_64_IRELATIVE, NONE included, in bothreloc_pltandreloc_jmpslots, whether or not the slot is ever called. So a binary with such a table wouldn't load there either; the relinker now says so instead of converting it.Tested
Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON) ofd008392c54(currentmainmerged in).test_jmprel_table_bounds.pygains-none-in-pltcases for Linux and Windows output: a NONE entry in DT_JMPREL must fail with "Unsupported PLT relocation type" at the default filter level and withunused-filter=1andunused-filter=2. The ordinary DT_RELA NONE (-data-symbol-none) and valid JUMP_SLOT (-plt-symbol-valid) controls in the same file still convert.jmprel_table_boundspasses in 2 runs.RelinkerPipeline.cpp,jmprel_table_boundsfails on the new case.none_relocations,overlapping_relocations,optional_plt,optional_relaandnull_symbol_relocationscouldn't run here: Smart App Control blocked their freshly built fixtures (WinError 4551), no assertion failures. @thepoppfish's native run of the previous head passed those groups 10/10, and this push only adds test cases and mergesmain.tools/check_conventions.py --base origin/mainpasses.Overlap
pr_overlapreports #10971 (@roboterspinne) at the end of the same test loop (test_jmprel_table_bounds.pyL131); whichever lands second needs a small text merge. #8076 sharesRelinkerPipeline.cppbut conflicts with main and doesn't touch these lines.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:10:01Z.
Review: APPROVED
Reviewed exact head
e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1. Moving the DT_JMPREL type guard before the NONE skip makes NONE entries fail at the same validation point as other unsupported PLT relocations while preserving the DT_RELA skip. The added Linux/Windows output cases exercise that distinction. Hosted Linux, Windows, macOS arm64/x86_64, ASan and conventions checks pass; product-specific jobs are skipped by path policy. The noted test-file overlap with #10971 is limited to adjacent assertions and does not block this change.Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-25T15:22:59Z.
Review: COMMENTED
Additional native Windows validation and one scope clarification for exact head
e38c2e1e7a4b5989d31d2a82aeb47f53cc05c4e1against main3a2c51afd2ee6a824cd3a294912c65e6bbf2b768. The relocated guard gives the intended early diagnostic, and the ordinary DT_RELA NONE skip remains intact. This is a comment review because the matrix also found an acceptance change that is worth stating explicitly.Strict-filter scope: with
unused-filter=2, an immutable code segment returning immediately and an unused NONE-only DT_JMPREL table, main succeeds and emits an output; this head exits 2 withUnsupported PLT relocation typebefore filtering. This happens for both the ordinary NONE entry and a completely zeroed 24-byte entry, using standard/SCE table tags and Linux/Windows/macOS output (12 paired acceptance changes). Main's strict-filter PLT compaction removes the unused table, so those inputs do not reach its later missing-JUMP_SLOT error. With filter levels 0 and 1, the same inputs do fail on main with the misleading message, as described in the PR (24 paired diagnostic improvements).Is rejecting the previously accepted strict-filter case intentional? If so, please include it in What/Tested and add a strict-filter regression, so the PR is described as enforcing the DT_JMPREL type rule before compaction as well as correcting diagnostics. This observation does not establish that NONE entries in DT_JMPREL must be supported; it distinguishes the actual old/new behavior from a diagnostic-only change.
Validation on Windows 11 build 26200, GCC 16.2.0-6 UCRT, CMake 4.3.1/Ninja 1.13.2, Python 3.14.7:
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON, targetrelinker: 88 build steps each, both successful. No source substitution or mixed binary was used.rela_size,none_relocations,guest_none_relocations,guest_relative_section_symbols,overlapping_relocations,optional_plt,optional_rela,null_symbol_relocations,jmprel_table_bounds,copy_relocations. Head 10/10 passed, 42.07 s total; base 10/10 passed, 41.90 s total, each at-j2. These are separate local results, not a speed comparison. The tests include native Windows fixture execution and inspection of other output formats. I did not reproduce the author's Windows security-blocking failure on these selected tests, and changed no security settings.test_jmprel_table_bounds.pyagainst the exact main executable gives the expected assertion failure at the first newlinux-plt-symbol-none-in-pltcase: return 2 and the old missing-JUMP_SLOT message, rather than the new expected message. The head's registered version passes.0x1400in this fixture. Both ordinary DT_RELA NONE entries (including an out-of-range ignored symbol index) and valid canonical JUMP_SLOT controls continue to convert successfully, with 36 complete output files byte-for-byte identical between base and head. The 12 acceptance changes and 24 corrected errors above are recorded separately; the baseline is not falsely reported as rejecting every NONE case.Tested executable SHA-256 values:
Complete native before/after matrix replay
Prepare checkouts at the two exact commits above and build each separately:
Save the script below in a separate scratch directory and run with native Git and the selected compiler's runtime directory on PATH:
The first command asserts all 144 results and writes a JSON record including executable hashes; expected summary is 24 corrected errors, 12 strict-filter acceptance changes and 36 identical valid pairs. The second is the expected failing negative control. The script uses the committed fixture builder, constructs the segment layout needed for strict filtering, and runs real converter subprocesses in a disposable scratch directory. It does not edit either checkout or fetch anything.
AI-assisted review and scratch fixture: yes (OpenAI Codex).