Hasty Briefsbeta

Bilingual

Golfing Zig ELF binaries (2025)

a day ago
  • #elf
  • #optimization
  • #zig
  • Starting from a debug zig binary (2,180K) that does nothing, stripping debug info reduces size to 192K.
  • Using ReleaseSmall mode shrinks binary to 12K, removing unnecessary ELF sections like .eh_frame further reduces bloat.
  • Switching to freestanding platform and changing entry point to _start yields 472-byte binary, but lacks executable code initially.
  • Merging program segments via a linker script cuts binary to 448 bytes; removing non-alloc sections reduces size to 131 bytes.
  • Code optimizations like marking functions as noreturn and using LTO reduce binary to minimal size, but ELF type change from EXEC to DYN is needed for compatibility on modern Linux systems.