libabigail/tests/data/test-abicompat
Dodji Seketeli 15f2ff5d6c Emit & read undefined interfaces to & from ABIXML
This patch teaches the ABIXML writer to emit information about
undefined interfaces.  It also teaches the ABIXML reader to read
information about undefined interfaces.

It introduces two new ABIXML elements:
'undefined-elf-function-symbols' and 'undefined-elf-variable-symbols'
to represent undefined function and variable symbols.

Then, in the 'abi-instr' element functions and variables that
reference undefined elf symbols now have an 'elf-symbol-id' attribute
referencing the undefined symbol listed in the new
'undefined-elf-variable-symbols' or 'undefined-elf-function-symbols'
element.

The patch introduces tests that perform compatibility checks done on
ABIXML files.

	* include/abg-writer.h (set_write_undefined_symbols): Declare new
	function.
	(set_common_options): Use the new set_write_undefined_symbols in
	this function template.
	* src/abg-dwarf-reader.cc (reader::{get_die_language, die_is_in_c,
	die_is_in_cplus_plus, die_is_in_c_or_cplusplus}): Move these
	member functions into ...
	(get_die_language, die_is_in_c, die_is_in_cplus_plus)
	(die_is_in_c_or_cplusplus): ... these static non-member functions.
	(fn_die_equal_by_linkage_name): Adjust and remove the now useless
	reader parameter.
	(compare_dies, get_scope_die, function_is_suppressed)
	(variable_is_suppressed): Adjust.
	(build_translation_unit_and_add_to_ir): When we are asked to load
	undefined symbol, make sure to also analyze top-level class types
	and if we are in C++, also analyze top-level unions and structs as
	these might also have some undefined interfaces.
	* src/abg-reader.cc (build_elf_symbol_db): Let's not construct and
	return the symbol DB anymore.  Rather, let's let the caller
	construct it, so we can just update it with the input gathered.
	(read_symbol_db_from_input): Support getting undefined function
	and variable symbols from the new undefined-elf-function-symbols
	and undefined-elf-variable-symbols elements.  Note that undefined
	and defined function symbols go into the same symbol DB whereas
	undefined and defined variable symbols go into another symbol DB.
	Now, we suppose that the variable & symbol DBs are allocated by
	the caller.  We pass it down to build_elf_symbol_db that populates
	it.  Maybe we should rename build_elf_symbol_db into
	populate_elf_symbol_db.
	(reader::read_corpus): Allocate the function
	and variable symbol DB and let read_symbol_db_from_input populate
	it.  Sort functions and variables after reading the whole ABIXML.
	* src/abg-writer.cc (write_context::write_context): Define new
	data member.
	(write_context::write_context): Initialize it.
	(write_context::{get,set}::write_undefined_symbols): Define
	accessors.
	(set_write_undefined_symbols): Define a new function.
	(write_context::decl_is_emitted): Add a new overload.
	(write_elf_symbol_reference): Add a writer context and a corpus
	parameter.  If the symbol is not in the corpus or if the symbol is
	undefined and we were not asked to emit undefined symbols then do
	not emit any reference to it.
	(write_translation_unit): Emit the undefined functions and
	variables that belong to the current translation unit, along with
	their reference to the undefined ELF symbol they are associated
	to.
	(write_var_decl, write_function_decl): Let
	write_elf_symbol_reference decide whether it should emit the
	reference to ELF symbol or not, as it now know how to make that
	decision.
	(write_corpus): Write the undefined function & variable ELF symbol
	data bases.  These in the new 'undefined-elf-function-symbols' and
	'undefined-elf-variable-symbols' elements.
	* tools/abidw.cc (options::load_undefined_interfaces): Define new
	data member.
	(options:options): Initialize it.
	(display_usage): Add a help string for the
	--no-load-undefined-interfaces option.
	(parse_command_line): Parse the --no-load-undefined-interfaces
	option.
	(set_generic_options): Set the
	fe_iface::option_type::load_undefined_interfaces option.
	* doc/manuals/abidw.rst: Document the new
	--no-load-undefined-interfaces of abidw.
	* tests/data/test-abicompat/test10/libtest10-with-exported-symbols.so:
	New binary input file.
	* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so:
	New binary input file.
	* tests/data/test-abicompat/test10/libtest10-with-incompatible-exported-symbols.so.abi:
	New abixml input file.
	* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols:
	New binary input file.
	* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.abi:
	New abixml input file.
	* tests/data/test-abicompat/test10/test10-app-with-undefined-symbols.cc:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-0.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-1.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-2.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-3.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-fn-changed-report-4.txt:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-exported-symbols.cc:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-exported-symbols.h:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.cc:
	New source file for binary test input
	* tests/data/test-abicompat/test10/test10-with-incompatible-exported-symbols.h:
	New source file for binary test input.
	* tests/data/Makefile.am: Add new test input files to source
	distribution.
	* tests/test-abicompat.cc (in_out_specs): Add the new test inputs
	to this test harness.
	* tests/test-annotate.cc (main): Use the new
	--no-load-undefined-interfaces option of abidw to keep the old
	behavior.
	* tests/test-read-common.cc (test_task::serialize_corpus): Do not
	emit undefined symbols.
	* tests/test-read-dwarf.cc (test_task_dwarf::perform): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-03-14 16:27:14 +01:00
