libabigail/tests/data
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
..
test-abicompat symtab/dwarf-reader: allow hinting of main symbols for aliases 2021-04-02 15:54:23 +02:00
test-abidiff symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-abidiff-exit symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-alt-dwarf-file
test-annotate symtab/dwarf-reader: allow hinting of main symbols for aliases 2021-04-02 15:54:23 +02:00
test-core-diff
test-default-supprs
test-diff-dwarf symtab/dwarf-reader: allow hinting of main symbols for aliases 2021-04-02 15:54:23 +02:00
test-diff-dwarf-abixml dwarf-reader: Treat union members as public by default. 2021-03-19 17:06:25 +01:00
test-diff-filter symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-diff-pkg symtab/dwarf-reader: allow hinting of main symbols for aliases 2021-04-02 15:54:23 +02:00
test-diff-suppr dwarf-reader/writer: consider aliases when dealing with suppressions 2021-04-02 16:05:32 +02:00
test-fedabipkgdiff tests/data/test-fedabipkgdiff: Update reference output 2020-11-25 13:15:18 +01:00
test-ini Add missing newlines to end of test files. 2020-10-01 16:11:29 +02:00
test-kmi-whitelist KMI Whitelists: Add functionality to make whitelists additive 2020-01-21 18:37:43 +00:00
test-lookup-syms dwarf-reader: Fix bloom filter access in GNU_HASH section 2020-03-20 13:35:00 +01:00
test-read-dwarf symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-read-write symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-symtab symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00
test-types-stability Bug 27165 - Better support multi-language binaries 2021-02-02 16:15:29 +01:00
test-write-read-archive
Makefile.am symtab: Add support for MODVERSIONS (CRC checksums) 2021-04-02 16:13:13 +02:00