Skip to content
Permalink
Browse files
[zbin] Use LZMA compression
LZMA provides significantly better compression (by ~15%) than the
current NRV2B algorithm.

We use a raw LZMA stream (aka LZMA1) to avoid the need for code to
parse the LZMA2 block headers.  We use parameters {lc=2,lp=0,pb=0} to
reduce the stack space required by the decompressor to acceptable
levels (around 8kB).  Using lc=3 or pb=2 would give marginally better
compression, but at the cost of substantially increasing the required
stack space.

The build process now requires the liblzma headers to be present on
the build system, since we do not include a copy of an LZMA compressor
within the iPXE source tree.  The decompressor is written from scratch
(based on XZ Embedded) and is entirely self-contained within the
iPXE source.

The branch-call-jump (BCJ) filter used to improve the compressibility
is specific to iPXE.  We choose not to use liblzma's built-in BCJ
filter since the algorithm is complex and undocumented.  Our BCJ
filter achieves approximately the same results (on typical iPXE
binaries) with a substantially simpler algorithm.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Feb 25, 2015
1 parent 3e04f07 commit 5350b65a3ce727f20e9d9fa7b9c2c0af52cfb7bd
Showing with 1,004 additions and 17 deletions.
  1. +4 −7 src/Makefile.housekeeping
  2. +905 −0 src/arch/i386/prefix/unlzma.S
  3. +9 −0 src/arch/i386/prefix/unlzma16.S
  4. +86 −10 src/util/zbin.c
@@ -1220,15 +1220,12 @@ endif # defined(BIN)
#
# The compression utilities
#
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) $(HOST_CFLAGS) -DENCODE -DDECODE -DMAIN -DVERBOSE \
-DNDEBUG -DBITSIZE=32 -DENDIAN=0 -o $@ $<
CLEANUP += $(NRV2B)

$(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
ZBIN_LDFLAGS := -llzma

$(ZBIN) : util/zbin.c $(MAKEDEPS)
$(QM)$(ECHO) " [HOSTCC] $@"
$(Q)$(HOST_CC) $(HOST_CFLAGS) -o $@ $<
$(Q)$(HOST_CC) $(HOST_CFLAGS) $< $(ZBIN_LDFLAGS) -o $@
CLEANUP += $(ZBIN)

###############################################################################

0 comments on commit 5350b65

Please sign in to comment.