Repository navigation
fix(relinker): reject a second PT_DYNAMIC segment - #10403
oneandonlydean merged 1 commit into
Conversation
The PT_DYNAMIC loop used the first header and ignored any later one, so the Linux target converted an input with two PT_DYNAMIC headers. A second PT_DYNAMIC now fails with "Multiple PT_DYNAMIC segments" at its file offset on every target.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
Checked manually: #8076 changes |
MarcZX10
left a comment
There was a problem hiding this comment.
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.
MarcZX10
left a comment
There was a problem hiding this comment.
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.
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(11e8ad2):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. fix(relinker): preserve imported ELF symbol types #10017 and fix(relinker): mask embedded data tables in inter-FDE gaps #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)