libabigail/include
Dodji Seketeli 75e9536cb7 hash: Implement full recursive hashing of artifacts
Up until now, when hashing an artifact through the virtual
type_or_decl_base::hash_value the given artifact is hashed by its
specific hashing function, that would be, for e.g, a pointer,
pointer_type_def:#️⃣:operator().  But then, the sub-types of the
pointer would be hashed using do_hash_value, which is a function
template that invokes type_base:#️⃣:operator().  That means, all
sub-types are hashed only using type_base:#️⃣:operator(), not their
virtual type_or_decl_base::hash_value.  That
type_base:#️⃣:operator() hashes types only based on their size.  No
other property of the artifact is taken into account.  I call that
"partial" hashing, in lieu of the full hashing that would have
happened if the virtual type_or_decl_base::hash_value was invoked
leading to the invocation of the full <type>:#️⃣:operator() that
would hash the artifact based on all its properties, not just its
type size.

This patch implements a hash for complex types which is less likely to
have collisions.

	* include/abg-hash.h (enum hashing_state): Add better comments for
	the enumerators.
	(hashing_state::HASHING_SUBTYPE_STATE): Add new enumerator.
	* src/abg-hash.cc
	(MAYBE_RETURN_EARLY_FROM_HASHING_TO_AVOID_CYCLES): Consider the
	new state hashing::HASHING_SUBTYPE_STATE when detecting cycles.
	({typedef_decl, qualified_type_def, pointer_type_def,
	reference_type_def, array_type_def, ptr_to_mbr_type,
	enum_type_decl, function_type, method_type, class_decl::base_spec,
	class_or_union, class_decl, union_decl}:#️⃣:operator()): Invoke
	type_or_decl_base::hash_decl on sub-types to compute their hash.
	Prior to invoke that hashing function, set the state of the
	artifact to the new hashing:HASHING_SUBTYPE_STATE so that
	type_or_decl_base::hash_decl does *not* set the computed hash on
	the sub-type.
	* src/abg-ir-priv.h (type_or_decl_base::priv::set_hash_value): An
	ABI artifact can now be in the hashing::HASHING_SUBTYPE_STATE
	state.
	* tests/data/test-annotate/PR29443-missing-xx.o.annotated.abi:
	Adjust.
	* tests/data/test-annotate/libtest23.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi:
	Likewise.
	* tests/data/test-annotate/test-pointer-to-member-1.o.annotated.abi:
	Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-annotate/test4.so.abi: Likewise.
	* tests/data/test-annotate/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
	Likewise.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
	Likewise.
	* tests/data/test-read-btf/test0.o.abi: Likewise.
	* tests/data/test-read-ctf/PR27700/test-PR27700.abi: Likewise.
	* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
	* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-A.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-ambiguous-struct-B.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
	* tests/data/test-read-ctf/test-array-mdimension.abi: Likewise.
	* tests/data/test-read-ctf/test-array-of-pointers.abi: Likewise.
	* tests/data/test-read-ctf/test-array-size.abi: Likewise.
	* tests/data/test-read-ctf/test-bitfield-enum.abi: Likewise.
	* tests/data/test-read-ctf/test-bitfield.abi: Likewise.
	* tests/data/test-read-ctf/test-callback.abi: Likewise.
	* tests/data/test-read-ctf/test-callback2.abi: Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-a.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-conflicting-type-syms-b.o.hash.abi:
	Likewise.
	* tests/data/test-read-ctf/test-const-array.abi: Likewise.
	* tests/data/test-read-ctf/test-dynamic-array.o.abi: Likewise.
	* tests/data/test-read-ctf/test-enum-many.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-enum-symbol.o.hash.abi: Likewise.
	* tests/data/test-read-ctf/test-enum.o.abi: Likewise.
	* tests/data/test-read-ctf/test-forward-type-decl.abi: Likewise.
	* tests/data/test-read-ctf/test-functions-declaration.abi:
	Likewise.
	* tests/data/test-read-ctf/test-linux-module.abi: Likewise.
	* tests/data/test-read-ctf/test-list-struct.abi: Likewise.
	* tests/data/test-read-ctf/test0.abi: Likewise.
	* tests/data/test-read-ctf/test0.hash.abi: Likewise.
	* tests/data/test-read-ctf/test1.so.abi: Likewise.
	* tests/data/test-read-ctf/test1.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test2.so.abi: Likewise.
	* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test4.so.abi: Likewise.
	* tests/data/test-read-ctf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-ctf/test5.o.abi: Likewise.
	* tests/data/test-read-ctf/test7.o.abi: Likewise.
	* tests/data/test-read-ctf/test9.o.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
	* tests/data/test-read-dwarf/PR29443-missing-xx.o.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-1.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-pointer-to-member-1.o.abi:
	Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test1.abi: Likewise.
	* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.abi: Likewise.
	* tests/data/test-read-dwarf/test6.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test8-qualified-this-pointer.so.hash.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-10-01 17:04:12 +02:00
..
Makefile.am Add support for BTF 2023-01-06 21:05:53 +01:00
abg-btf-reader.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-comp-filter.h dwarf-reader: Avoid duplicating anonymous member types 2024-08-29 17:15:43 +02:00
abg-comparison.h dwarf-reader: Avoid duplicating anonymous member types 2024-08-29 17:15:43 +02:00
abg-config.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-corpus.h corpus: Allow several variables with same ID to be exported 2024-09-06 22:35:22 +02:00
abg-ctf-reader.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-cxx-compat.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-diff-utils.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-dwarf-reader.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-elf-based-reader.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-elf-reader.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-fe-iface.h Use smart pointers for variables exported from the ABI corpus 2024-08-14 14:05:54 +02:00
abg-fwd.h dwarf-reader,reader.cc: Fix function virtuality setting 2024-08-29 17:15:44 +02:00
abg-hash.h hash: Implement full recursive hashing of artifacts 2024-10-01 17:04:12 +02:00
abg-ini.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-interned-str.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-ir.h dwarf-reader,ir,writer: Better support for static member variables 2024-08-29 17:15:44 +02:00
abg-libxml-utils.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-reader.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-regex.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-reporter.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-sptr-utils.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-suppression.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-tools-utils.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-traverse.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-version.h.in abidw: Add --abixml-version 2021-11-12 18:31:28 +01:00
abg-viz-common.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-viz-dot.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-viz-svg.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-workers.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00
abg-writer.h Update Copyright for year 2024 2024-04-26 15:29:50 +02:00