Skip to content

feat(nx-object): read a KIP1 and a CNMT, and expand packed segments - #14

Merged
LNSD merged 1 commit into
mainfrom
lnsd/read-kip-and-cnmt
Aug 18, 2026
Merged

LNSD merged 1 commit into
mainfrom
lnsd/read-kip-and-cnmt

Conversation

@LNSD

@LNSD LNSD commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Completes the read side for the formats the crate already builds. Expanding a segment stays a separate call rather than an accessor: a reader borrows its buffer and has nowhere to put the result, so the allocation and the failure are both the caller's to see.

  • Add blz::decompress, taking the expanded length as an argument because a stored stream is padded to four bytes and records no length of its own
  • Add read::kip, proving each segment's stored bytes lie inside the image and expanding the three the header marks packed; bss reads as an empty slice, since it occupies no bytes in the file
  • Add read::cnmt, exposing the content records and leaving an extended header unread when the meta type is not one this crate models, rather than reinterpreting it as the wrong structure
  • Add Nso::text, Nso::rodata, and Nso::data, returning the segment as the loader maps it — page padding included, because the recorded size and hash both cover it
  • Fix two compress defects the new round-trip sweep found: a layout saving less than the trailer underflowed extra_len and panicked, and one saving exactly the trailer wrote a zero there, which is the marker for a stored stream and decoded as the wrong form

Completes the read side for the formats the crate already builds. Expanding a segment stays a separate call rather than an accessor: a reader borrows its buffer and has nowhere to put the result, so the allocation and the failure are both the caller's to see.

- Add `blz::decompress`, taking the expanded length as an argument because a stored stream is padded to four bytes and records no length of its own
- Add `read::kip`, proving each segment's stored bytes lie inside the image and expanding the three the header marks packed; `bss` reads as an empty slice, since it occupies no bytes in the file
- Add `read::cnmt`, exposing the content records and leaving an extended header unread when the meta type is not one this crate models, rather than reinterpreting it as the wrong structure
- Add `Nso::text`, `Nso::rodata`, and `Nso::data`, returning the segment as the loader maps it — page padding included, because the recorded size and hash both cover it
- Fix two `compress` defects the new round-trip sweep found: a layout saving less than the trailer underflowed `extra_len` and panicked, and one saving exactly the trailer wrote a zero there, which is the marker for a stored stream and decoded as the wrong form

Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
@LNSD
LNSD added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit f3546be Aug 18, 2026
5 checks passed
@LNSD
LNSD deleted the lnsd/read-kip-and-cnmt branch August 18, 2026 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant