fix(tools): keep p_align for segments unwrap_self copies outside load segments #7820
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7820"
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 parl0v on 2026-10-19T08:59:04Z.
What
tools/unwrap_self.pycopies a segment that does not sit inside a PT_LOAD into its own region, but that region was laid out with alignment 1. On real dumps the comment segment (PT_SCE_COMMENT,p_align0x10) therefore lands right after the last load segment, and the version segment (PT_SCE_VERSION) right after it, at offsets that breakp_offset % p_align == p_vaddr % p_align. In the eboot of one title the comment segment goes to 0x1c92418, while the inner ELF has it at 0x1c8e420. The module docstring already says every region is copied to an offset that satisfies the rule.These regions now use the segment's own
p_vaddrandp_align, like the load segments (a zero or non-power-of-twop_alignstill lays out with alignment 1, as before). Load segment placement and bytes do not change; only the comment and version offsets move and the file grows by a few bytes of padding. The relinker does not read either segment (GuestImageReaderskips them andSegmentFilterdrops them), so its output does not change.Tested
Windows 10 x64, Python 3.13.
python -m unittest tools.tests.test_unwrap_self: 20 tests pass. The newtest_segments_copied_outside_the_load_segments_keep_their_alignmentfails onmainin both subcases (8 != 0 : 0x6fffff00for a comment segment after a 0x88-byte load,0 != 4 : 0x2for a recorded segment with a vaddr).sce_modulelibraries and 15 bundled modules of one title, plus the eboot andsce_module/libc.prxof PPSA15552. Onmain, 16 of the 25 outputs have a comment or version segment that breaks the rule (20 headers). With this PR every program header withp_align> 1 satisfies it. Every load and dynamic header and every segment's bytes are identical tomain's output.sce_modulelibraries (--windows --to-intel) frommain's output and from this PR's output with the same relinker build. Both runs succeed, and the executable and all 7 guest modules are byte-identical.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchreports no overlap with open pull requests.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 adriadam10 on 2026-10-20T02:19:25Z.
Checked the placement loop: regions for segments outside PT_LOAD now use the segment's
p_vaddr/p_align, and zero or non-power-of-two alignment still falls back to 1. The new test pins the offset/vaddr rule and each segment's bytes in both layouts; merged.