Skip to main content

Module executable

Module executable 

Source
Expand description

Executable categorizer — routes ELF / PE / Mach-O binaries to BCJ-x86 or BCJ-ARM64 composite codecs.

§Algorithm

  1. Detect executable format by magic bytes at offset 0:
    • ELF: \x7FELF
    • PE: MZ then PE header at offset stored at 0x3C
    • Mach-O: 0xFEEDFACE, 0xFEEDFACF, 0xCEFAEDFE, 0xCFFAEDFE
  2. Read architecture from the format-specific header field:
    • ELF: e_machine at offset 18 (u16 LE)
      • 0x3E = x86_64 → BCJ-x86
      • 0xB7 = aarch64 → BCJ-ARM64
    • PE: Machine at offset 0 in PE header (u16 LE)
      • 0x8664 = x86_64 → BCJ-x86
      • 0xAA64 = aarch64 → BCJ-ARM64
    • Mach-O: cputype at offset 4 (u32 LE for native-endian magic)
      • 0x01000007 = x86_64 → BCJ-x86
      • 0x0100000C = arm64 → BCJ-ARM64
  3. Pick the LZ4 variant for write-heavy profiles (faster encode) and the ZSTD variant otherwise. We pick LZ4 by default for speed; the tournament in process_whole_file_drop will re-evaluate against ZSTD and pick the smaller result.

§Coverage

All four major executable formats × the two architectures that have a BCJ filter implementation in omnizip-filters today. 32-bit ARM (no BCJ filter published), PowerPC, SPARC, IA-64 routes to plain LZ4 (no benefit from a filter we don’t have).

Structs§

ExecutableCategorizer
Categorizer for executable binaries. Detects ELF / PE / Mach-O magic and routes x86_64 / aarch64 architectures to BCJ-x86 / BCJ-ARM64 composite codecs.