46 Commits
Author SHA1 Message Date
Dean 95833d842d Merge pull request #10923 from 1whythef2/fix/unwrap-contained-segment-alignment
fix(tools): preserve contained segment alignment when unwrapping SELF
2026-10-27 10:56:22 +13:00
Dean da1d222d52 Merge pull request #10733 from Bram910/fix/unwrap-elf-header-metadata
fix(tools): validate inner ELF machine and header size
2026-10-27 09:03:28 +13:00
plexerPK b6f33d10cc fix(tools): preserve recorded SELF segment host mapping 2026-10-25 14:42:02 +01:00
Jade'sG 2a45d721f6 fix(tools): stabilize overlapping SELF region selection 2026-10-25 19:45:03 +08:00
Jade'sG d5635e5728 fix(tools): preserve contained segment alignment when unwrapping SELF 2026-10-25 18:21:54 +08:00
MarcZX10 443388f161 fix(tools): refuse unwrap_self segments placed before the file start 2026-10-25 06:37:02 +00:00
Bram910 efc4ed1b7b fix(tools): validate inner ELF machine and header size 2026-10-24 21:56:41 +02:00
hakarrr 546bad013f fix(tools): open the unwrap_self temporary file through io.open 2026-10-24 16:47:37 +05:30
Dean 8fc60685a7 Merge pull request #10224 from Project-MOC/codex/fix-unwrap-self-atomic-output
fix(tools): preserve SELF outputs on failed writes
2026-10-24 12:55:33 +13:00
Project-MOC db8785f6ce fix(tools): preserve new SELF output permissions 2026-10-23 18:33:14 +02:00
Project-MOC 1852888af9 fix(tools): preserve SELF outputs on failed writes 2026-10-23 18:20:22 +02:00
emirplus 81820edf30 fix(tools): reconfigure streams with backslashreplace in unwrap_self
Reconfigure sys.stdout and sys.stderr with backslashreplace error handling at the entrypoint of main() so unwrapping reports and error messages do not fail on Windows consoles configured with non-UTF-8 code pages.
2026-10-23 18:48:42 +03:00
Dean 92d5a052eb Merge pull request #8902 from THEBIGTOMMY13DEV/fix/self-program-header-overlap
fix(tools): reject SELF program tables overlapping the ELF header
2026-10-23 14:15:02 +13:00
Dean c9999808e7 Merge pull request #9328 from emirplus/fix/unwrap-self-main-guard
fix(tools): wrap entrypoint in main with stream reconfigure in unwrap_self
2026-10-23 10:43:41 +13:00
emirplus 032344e05a fix(tools): wrap entrypoint in main with stream reconfigure in unwrap_self 2026-10-21 21:35:18 +03:00
Kovalev Vladislav da1d9407ed fix(tools): bound total SELF alignment padding 2026-10-21 23:23:52 +06:00
Dean 26d1065e25 Merge pull request #8803 from AMRYB/fix/self-overlapping-load-regions
fix(tools): preserve load ownership when unwrapping SELF
2026-10-21 21:32:12 +13:00
THEBIGTOMMY13DEV ca376e7545 fix(tools): reject SELF program tables overlapping the ELF header 2026-10-21 01:05:56 -04:00
Dean 7d7b097407 Merge pull request #8543 from tkcm01/fix/unwrap-self-bss-segments
fix(tools): handle zero-size segments in unbacked PT_LOAD ranges in unwrap_self
2026-10-21 17:31:54 +13:00
Dean 2411c6e48b Merge pull request #8532 from valenciana-nc/fix/unwrap-self-minimal-alignment
fix(tools): avoid redundant padding when unwrapping SELF
2026-10-21 17:19:10 +13:00
Amr Yasser ecc88d1494 fix(tools): preserve load ownership when unwrapping SELF 2026-10-21 04:23:27 +03:00
tkcm01 7679fbd657 fix(tools): handle zero-size segments in unbacked PT_LOAD ranges in unwrap_self 2026-10-20 11:59:55 -04:00
Dean f0d8e6924d Merge pull request #6165 from MarcZX10/codex/unwrap-self-truncated-elf
fix(tools): reject unsupported inner ELF encodings
2026-10-21 04:46:15 +13:00
valenciana-nc 85cb95851b fix(tools): avoid redundant padding when unwrapping SELF 2026-10-20 09:15:49 -06:00
Adrià eca8d6cca4 Merge pull request #7820 from parl0v/fix/unwrap-self-segment-align
fix(tools): keep p_align for segments unwrap_self copies outside load segments
2026-10-20 04:18:47 +02:00
xXPBSXxandClaude Sonnet 5.5 360e8bd685 fix(tools): print unwrap_self reports as UTF-8 on every console
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-19 13:58:16 +02:00
Dean 08a0b7c95b Merge pull request #7702 from vittoriosalvadore/codex/fix-unwrap-empty-load-alignment
fix(tools): preserve empty load segment alignment when unwrapping SELF
2026-10-20 00:51:46 +13:00
Dean b62e0a8a7d Merge pull request #7713 from joedeangelis533-bot/fix/unwrap-file-backed-segments
fix(tools): reject unbacked segment data when unwrapping SELF
2026-10-19 23:51:55 +13:00
Josip Parlov 1e1ce29909 fix(tools): keep p_align for segments unwrap_self copies outside load segments
unwrap_self copied every segment that does not sit inside a PT_LOAD with
alignment 1. On real dumps that puts the comment and version segments
(p_align 0x10) right after the last load segment, at offsets that break
p_offset % p_align == p_vaddr % p_align. Those regions now use the
segment's own p_vaddr and p_align, the same as the load segments, which
is what the module docstring already promises. Load segment placement
and bytes do not change.
2026-10-19 10:52:04 +02:00
Josip Parlov d757b66e9a fix(tools): unwrap SELF dumps that leave out the version segment
unwrap_self reads the vaddr-less segments that follow the recorded
comment segment back to back from right after its data, and refuses the
whole container when one of them runs past the end of the file. Some
dumps end right after the last recorded segment and do not store the
version segment at all. The sce_module/libc.prx of PPSA15552 is one:
its last record, the 0x58-byte comment at 0x13b590, ends at 0x13b5e8,
which is the file size, so the 0x1a-byte PT_SCE_VERSION has no bytes
and the tool failed with "segment 12 does not fit the file" although
every load, dynamic and comment segment is complete.

