/unlzma_tiny

Very small unlzma for embedded systems

Primary LanguageCGNU General Public License v2.0GPL-2.0

Tiny unlzma for embedded systems

Adaptation of BusyBox lzma decompressor for embedded, inflate directly from buffer to buffer.

Main goal is binary size.

Modifications from busybox version

  • read and write directly into buffers, removed all file handling
  • handle files without compressed size, using a end marker. Can now inflate lzma1 files made with lzma from xz-utils
  • prefer stack variable for rc_t
  • reuse buffer_end to handle truncated input

Binary Size

  • Observed binary sizes with GCC 10:
    • i686: 1.445 bytes
    • x86_64: 1.545 bytes
    • armv7-a thumb: 1.128 bytes
    • armv7-a: 1.652 bytes
    • aarch64: 1.756 bytes
    • mips: 2.016 bytes
    • mips16 1.456 bytes

Build

mkdir obj
cd obj
make -f ../Makefile

Contents

  • unlzma_tiny.c: uncompressor base on busybox/archival/libarchive/decompress_unlzma.c
  • unlzma_tiny_config.h: wrapper for base functions
  • unlzma.c: test program for debugging

Update from BusyBox

This code was originally based on busybox commit 8f48fc0 without keeping history. A backup tag unlzma_tiny-2021.01 to previous history was kept.

Further changes are merged from a filtered branch obtained with this script:

#!/bin/sh

set -e

REF=1_29_0

export FILTER_BRANCH_SQUELCH_WARNING=1

git fetch busybox -t -f
git checkout $REF -b busybox-filtered
git filter-branch -f --subdirectory-filter archival/ --prune-empty -- --all
git filter-branch -f --prune-empty --index-filter "git ls-files | grep -v 'decompress_unlzma.c' | xargs git rm --cached --ignore-unmatch"
git filter-branch -f --prune-empty --tree-filter "git ls-files | xargs -I '{}' git mv '{}' ./"
git fetch busybox -t -f

Credits