Llvm-objcopy --compress-sections

ELF linkers and objcopy/llvm-objcopy provide --compress-debug-sections=[zlib|zstd] to compress .debug_* sections. A natural extension is to compress arbitrary sections, which can be used with a number of sections not requiring runtime introspection.

I recently added

ld.lld --compress-sections <sections-glob>=[zlib|zstd]

To complement ld.lld, similar functionality for decompressing sections would be valuable in llvm-objcopy. I have created [llvm-objcopy] Add --compress-sections by MaskRay · Pull Request #85036 · llvm/llvm-project · GitHub

llvm-objcopy --compress-sections <sections-glob>=[zlib|zstd]  # compress sections
llvm-objcopy --compress-sections <sections-glob>=none         # decompress sections

I find arbitrary section compression handy for several tasks:

I’m curious to see how others are creatively applying compression techniques!