..
test10 Emit & read undefined interfaces to & from ABIXML 2024-03-14 16:27:14 +01:00
libtest0-fn-changed-libapp-v0.so
libtest0-fn-changed-libapp-v1.so
libtest1-fn-removed-v0.so
libtest1-fn-removed-v1.so
libtest2-var-removed-v0.so
libtest2-var-removed-v1.so
libtest3-fn-removed-v0.so
libtest3-fn-removed-v1.so
libtest4-soname-changed-v0.so
libtest4-soname-changed-v1.so
libtest5-fn-changed-libapp-v0.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest5-fn-changed-libapp-v1.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest6-undefined-var.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest6-var-changed-libapp-v0.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest6-var-changed-libapp-v1.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest7-fn-changed-libapp-btf-v0.so Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
libtest7-fn-changed-libapp-btf-v1.so Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
libtest7-fn-changed-libapp-v0.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest7-fn-changed-libapp-v1.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest8-fn-changed-libapp-v0.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest8-fn-changed-libapp-v1.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest9-fn-changed-v0.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
libtest9-fn-changed-v1.so Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test0-fn-changed-0.suppr
test0-fn-changed-1.suppr
test0-fn-changed-app
test0-fn-changed-app.cc
test0-fn-changed-libapp-v0.cc
test0-fn-changed-libapp-v1.cc
test0-fn-changed-libapp.h
test0-fn-changed-report-0.txt
test0-fn-changed-report-1.txt
test0-fn-changed-report-2.txt
test0-fn-changed-report-3.txt
test1-fn-removed-app
test1-fn-removed-app.cc
test1-fn-removed-report-0.txt
test1-fn-removed-v0.cc
test1-fn-removed-v1.cc
test2-var-removed-app
test2-var-removed-app.cc
test2-var-removed-report-0.txt
test2-var-removed-v0.cc
test2-var-removed-v1.cc
test3-fn-removed-app
test3-fn-removed-app.cc
test3-fn-removed-report-0.txt
test3-fn-removed-v0.cc
test3-fn-removed-v1.cc
test3-fn-removed-version-script-0
test3-fn-removed-version-script-1
test4-soname-changed-app
test4-soname-changed-app.cc
test4-soname-changed-report-0.txt
test4-soname-changed-v0.cc
test4-soname-changed-v1.cc
test5-fn-changed-app Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test5-fn-changed-app.cc
test5-fn-changed-libapp-v0.cc
test5-fn-changed-libapp-v0.h
test5-fn-changed-libapp-v1.cc
test5-fn-changed-libapp-v1.h
test5-fn-changed-report-0.txt
test5-fn-changed-report-1.txt
test6-undefined-var.cc Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test6-var-changed-libapp-v0.cc Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test6-var-changed-libapp-v0.h
test6-var-changed-libapp-v1.cc Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test6-var-changed-libapp-v1.h
test6-var-changed-report-0.txt Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test6-var-changed-report-1.txt Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test6-var-changed-report-2.txt Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test7-fn-changed-app Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test7-fn-changed-app.btf Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
test7-fn-changed-app.c Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
test7-fn-changed-libapp-v0.c Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
test7-fn-changed-libapp-v0.h
test7-fn-changed-libapp-v1.c Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
test7-fn-changed-libapp-v1.h
test7-fn-changed-report-0.1.txt Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
test7-fn-changed-report-0.txt
test7-fn-changed-report-1.txt Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test7-fn-changed-report-2.1.txt Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
test7-fn-changed-report-2.txt Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test8-fn-changed-app Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test8-fn-changed-app.c
test8-fn-changed-libapp-v0.c
test8-fn-changed-libapp-v0.h
test8-fn-changed-libapp-v1.c Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test8-fn-changed-libapp-v1.h
test8-fn-changed-report-0.txt
test9-fn-changed-app Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test9-fn-changed-app.cc Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
test9-fn-changed-report-0.txt
test9-fn-changed-v0.cc
test9-fn-changed-v0.h
test9-fn-changed-v1.cc
test9-fn-changed-v1.h