ld --compress-debug-sections=zlib compresses the .debug_* output sections (usually non-SHF_ALLOC, but I've seen rustc SHF_ALLOC .debug_gdb_scripts - which could be a rustc bug). There are needs compressing other sections, even SHF_ALLOC ones, e.g. __llvm_covstr for potential future clang coverage mapping formats (https://bugs.llvm.org//show_bug.cgi?id=49155). For SHF_ALLOC sections, there will be additional requirement on the runtime side as the runtime needs to figure out whether the section is compressed or not (perhaps just checking the Elf*_Chdr header (section header table is optional in executable/shared object files)) If we don't distinguish SHF_ALLOC and non-SHF_ALLOC sections, the new option can be '--compress-sections=.debug_*=zlib' . If we just need non-SHF_ALLOC sections, the new option can be '--compress-nonalloc-sections=.debug_*=zlib' . The exact requirements may need fleshing out.
I think we should just allow SHF_ALLOC | SHF_COMPRESSED sections. Created https://groups.google.com/g/generic-abi/c/HUVhliUrTG0 The proposed option syntax is: --compress-sections='.debug_*=zlib' . This applies to both SHF_ALLOC and non-SHF_ALLOC sections.