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:
- Analysis of compressed
__llvm_covmap
- Analysis of compressed
.strtab
([RFC] Compressed SHT_SYMTAB/SHT_STRTAB for ELF) in exe/dso or an alternative that places `.strtab in a file referenced by .gnu_debuglink - Analysis of the compression ratio of CREL [RFC] CREL: A compact relocation format for ELF (Applying a generic compression algorithm is a good way to measure the efficiency of an encoding format, as a dense format can hardly be further compressed by a generic algorithm)
I’m curious to see how others are creatively applying compression techniques!