test(relinker): add bounds and termination tests for dynamic tags and segment reading #12009
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12009"
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 slopgobblercobbler on 2026-10-27T17:01:07Z.
What
Adds unit test coverage in
core/relinker/relinker/tests/ElfReaderBoundsTests.cppfor bounds and termination validation inElfReader:ElfReader::ReadDynamicTags: tests that a dynamic header with offset/size extending past file bounds or overflowing throwsRelinkerException("Dynamic segment out of bounds", dynamicHeader.Offset).ElfReader::ReadDynamicTags: tests that a dynamic segment lacking a terminatingDT_NULLtag throwsRelinkerException("Unterminated dynamic segment", dynamicHeader.Offset), and verifies correct tag extraction when terminated.ElfReader::ReadSegment: tests that a segment header with offset/size extending past file bounds throwsRelinkerException("Segment offset out of bounds", header.Offset), and verifies correct byte retrieval for valid segments.Tested
elf_reader_bounds(all 34 cases passed including dynamic tag and segment bounds tests).python tools/check_conventions.py --base upstream/main --head HEADpassed with 0 findings.d36fb789b1merged onto86fb985abb.ElfReader.cppkilled; full ctest passed 361/361.elf_reader_boundspassed 1/1.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 rooklz on 2026-10-28T02:20:59Z.
Review: APPROVED
Reviewed on macOS (arm64, relinker-only Release build) @
d36fb789b1. The PR is test-only, so the question is whether the new cases catch regressions in the guards they target. I checked that with mutation probes onElfReader.cpp: one mutant at a time, rebuilding onlyelf_reader_bounds_tests.ElfReader.cppReadDynamicTagsrange check removedOffset + FileSize > size(wraps)return tags>= 16→>= 8(partial entry read)ReadSegmentrange check removedThe file on main catches 0 of 8 mutants and this PR catches 8 of 8. So the coverage is new, and the
max-15 / 32overflow rows are what catch the wrapping-sum mutants (M2/M7). The source was restored afterwards and the tree is clean.elf_reader_boundspasses; fullctest -j 8passes 361/361check_conventions.py --base upstream/main: all passedpr_overlap.py: no overlap with open pull requests737f17291ais an ancestor of main. NeitherElfReader.cppnor this test file has changed on main since then (0 lines), andgit merge-treeagainst current main (cccdaa2734) is clean.LGTM.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-28T05:01:11Z.
Review: APPROVED
Reviewed
d36fb789b1b918b05d329bd5641008ac58f2b4f6— approve. The added reader cases exercise out-of-bounds/overflowing dynamic and data segments, missing DT_NULL termination and valid reads.Fresh Windows/GCC 15.2 Release build: elf_reader_bounds passes 1/1 on both exact head and author base. Reviewed the three new case groups and their exception-message assertions. This is new coverage for existing checks; the production reader is unchanged and a failing old-production control is not expected. The inspected hosted Windows job merged this head and passed the same registered test. No full product or game execution is claimed.
Pull request closed