Documentation
¶
Overview ¶
Package efipack compresses PE32+/EFI binaries into a self-extracting PE32+/EFI image. PR1 (this revision) ships the host-side compression API, the PE32+ envelope assembly, and tests; the per-arch runtime decompressor stub lands in PR2 and the pectl CLI integration in PR3.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCompressorNotImplemented = errors.New("efipack: compressor not implemented in this build")
ErrCompressorNotImplemented is the sentinel switchCompressor returns for a valid Compressor constant that has no codec wired in the current build. As of v0.3.0 every defined Compressor (Flate, LZFSE, LZ4) is implemented host-side, so switchCompressor no longer returns it; the sentinel is retained as a stable part of the public API so callers that added a Compressor constant ahead of its codec can keep matching on it with errors.Is.
Functions ¶
func ReadPayload ¶
ReadPayload locates the .payload section in a packed PE32+ image, strips the wire header, and returns the raw compressed body plus the metadata stamped at pack time. It is the inverse of Pack's envelope assembly, used by host tests today and by the runtime stub (PR2) tomorrow. It does NOT decompress — the caller pairs it with a bodyCodec.Decode for the appropriate algorithm.
Types ¶
type Arch ¶
type Arch int
Arch enumerates the four PE32+/EFI target machines efipack ships (or will ship, once PR2 lands the per-arch decompressor stubs).
type Compressor ¶
type Compressor int
Compressor is the body-compression algorithm used by Pack.
The default is Flate; it costs zero additional bytes in the decompressor stub because cloud-boot binaries already link compress/gzip via M6.1's embedded payloads and M7's OCI manifest handling. Alternatives (LZFSE, LZ4) can be wired in by adding a constant + case in switchCompressor.
const ( // Flate uses stdlib compress/flate. Default; zero stub cost. Flate Compressor = iota // LZFSE uses github.com/go-compressions/lzfse. Best raw ratio; // host-side wired since v0.2.0. Booting an LZFSE-packed EFI needs // an LZFSE-aware runtime stub (the shipped blobs decode FLAT only). LZFSE // LZ4 uses github.com/go-compressions/lz4's pure-Go block codec. // Host-side wired since v0.3.0 — the fastest decompressor of the // three, at a lower ratio. Like LZFSE, booting an LZ4-packed EFI // needs an LZ4-aware runtime stub (the shipped blobs decode FLAT // only); efipack still stamps the LZ4 body + "LZ4 " algo tag so a // future LZ4-aware stub — or a host-side unpack — round-trips it. LZ4 )
func (Compressor) String ¶
func (c Compressor) String() string
String returns a short stable name for the compressor.
type Options ¶
type Options struct {
Compressor Compressor // defaults to Flate
Level int // compression level passed to the underlying codec; 0 = codec default
}
Options controls Pack. The zero value is sensible (Flate at the stdlib default level).
type PackResult ¶
type PackResult struct {
OriginalSize int64
CompressedSize int64 // size of the compressed body inside .payload (excludes the 24-byte header)
PackedSize int64 // size of the output PE32+ on disk
Compressor Compressor
Arch Arch
}
PackResult summarises a successful Pack call. Sizes are in bytes.
PR1 leaves StubSize at 0 because the .stub section is the placeholder; PR2 will add a StubSize field carrying the real per-arch blob length.
func Pack ¶
Pack reads a PE32+/EFI image from in, compresses it, and writes a self-extracting PE32+/EFI envelope to out.
PR1 acceptance: the output is structurally a valid PE32+ image (correct DOS stub, PE signature, COFF header with the input arch's Machine field, optional header, section table with `.stub` and `.payload`), but the `.stub` section is a placeholder containing only the sentinel "TODO_STUB". Firmware will load the image, jump to the entry point, and fault — by design. PR2 replaces the .stub body with the real per-arch decompressor blob, after which the output becomes a runnable self-extracting EFI.
Round-trip is guaranteed today: the bytes inside .payload, when fed back through the matching bodyCodec.Decode, reproduce the input byte-for-byte. This is what the host tests exercise.
