Skip to content

Commit 5350b65

Browse files
committed
[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>
1 parent 3e04f07 commit 5350b65

File tree

4 files changed

+1004
-17
lines changed

4 files changed

+1004
-17
lines changed

src/Makefile.housekeeping

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,15 +1220,12 @@ endif # defined(BIN)
12201220
#
12211221
# The compression utilities
12221222
#
1223-
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
1224-
$(QM)$(ECHO) " [HOSTCC] $@"
1225-
$(Q)$(HOST_CC) $(HOST_CFLAGS) -DENCODE -DDECODE -DMAIN -DVERBOSE \
1226-
-DNDEBUG -DBITSIZE=32 -DENDIAN=0 -o $@ $<
1227-
CLEANUP += $(NRV2B)
12281223

1229-
$(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
1224+
ZBIN_LDFLAGS := -llzma
1225+
1226+
$(ZBIN) : util/zbin.c $(MAKEDEPS)
12301227
$(QM)$(ECHO) " [HOSTCC] $@"
1231-
$(Q)$(HOST_CC) $(HOST_CFLAGS) -o $@ $<
1228+
$(Q)$(HOST_CC) $(HOST_CFLAGS) $< $(ZBIN_LDFLAGS) -o $@
12321229
CLEANUP += $(ZBIN)
12331230

12341231
###############################################################################

0 commit comments

Comments
 (0)