mirror of
git://sourceware.org/git/libabigail.git
synced 2025-03-03 05:07:59 +00:00
In preparation for an upcoming patch about comparing sets of packages (especially kernel packages that can contain xz-compressed kernel modules) this patch adds support for detecting the content of an input file compressed with the XZ tool. Note that the various libabigail tools need to know the kind of input file they are given in order to know what front-end to instantiate to handle the input file. The determination of the kind of file is done by the function tools::utils::guess_file_type either by looking at the suffix of the file name (for certain special files like tar files) or by opening the file and looking at its magic bytes. This patch uses liblzma to de-compress xz-ed files. The decompressing is done by a custom-written std::streambuf class. That decompressor streambuf is then instantiated with the input compressed ifstream. Then, an istream is constructed using that decompressor and so readers of that istream can just transparently just read from it, without knowing anything about the upstream decompressor streambuf. The existing code of guess_file_type has been adapted to instantiate the right decompressor streambuf. Once it has it and constructed the (decompressed) istream, the rest of the code remains unchanged and uses the istream as before. A new function tools_utils::get_decompressed_streambuf is introduced to get the right streambuf decompressor for the given input file. That function must be amended to support new compression schemes to come. With this patch, libabigail now can transparently read xz-ed ABIXML files as well as xz'ed ELF files. Note that both elfutils and libxml2 know how to read xz'ed binaries so I haven't had to do anything for them to handle the xz'ed input files. Pretty neat. The patch also adds regression tests handling input ABIXML files and ELF files. * configure.ac: Detect the liblzma library. * include/abg-tools-utils.h (enum file_type): Add a new FILE_TYPE_XZ enumerator. (class xz_decompressor_type): Declare a new custom std::streambuf class. * src/abg-elf-helpers.h: Include elfutils/libdwelf.h. * src/abg-elf-reader.cc (get_type_of_elf_file): Use dwelf_elf_begin instead of elf_begin to transparently handle compressed input file. * src/abg-tools-util*s.cc (struct xz_decompressor_type::priv): Define private type. (xz_decompressor_type::{xz_decompressor_type, ~xz_decompressor_type, underflow}): Define new methods for xz_decompressor_type. (operator<<(ostream&, file_type)): Add support for the new FILE_TYPE_XZ enumerator. (enum compression_kind): Define new enum. (is_compressed_file_type, get_decompressed_streambuf): Define new static functions. (guess_file_type): In the overload for std::istream, detect the XZ file type. In the overload for std::string, use the new is_compressed_file_type and get_decompressed_streambuf to decompress a compressed file on the fly and handing the resulting decompressed istream to the overload for std::istream. * tests/data/test-read-dwarf/test0.xz: New input binary test. * tests/data/test-read-dwarf/test0.xzbinary: Likewise. * tests/data/test-read-write/test28.xml.xz: Likewise. * tests/data/test-read-write/test28.xml.xzed: Likewise. * tests/data/Makefile.am: Add the new test input to source distribution. * tests/test-read-dwarf.cc (in_out_specs): Add the new test input to this test harness. * tests/test-read-write.cc (in_out_specs): Likewise. * tools/abicompat.cc (read_corpus): Add support for the new abigail::tools_utils::FILE_TYPE_XZ. * tools/abidiff.cc (main): Likewise. * tools/abilint.cc (main): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
---|---|---|
.. | ||
test-abicompat | ||
test-abidb | ||
test-abidiff | ||
test-abidiff-exit | ||
test-alt-dwarf-file | ||
test-annotate | ||
test-core-diff | ||
test-default-supprs | ||
test-diff-dwarf | ||
test-diff-dwarf-abixml | ||
test-diff-filter | ||
test-diff-pkg | ||
test-diff-pkg-ctf | ||
test-diff-suppr | ||
test-fedabipkgdiff | ||
test-ini | ||
test-kmi-whitelist | ||
test-lookup-syms | ||
test-read-btf | ||
test-read-common | ||
test-read-ctf | ||
test-read-dwarf | ||
test-read-write | ||
test-symtab | ||
test-types-stability | ||
test-write-read-archive | ||
Makefile.am |