fix(relinker): report PLT stubs replaced after linking #18085
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18085"
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 eliasbruno124-dev on 2026-11-10T11:06:58Z.
What
Some dumps carry PLT stubs that were overwritten after linking: the stub's
jmpthrough its GOT entry is replaced by inline code or by a jump to code placed in the segment's padding, so the import of that entry is no longer called. #12123 describes two titles whose bundledlibc.prxhas such a stub jumping to an inline_umtx_opsyscall; the relinker then reports onlyForbidden syscall instruction at code offset 0x116c84, which does not say where the instruction comes from. A stub replaced bymov eax, 0; retconverts without any message at all.Report every replaced stub of the executable and of each bundled module during the conversion, with the bytes that restore it through the existing
--patchesmechanism:When the syscall scan refuses an instruction in the code such a stub jumps to, before that code's first return or jump, the error names the stub:
This is the general diagnostic offered as option 2 in #12123; the relinker does not learn the inline helper and converts replacements exactly as before. The PLT header is located by its
push/jmpthroughGOT+8andGOT+16; stubiis expected at header + 16 * (i + 1) with ajmpthroughGOT + 24 + 8 * i. A stub that differs is reported with its 6-byte jump, or with all 16 bytes when itspush index; jmp headertail differs too. A table in which no stub has the linked form is not reported, so an unknown PLT layout stays silent. No output byte changes: only messages and the text of that one error.docs/user/USAGE.mddescribes the line beside the patch file format.No maintainer has chosen between the two options in #12123 yet, so this does not close it. @B-Howell offered to write option 2 there; no branch or PR for it exists, and this one can be dropped if theirs is preferred.
Tested
Windows 11 Pro 10.0.26300, MSYS2 MinGW-w64 GCC 16.2.0, CMake 4.4.5, Ninja, CPython 3.12.14, Release,
ANYPS5_RELINKER_ONLY=ON,BUILD_TESTING=ON.70aab1bf93, whole relinker-only suite withctest -j 5:mainpasses 859 of 860 tests, this change 861 of 862 (the two new tests). The one failure is the same in both runs:vulkan_validation_gate_commands, whose symlink-loop case cannot create a symbolic link without the Windows privilege (WinError 1314); #16558 addresses it.39bac5d055as25f32d517d; nothing undercore/relinkeror indocs/user/USAGE.mdchanged in between. Full rebuild and suite again: 861 of 862, the same single failure.replaced_plt_stubschecks the finder directly: a linked table, no relocations, no PLT header, a table longer than its segment and a table without one linked stub report nothing; a 6-byte replacement, a 16-byte replacement and a jump are reported with their addresses, GOT entries and both byte strings; the cause is given for an instruction reached from the jump target and withheld after a return, inside an instruction, before the target and past the segment.replaced_plt_stubs_conversionruns the relinker for Linux and Windows output: a linked executable prints nothing; replaced stubs in an executable are reported and it converts; a module whose stub jumps to a syscall is refused with the stub named in the error and no output written; the same module converts without a report once a patch file restores the stub and overwrites the helper; a syscall behind a return is refused without the cause. Run against the relinker built frommain, the test fails at its first report check.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Title files, conversion only (
--windows --to-intel, SELF containers unwrapped withtools/unwrap_self.py), 22 PS5 titles with 142 ELF files in total:main70aab1bf93: 20 convert, 2 are refused at the same instruction. 5 titles get reports, 17 stubs in all; the other 17 titles print none. A separate script that parses the same files independently (36,665 linked stubs, 17 replaced) lists the same 17 addresses.sce_module/libc.prx(SHA-256b3e1a95e…1d0bef) prints the line quoted above and the conversion stops with the extended error;eboot.binreports two more stubs (TViD1EZXkNI, a jump to0x4370eb7, andVANhIWcqYak, 16 bytes of inline code). A patch file holding the three reportedexpected/valuepairs plus one entry that overwrites the now unreferenced helper at0x116c50passes--verify-patches(4 applicable) and converts the title with the syscall scan on (5 modules).mainrefuses the same input.libc.prxstub and refusal. Its unwrappedlibc.prxhas SHA-256e0143155…85234f, the hash reported for Minecraft in #12123.eboot.bin(mov eax, 0; ret,mov byte [rdi], 1; xor eax, eax; retand two 16-byte replacements). Both convert, as onmain, now with the reports.eboot.bin; itslibc.prxhas no replaced stub and converts, unlike the PPSA08329 copy of #12123.Not tested: Linux and macOS hosts, the web converter, and launching any title. Whether the runtime implements the imports a restored stub calls again was not checked. The provenance of these dumps is not established here.
Overlap:
tools/pr_overlap.py --branch fix/relinker-replaced-plt-stubsdid not finish on this machine (its diffs fetch blobs on demand in a partial clone, and the connection was dropped in two runs), so the comparison was made directly against the 1,986 open pull request heads it had fetched on 2026-11-10. 76 of them change a file this branch changes; a trial merge (git merge-tree) of this branch with each adds conflicts for four. #14107 registers a test on the line next to the one added here incore/relinker/CMakeLists.txt; both lines stay. #10792, #10861 and #11525, which already conflict withmain, change lines this branch changes around the syscall scan: #10792 and #10861 inGuestModuleBuilder.cpp,RelinkerPipeline.cppand the same CMake list, #11525 inGuestModuleBuilder.cpp. None of the four reports replaced PLT stubs; whichever lands later resolves the conflict. The branch merges cleanly intomain2c41a032c6, which was not built here.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)