libabigail/tests
Matthias Maennich acc4bea0b8 symtab: Add support for MODVERSIONS (CRC checksums)
The Linux Kernel has a mechanism (MODVERSIONS) to checksum symbols based
on their type. In a way similar to what libabigail does, but different.
The CRC values for symbols can be extracted from the symtab either by
following the __kcrctab_<symbol> entry or by using the __crc_<symbol>
value directly.

This patch adds support for extracting those CRC values and storing them
as a property of elf_symbol. Subsequently, 'crc' gets emitted as an
attribute of 'elf-symbol' in the XML representation.

CRC comparisons are also added to the abidiff machinery such that if
both representations of a comparison contain a CRC value, they will be
compared and if any of the values is unset (i.e. == 0), equality is
assumed. Differences will be reported in the format that the Kernel
presents them e.g. via Module.symvers. It is likely, but not necessary,
that a CRC difference comes along with an ABI difference reported by
libabigail. Not everything that leads to a change of the CRC value an
ABI breakage in the libabigail sense.

In case a function or variable symbol changes in a harmless way, we
would previously also consider a CRC change harmless (or more precise:
not harmful). Explicitly testing for CRC changes when analyzing whether
diff nodes need to be considered harmful, allows to still classify them
harmful.

Also add some test cases to ensure reading CRC values from kernel
binaries works as expected. The empty-report files have been
consolidated to one file: empty-report.txt. That also clarifies the
expected outcome for the affected tests.

	* include/abg-ir.h (elf_symbol::elf_symbol): Add CRC parameter.
	(elf_symbol::create): Likewise.
	(elf_symbol::get_crc): New member method.
	(elf_symbol::set_crc): New member method.
	* src/abg-comp-filter.cc (crc_changed): New function.
	(categorize_harmful_diff_node): Also test for CRC changes.
	* src/abg-ir.cc (elf_symbol::priv::crc_): New data member.
	* src/abg-ir.cc (elf_symbol::priv::priv): Add CRC parameter.
	(elf_symbol::elf_symbol): Likewise.
	(elf_symbol::create): Likewise.
	(elf_symbol::textually_equals): Add CRC support.
	(elf_symbol::get_crc): New member method.
	(elf_symbol::set_crc): New member method.
	* src/abg-reader.cc (build_elf_symbol): Add CRC support.
	* src/abg-reporter-priv.cc (maybe_report_diff_for_symbol): Likewise.
	* src/abg-symtab-reader.cc (symtab::load): Likewise.
	* src/abg-writer.cc (write_elf_symbol): Likewise.
	* tests/data/Makefile.am: Add new test data files.
	* tests/data/test-abidiff-exit/test-crc-report.txt: New test file.
	* tests/data/test-abidiff-exit/test-crc-v0.abi: Likewise.
	* tests/data/test-abidiff-exit/test-crc-v1.abi: Likewise.
	* tests/data/test-abidiff/empty-report.txt: New file.
	* tests/data/test-abidiff/test-PR18166-libtirpc.so.report.txt: Deleted.
	* tests/data/test-abidiff/test-PR24552-report0.txt: Deleted.
	* tests/data/test-abidiff/test-crc-0.xml: New test file.
	* tests/data/test-abidiff/test-crc-1.xml: Likewise.
	* tests/data/test-abidiff/test-crc-2.xml: Likewise.
	* tests/data/test-abidiff/test-crc-report.txt: Likewise.
	* tests/data/test-abidiff/test-empty-corpus-report.txt: Deleted.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Add CRC values.
	* tests/data/test-read-write/test-crc.xml: New test data file.
	* tests/data/test-symtab/kernel-modversions/Makefile: New test source.
	* tests/data/test-symtab/kernel-modversions/one_of_each.c: Likewise.
	* tests/data/test-symtab/kernel-modversions/one_of_each.ko: Likewise.
	* tests/test-abidiff-exit.cc: Add new test case.
	* tests/test-abidiff.cc: Add new test case.
	* tests/test-read-write.cc: Likewise.
	* tests/test-symtab.cc (Symtab::KernelSymtabsWithCRC): New test case.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 16:13:13 +02:00
..
data symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
lib tests/catch.hpp: Add SPDX header back 2021-03-08 11:33:56 +01:00
.gitignore tests/.gitignore: ignore all files starting with runtest* 2020-05-13 11:26:28 +02:00
Makefile.am Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00
mockfedabipkgdiff.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
print-diff-tree.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
runtestcanonicalizetypes.sh.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
runtestdefaultsupprs.py.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
runtestdefaultsupprspy3.sh.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
runtestfedabipkgdiff.py.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
runtestfedabipkgdiffpy3.sh.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
runtestslowselfcompare.sh.in Bug 26769 - Fix missing types in abixml output 2020-11-23 13:02:34 +01:00
test-abicompat.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-abidiff-exit.cc symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-abidiff.cc symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-alt-dwarf-file.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-annotate.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-core-diff.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-cxx-compat.cc abg-cxx-compat: add simplified version of std::optional 2021-03-09 10:41:10 +01:00
test-diff2.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-diff-dwarf-abixml.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-diff-dwarf.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-diff-filter.cc Bug 27598 - abidiff mishandles union member functions 2021-03-31 18:21:28 +02:00
test-diff-pkg.cc dwarf-reader: Support more DWARF-5 type DIEs 2021-03-18 13:41:18 +01:00
test-diff-suppr.cc Bug 27267 - Better support for opaque enum types 2021-02-04 09:26:05 +01:00
test-dot.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-elf-helpers.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-ini.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-ir-walker.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-kmi-whitelist.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-lookup-syms.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-read-dwarf.cc dwarf-reader/writer: consider aliases when dealing with suppressions 2021-04-02 16:05:32 +02:00
test-read-write.cc symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-svg.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-symtab-reader.cc dwarf-reader split: create abg-symtab-reader.{h,cc} and test case 2021-03-10 18:54:55 +01:00
test-symtab.cc symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-tools-utils.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-types-stability.cc Bug 27165 - Better support multi-language binaries 2021-02-02 16:15:29 +01:00
test-utils.cc Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-utils.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
test-valgrind-suppressions.supp
update-test-output.py Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00