fix(tools): preserve inactive SELF program headers #14534
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14534"
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 Queuse on 2026-11-01T15:30:39Z.
What
Normalize unused PT_NULL entries before placing decrypted SELF segments. Their undefined offsets must not reject an otherwise valid input or cause unused file bytes to be copied. Active segment bounds and overlap checks remain intact. The ELF gABI defines PT_NULL entries as ignored.
Tested
Head
9145ab72e10543ccd455e3247d4012a6fc20bc42, refreshed against mainf2d874c1fdccf781c0fa5d86619bb5dd8894b958.python -m unittest tools.tests.test_unwrap_selfran 81 tests: 78 passed and 3 existing platform skip(s).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 BunnyFl on 2026-11-02T01:16:04Z.
Review: APPROVED
Windows 11, Python 3.14.7. Head
9145ab72e1merged into upstream/main93dbd0f82a:tools/tests/test_unwrap_self.py: 81 tests OK (5 skipped on this platform).tools/unwrap_self.py,test_null_segment_fields_do_not_affect_conversionfails (6 subtest failures).One effect worth knowing, not a blocker: the normalization mutates
headersin place, and the output program header table is written from those dicts (unwrap_self.py~:396). So PT_NULL entries now come out as all zeros instead of copying the input's fields. The gABI says they're ignored, so that's fine, and the new test pins it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T05:01:33Z.
Review: COMMENTED
Reviewed — no blocking findings
place_segmentsnow zeroes the fields ofPT_NULLprogram headers before placement, so stale values in unused slots no longer affect the conversion. The new test sets each field of aPT_NULLslot to all ones and checks that the output does not change; its offsets match the ELF64Phdrlayout (p_flagsat 4,p_offsetat 8, and so on throughp_alignat 48). The hosted run has nounwrap_selfresult for this head, so the test did not run there. One edge in the placement loop is raised below as a question.What I ran
9145ab72e10543ccd455e3247d4012a6fc20bc42; basef2d874c1fdccf781c0fa5d86619bb5dd8894b958. 2 files, +20/-0:tools/unwrap_self.py(+3) andtools/tests/test_unwrap_self.py(+17).place_segmentsfunction at this head (lines 159-200), and the trailing-segment logic that follows it.unwrap_selfresult appears for this head's check runs.Results
PhdrlayoutPT_NULLslots ignored after the changeplace_segments(lines 159-164)PT_NULLheadersPT_NULLheader (non-blocking)unwrap_selftest (hosted)unwrap_selfresult for this headRead-only check output
Precheck was not run; no PR-head Python is run here. Conventions: passed. Hosted:
gh api repos/boykopovar/AnyPS5/commits/9145ab72e10543ccd455e3247d4012a6fc20bc42/check-runs.Negative control
Not run here. Running the Python tests from this head is not permitted in this session.
Findings
Blocking
None.
Non-blocking
headers[target]["size"] == sizedoes not check the header type. A zeroedPT_NULLheader has size 0, so a zero-size record that points at it can now set itssourceand, through therecordedlist, become thelastheader for the trailing placement. Before this change such a header kept its original size. Please confirm that a zero-size record cannot place aPT_NULLheader, or excludePT_NULLin that check.Sources
github.com/boykopovar/AnyPS5@9145ab72e1/tools/unwrap_self.pygithub.com/boykopovar/AnyPS5@9145ab72e1/tools/tests/test_unwrap_self.pyNot verified
To get this to a good state