fix(relinker): reject a second PT_DYNAMIC segment #10403
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10403"
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-23T21:34:52Z.
What
The
PT_DYNAMICloop inRelinkerPipeline::Relink()took the first header and stopped (break,RelinkerPipeline.cpp:109onmain), so Linux output silently ignored a secondPT_DYNAMICand converted with exit 0. The other readers already refuse it:RelativeRelocationIndex.cpp:172throwsMultiple PT_DYNAMIC segmentsand guest modules fail withDuplicate dynamic segment(GuestImageReader.cpp:52).PT_DYNAMICnow fails withMultiple PT_DYNAMIC segmentsat its file offset (RelinkerPipeline.cpp:106-107), the wordingRelativeRelocationIndex.cpp:172already uses. The check is in the pipeline, so all targets report it.main, Windows and macOS failed later withCode analysis: invalid dynamic segment(CodeInstructionCollector.cpp:74) and now report the pipeline message.PT_DYNAMICis read as before, and a missing one still fails withNo PT_DYNAMIC segment found.Tested
Ubuntu 24.04.5 x86_64, GCC 13.3, CMake 3.28, Python 3.13. Relinker-only Release build (
-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Ninja). Synthetic fixtures only, no title or homebrew.test_dynamic_segment.py: a newduplicatecase copies the fixture'sPT_DYNAMICinto a second program header. It expects exit 2,Multiple PT_DYNAMIC segmentsand no output on Linux,--windowsand--macos.convert()takes the modes as a parameter so this case also covers--macos; the existing cases keep Linux and--windows.main(11e8ad2934):dynamic_segmentfails atduplicate. Linux exits 0, while--windowsand--macosexit 2 withCode analysis: invalid dynamic segment.ctest --test-dir build -R '^(elf_header|dynamic_segment|input_magic)$'3/3 passed (dynamic_segment0.1 s).ctest --test-dir build -j2240/240 passed.fix/relinker-elf-type-allowlistandfix/relinker-linux-load-bounds: no conflicts,ctest241/241 passed. #10017 and #8076 also editRelinkerPipeline.cpp, at line 346 and later; this patch applies cleanly on top of both PR heads.python3 tools/check_conventions.py --base upstream/mainwith 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-10-23T21:59:13Z.
Review: APPROVED
Reviewed the three-line guard and the duplicate-header fixture. The pipeline now applies the same multiple-segment rejection already used for PT_SCE_DYNLIBDATA, and the test checks Linux, Windows, and macOS diagnostics plus no output. The hosted relinker matrix and conventions checks pass; full Linux and Windows product jobs are skipped by the repository workflow. No blocking issue found.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T22:07:42Z.
Review: APPROVED
Reviewed the duplicate-header check and its regression fixture. The loop now rejects a second PT_DYNAMIC with the existing diagnostic before replacing the first segment’s tags, and the new fixture exercises Linux, Windows, and macOS output modes. The reported 240/240 focused suite and 241/241 combined suite cover the change; hosted relinker jobs for Linux, Windows, macOS arm64, macOS x86_64, and ASan also pass. I found no blocking issue.