Expand description
Executable categorizer — routes ELF / PE / Mach-O binaries to BCJ-x86 or BCJ-ARM64 composite codecs.
§Algorithm
- Detect executable format by magic bytes at offset 0:
- ELF:
\x7FELF - PE:
MZthen PE header at offset stored at 0x3C - Mach-O:
0xFEEDFACE,0xFEEDFACF,0xCEFAEDFE,0xCFFAEDFE
- ELF:
- Read architecture from the format-specific header field:
- ELF:
e_machineat offset 18 (u16 LE)0x3E= x86_64 → BCJ-x860xB7= aarch64 → BCJ-ARM64
- PE:
Machineat offset 0 in PE header (u16 LE)0x8664= x86_64 → BCJ-x860xAA64= aarch64 → BCJ-ARM64
- Mach-O:
cputypeat offset 4 (u32 LE for native-endian magic)0x01000007= x86_64 → BCJ-x860x0100000C= arm64 → BCJ-ARM64
- ELF:
- 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_dropwill 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§
- Executable
Categorizer - Categorizer for executable binaries. Detects ELF / PE / Mach-O magic and routes x86_64 / aarch64 architectures to BCJ-x86 / BCJ-ARM64 composite codecs.