Bug 29563 - gdb: support zstd for SHF_COMPRESSED debug sections
Summary: gdb: support zstd for SHF_COMPRESSED debug sections
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 13.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 29584
  Show dependency treegraph
 
Reported: 2022-09-09 20:02 UTC by Fangrui Song
Modified: 2022-09-27 02:55 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2022-09-09 20:02:10 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.

See https://sourceware.org/bugzilla/show_bug.cgi?id=29397 for binutils feature request.

gdb will need to support SHF_COMPRESSED (ch_type=ELFCOMPRESS_ZSTD) .debug_* sections in executables, shared objects, and (split DWARF) .dwo files.
Comment 1 Fangrui Song 2022-09-09 20:11:00 UTC
llvm-project has some components supporting zstd now. Some instructions for developers who want to test gdb's support:


git clone https://github.com/facebook/zstd
cd zstd
cmake -GNinja -Hbuild/cmake -Bout/release -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/opt/zstd
make -j 8 install

# See https://llvm.org/docs/GettingStarted.html
# Example: cmake -GNinja -Sllvm -Bout/release -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='clang;lld' -DLLVM_ENABLE_ZSTD=FORCE_ON -DCMAKE_PREFIX_PATH=/tmp/opt/zstd; ninja -C out/release llvm-objcopy clang lld

You can create zstd output with

out/release/bin/llvm-objcopy --compress-debug-sections=zstd a.out a.out.zstd

or out/release/bin/clang -fuse-ld=lld -gz=zstd a.o b.o ...
Comment 2 Fangrui Song 2022-09-19 04:05:23 UTC
Due to gdb's use of bfd/compress.c, this actually has to be supported in the same patch that adds zstd support to bfd/.  Here it is.

https://sourceware.org/pipermail/gdb-patches/2022-September/191915.html [PATCH] binutils, gdb: support zstd compressed debug sections

I have tested gdb with a zstd-compressed lld.
Comment 3 Fangrui Song 2022-09-27 02:54:10 UTC
Closed by https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2cac01e3ffff74898c54fa5e6418817f5578adb6 "binutils, gdb: support zstd compressed debug sections"