fix(relinker): reject a second PT_GNU_EH_FRAME segment #13914
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13914"
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-10-31T12:37:31Z.
What
On
b7d3fd3c52(line numbers below refer to it) an executable or a guest module with twoPT_GNU_EH_FRAMEheaders converts on every target.RelinkerPipeline::Relinkrejects a secondPT_DYNAMIC(Multiple PT_DYNAMIC segments, line 120) and a secondPT_SCE_DYNLIBDATA, and the guest image reader rejects a second dynamic segment and a second SCE dynamic data header (GuestImageReader.cpp:55and59), but neither countsPT_GNU_EH_FRAME. Linux output keeps both headers, and the Windows writers add one.ehmetasection per header (WindowsPePatcher.cpp:76,WindowsGuestModuleWriter.cpp:106). The runtime then picks different tables per target: the Linux readers keep the lastPT_GNU_EH_FRAMEthey see (core/libs/prx/libc/src/exception/Unwind.cpp:193,core/libs/prx/libkernel/Module/src/Module.cpp:223), while the Windows readers stop at the first.ehmetaof an image (Unwind.cpp:507,core/libs/prx/libkernel/Module/EhFrame.hpp:103). An executable and a bundled module with two identicalPT_GNU_EH_FRAMEheaders converted with exit 0 for Linux,--windowsand--macos, writing the output and the module.PT_DYNAMICcheck, the pipeline throwsMultiple PT_GNU_EH_FRAME segmentsat the second segment'sp_offset, before any analysis or output, on every target.Duplicate EH frame segment, next to its other duplicate-header checks, so a bundled module fails the same way for Linux, Windows and macOS.PT_GNU_EH_FRAMEheader counts, as everyPT_DYNAMICheader does for the existing check, also an identical repeat and one withp_filesz0: the Linux writer would keep such a header, while the Windows writers already fail on it withCannot map an empty ELF address range(WindowsLoadImage.cpp:97). A single header and modules or executables without one are unchanged. Real titles with two such headers are not known.pr_overlap.py --branchfinds no shared lines with the open pull requests it can compare and cannot compare #10792 and #10861, which also changeRelinkerPipeline.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 (SyscallScanner.cppfor #10792;CodeInstructionCollector.cppanddocs/dev/debt/relinker.mdfor #10861), andRelinkerPipeline.cppmerges cleanly.Tested
Windows 11, WinLibs GCC 15.2.0, relinker-only build (
-DANYPS5_RELINKER_ONLY=ON, Ninja, Release), on3d5a51c470(based onb7d3fd3c52;mainatb8f0a6b202changed none of these files and merges cleanly):linux_eh_frame_headergainsduplicate_headers: its executable fixture (entry 0x100) with a secondPT_GNU_EH_FRAMEheader must fail withMultiple PT_GNU_EH_FRAME segmentsand write no output, and a bundledconsumer.prxwith two file-backedPT_GNU_EH_FRAMEheaders must fail withconsumer.prx: Duplicate EH frame segmentand write neither the output nor the module, each for Linux,--windowsand--macos. Built with the pipeline and guest reader ofb7d3fd3c52, all six cases convert with exit 0 and write their files; on3d5a51c470all six fail as expected and the test passes.ctest --test-dir build-relinker -j 5on54f981f596(3d5a51c470changes only the fixtures of this test): 543 tests, 537 passed,long_pathsskipped;annotate_module, a Python test oftools/annotate_module.pythat does not run the relinker, timed out under the parallel load and passes alone in about 15.5 s (it sits close to its 20 s limit on this machine);select_testsand its three partsselect_tests_SelectGraphStateTests,select_tests_SelectBuildTestsandselect_tests_SelectArgumentTestsfail with the Windows symlink fixture'sFileExistsError, as onmainon this machine; this change touches nothing undertools/.python tools/check_conventions.py --base b7d3fd3c52with this title and description passed on3d5a51c470.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-31T12:38:16Z.
Review: APPROVED
Reviewed — looks good
The exact head
3d5a51c4707797d788391bdfe8716f110bf17bfarejects duplicatePT_GNU_EH_FRAMEheaders before writing executable or guest-module outputs across the Linux, Windows, and macOS relinker modes.I ran
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13914against base60bdb061356db736928eee431cd8bd4c9ba68036: diff, conventions, Python syntax, test registration, and mergeability passed. The author reports that all six targeted duplicate-header cases fail as intended on this exact head after a Windows relinker-only build. I did not build or run CTests locally; the full-suite results in the PR description are from a different head and include unrelated existing failures. Hosted eligibility, conventions, intake, and label checks were still running at my last refresh.