A trailing segment that would run past the end of the file is now
emitted without file bytes, the same way as the PT_NOTE the container
leaves out. The relinker does not read PT_SCE_VERSION
(GuestImageReader skips it). Containers that store the version segment
unwrap byte for byte as before.
2026-10-19 09:09:39 +02:00
Dean b375e11806 Merge pull request #6621 from klosixgaming-arch/fix/unwrap-self-place-by-record-index
fix(tools): read unwrap_self's vaddr-less segments from where the SELF stores them
2026-10-19 16:52:24 +13:00
joedeangelis533-bot 392c947111 fix(tools): reject unbacked segment data when unwrapping SELF 2026-10-18 22:24:06 -04:00
Hotline Messina Dev 02dd083729 fix(tools): preserve empty load segment alignment when unwrapping SELF 2026-10-18 21:25:03 -04:00
Dean 802db07168 Merge pull request #7166 from MrMha/fix/unwrap-preserve-input-20261017
fix: preserve SELF inputs when an output aliases them
2026-10-18 09:47:48 +13:00
MrMha 4618ef679d fix: refuse invalid load segment metadata when unwrapping SELF 2026-10-17 18:41:08 +04:00
MrMha e80d47b7d0 fix: preserve SELF inputs when an output aliases them 2026-10-17 18:40:43 +04:00
Dean 8b84df66b1 Merge pull request #6441 from al3w0f205/fix/unwrap-self-zero-size-segments
fix(tools): allow unwrap_self to place zero-size segments without a PT_LOAD host
2026-10-18 02:17:56 +13:00
MarcZX100 0e61224749 fix(tools): reject unsupported inner ELF encodings 2026-10-16 22:01:26 +00:00
Adrià af7db81e6e Merge pull request #6065 from MiniRML/fix/unwrap-elf-metadata-bounds
fix(tools): validate inner ELF metadata before unwrapping SELF
2026-10-16 23:51:42 +02:00
klosixgaming-arch 38fc2ddb36 fix(tools): read unwrap_self's vaddr-less segments from where the SELF stores them
unwrap_self matched SELF records to PT_LOADs by size only and placed
every segment without a vaddr by the shift of the last mapped one. In the
19 modules of PPSA03743/PPSA03363 (Soul Hackers 2) the SCE comment
segment has a record of its own, after a 0x20-byte digest block, so it
and the version segment behind it were read 0x20 bytes too early, and in
the sce_module libraries, where the ELF puts a PT_NOTE between them, the
version segment was cut to a few bytes at the end of the file.

