Bug 29397

Summary: binutils: support zstd for SHF_COMPRESSED debug sections
Product: binutils Reporter: Fangrui Song <i>
Component: binutilsAssignee: Fangrui Song <i>
Status: RESOLVED FIXED    
Severity: normal CC: guillaume, hjl.tools, mliska, nick.alcock, nickc, sam, trass3r
Priority: P2    
Version: unspecified   
Target Milestone: ---   
See Also: https://sourceware.org/bugzilla/show_bug.cgi?id=29640
https://sourceware.org/bugzilla/show_bug.cgi?id=29641
Host: Target:
Build: Last reconfirmed:

Description Fangrui Song 2022-07-24 07:17:11 UTC
Zstandard is a "universal" compression algorithm which scales from low-ratio-very-fast to high-ratio-pretty-slow.
The generic-abi proposal https://groups.google.com/g/generic-abi/c/satyPkuMisk ("Add new ch_type value: ELFCOMPRESS_ZSTD") has been approved.

The default zstd -3 is easily 7x as fast as zlib level 1 while having a higher compression ratio.

See also https://sourceware.org/pipermail/gnu-gabi/2022q2/000498.html

binutils may need to:

* optional: import zstd/ as a toplevel directory like zlib/
* add configure.ac option --with-system-zstd
* gas: add --compress-debug-sections=zstd
* objcopy: add --compress-debug-sections=zstd
* ld: support ELFCOMPRESS_ZSTD input, add --compress-debug-sections=zstd
Comment 1 Fangrui Song 2022-07-25 07:45:14 UTC
Add more tools to the list:

* nm
* addr2line

For objcopy --compress-debug-sections=zstd , I think it should apply only to uncompressed .debug_* sections. If a section is compressed by zlib, the format should not change.
If a user wants to ensure zlib sections are converted to zstd, run --decompress-debug-sections first.
Comment 2 Fangrui Song 2022-09-19 04:03:16 UTC
https://sourceware.org/pipermail/gdb-patches/2022-September/191915.html [PATCH] binutils, gdb: support zstd compressed debug sections
Comment 3 Fangrui Song 2022-09-26 22:06:43 UTC
(In reply to Fangrui Song from comment #2)
> https://sourceware.org/pipermail/gdb-patches/2022-September/191915.html
> [PATCH] binutils, gdb: support zstd compressed debug sections

The latest version is at https://sourceware.org/pipermail/binutils/2022-September/123085.html . The gdb part has been approved.
Comment 4 Alan Modra 2022-09-30 02:24:13 UTC
Fixed with commit 2cac01e3ff