[PATCH v3] binutils, gdb: support zstd compressed debug sections
Simon Marchi
simon.marchi@polymtl.ca
Fri Sep 23 14:32:43 GMT 2022
On 2022-09-23 00:08, Fangrui Song wrote:
> PR29397 PR29563: The new configure option --with-zstd defaults to auto.
> If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support zstd
> compressed debug sections for most tools.
>
> * bfd: for addr2line, objdump --dwarf, gdb, etc
> * gas: support --compress-debug-sections=zstd
> * ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd
> * objcopy: support ELFCOMPRESS_ZSTD input for
> --decompress-debug-sections and --compress-debug-sections=zstd
> * gdb: support ELFCOMPRESS_ZSTD input. The bfd change references zstd
> symbols, so gdb has to link against -lzstd in this patch.
>
> If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error. We
> can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this
> is too heavyweight, so don't do it for now.
>
> ```
> % ld/ld-new a.o
> ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
> ...
>
> % ld/ld-new a.o --compress-debug-sections=zstd
> ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support
>
> % binutils/objcopy --compress-debug-sections=zstd a.o b.o
> binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support
>
> % binutils/objcopy b.o --decompress-debug-sections
> binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support
> ...
> ```
> ---
> Changes from v1:
> * use PKG_CHECK_MODULES to check libzstd.pc
>
> Changes from v2:
> * Improve PKG_CHECK_MODULES, autoreconf -vf
> * objcopy: check --compress-debug-sections=zstd in a !HAVE_ZSTD build
Just one question: you moved PKG_PROG_PKG_CONFIG up in ld/configure.ac,
which I think is ok. But what about the other configure.ac files, don't
they need PKG_PROG_PKG_CONFIG too? gdb/configure.ac, for instance, uses
pkg-config for debuginfod. So if the user passes --without-debuginfod
--with-zstd, I expect things to fail, as the pkg-config will be skipped.
binutils/configure.ac probably has the same problem, since it uses
PKG_CHECK_MODULES for msgpack.
I would suggest using PKG_PROG_PKG_CONFIG at the top of all configure.ac
that use AM_ZSTD, out of precaution.
Simon
More information about the Binutils
mailing list