libabigail/include
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
..
abg-btf-reader.h Update the copyright notice for the BTF reader 2023-01-06 21:40:44 +01:00
abg-comp-filter.h suppression: Add "has_strict_flexible_array_data_member_conversion" property 2023-11-15 09:55:08 +01:00
abg-comparison.h ir,corpus,comparison: Const-iffy the access to corpus interfaces 2024-03-01 14:19:05 +01:00
abg-config.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-corpus.h Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
abg-ctf-reader.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-cxx-compat.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-diff-utils.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-dwarf-reader.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-elf-based-reader.h Make fe_iface::initialize independent from the kind of interface 2023-07-07 13:34:15 +02:00
abg-elf-reader.h Add support for undefined symbols in the BTF reader 2024-03-14 16:27:07 +01:00
abg-fe-iface.h Represent undefined corpus interfaces to analyze app compatibility 2024-03-14 16:26:54 +01:00
abg-fwd.h ir,dwarf-reader: Peel const-qualifier from const this pointers 2024-03-06 14:02:55 +01:00
abg-hash.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-ini.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-interned-str.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-ir.h ir,dwarf-reader: Better handle inline-ness setting or detection 2024-03-04 09:49:02 +01:00
abg-libxml-utils.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-reader.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-regex.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-reporter.h Bug 30260 - Support pointer-to-member type 2023-12-01 15:43:53 +01:00
abg-sptr-utils.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-suppression.h suppression: Add "has_strict_flexible_array_data_member_conversion" property 2023-11-15 09:55:08 +01:00
abg-tools-utils.h abipkgdiff: Initialize libxml2 to use it in a multi-thread context 2023-09-07 15:23:38 +02:00
abg-traverse.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-version.h.in abidw: Add --abixml-version 2021-11-12 18:31:28 +01:00
abg-viz-common.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-viz-dot.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-viz-svg.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-workers.h Update copyright year for 2023 2023-01-01 18:19:30 +01:00
abg-writer.h Emit & read undefined interfaces to & from ABIXML 2024-03-14 16:27:14 +01:00
Makefile.am Add support for BTF 2023-01-06 21:05:53 +01:00