A record with flag 0x800 now places the program header whose index is in
flags bits 20 and up. Segments without a vaddr that follow the last
recorded one are read back to back after it; the PT_NOTE among them is
not stored in the container and is emitted without file bytes.
2026-10-16 16:42:42 -05:00
Adrià 8ac10e7a09 Merge pull request #6050 from MiniRML/fix/unwrap-program-header-space
fix(tools): reserve program header space when unwrapping SELF
2026-10-16 23:25:13 +02:00
al3w0f205andsimonbronk 7ef0bf1541 fix(tools): allow unwrap_self to place zero-size segments without a PT_LOAD host
When a decrypted SELF contains a non-PT_LOAD segment (such as PT_TLS for pure TBSS) with p_filesz == 0 whose virtual address lies outside any PT_LOAD memory range, unwrap_self previously refused the container with 'segment N vaddr 0x... is in no PT_LOAD'.

Allow zero-size segments without a matching PT_LOAD host to be placed with source offset 0 and new offset 0, preserving valid ELF headers for titles like Unity/IL2CPP PS5 builds.

Also allow file-empty PT_LOAD segments with stale out-of-file source offsets to skip the segment-extent bounds check, preserving memory sizes, addresses and alignments without reading container metadata.

Co-authored-by: simonbronk <[email protected]>
2026-10-15 14:22:04 -05:00
MiniRML 2df4c76f5b fix(tools): validate inner ELF metadata before unwrapping SELF 2026-10-14 14:07:38 -07:00
MiniRML 9936b8b9ee fix(tools): reserve program header space when unwrapping SELF 2026-10-14 13:53:31 -07:00
kjhq 019285d46f fix(tools): place an empty segment that ends a load segment in unwrap_self
unwrap_self refused a container when a non-load segment with no file data
sat exactly at the end of a PT_LOAD, as an empty PT_TLS does in Sifu
(PPSA03001): "segment 6 vaddr 0x88cb7a0 is in no PT_LOAD". The eboot and
36 of its 37 bundled modules carry such a segment. A segment of size zero
now matches the load segment it ends, so it is placed at that segment's end.
2026-10-14 15:24:14 +00:00
ryyReid 2a01e9eb18 feat(tools): unwrap decrypted SELF containers into clean ELF
The relinker reads a plain ELF executable and skips SELF containers with a
warning, so an eboot.bin or a *.prx taken from a title cannot be relinked
before it is unwrapped, and the repository has no tool for that.

The inner ELF program headers of a container carry stale offsets: a SELF
inserts its own metadata blocks between the segments, so the data sits at the
offsets of the SELF segment-record table at file offset 0x40. The segments are
also packed without honouring p_align, while ELF requires p_offset % p_align
== p_vaddr % p_align, which the relinker enforces on guest modules. The tool
places the segments from the records, falls back to the vaddr to file mapping
of the containing PT_LOAD for segments the table does not cover, copies every
region to an offset satisfying the alignment, and refuses a container whose
load segments all look encrypted.
2026-10-13 19:23:51 -05:00