The Git repository of the Libabigail Project
Go to file
Dodji Seketeli c29f0f2679 corpus: Allow several variables with same ID to be exported
The libQt6Network.so.6.3.1 exhibits some interesting debug info where
two variables with slightly different qualified name have the same ELF
symbol.

Consider the DIE for this variable:
 [ 1aab3]    variable             abbrev: 118
             name                 (GNU_strp_alt) "backendMutex"
             decl_file            (implicit_const) qsslsocket_p.h (42)
             decl_line            (data1) 196
             decl_column          (data1) 26
             linkage_name         (GNU_strp_alt) "_ZN17QSslSocketPrivate12backendMutexE"
             type                 (ref_udata) [ 1aa35]
             external             (flag_present) yes
             declaration          (flag_present) yes
             inline               (implicit_const) declared_inlined (3)
             location             (exprloc)
              [ 0] addr +0x1e3050 <_ZN17QSslSocketPrivate12backendMutexE>

This DIE designates a variable named backendMutex in the global
namespace.  It's associated to the ELF symbol
_ZN17QSslSocketPrivate12backendMutexE.

Then, later, there is this DIE:

 [d05d3e]    class_type           abbrev: 260
             name                 (GNU_strp_alt) "QSslSocketPrivate"
             declaration          (flag_present) yes
             sibling              (ref_udata) [d05d70]
[...]
 [d05d70]    variable             abbrev: 642
             name                 (GNU_strp_alt) "backendMutex"
             decl_file            (implicit_const) qsslsocket_p.h (54)
             decl_line            (data1) 196
             decl_column          (data1) 26
             linkage_name         (GNU_strp_alt) "_ZN17QSslSocketPrivate12backendMutexE"
             type                 (ref_addr) [  fdc5]
             external             (flag_present) yes
             declaration          (flag_present) yes
             inline               (implicit_const) declared_inlined (3)
             location             (exprloc)
              [ 0] addr +0x1e3050 <_ZN17QSslSocketPrivate12backendMutexE>

Here, this DIE represents a static data member named
QSslSocketPrivate::backendMutex, as it's member of the
QSslSocketPrivate class.  Note how it's also associated with the ELF
symbol _ZN17QSslSocketPrivate12backendMutexE.

So both variables are associated with the same ELF symbol and should
thus be exported from the ABI corpus.

Today, only one of these variables is represented as exported in the
corpus.  Depending on the order in which the variables are analyzed,
the variable that is represented as exported might be either one or
the other, leading to some spurious self-comparison errors.

This patch fixes the issue by allowing the corpus to represent more
than one variable having a given ELF symbol to be exported.  This is
similar to what is already for functions.

This fixes the self comparison of the qt6-qtbase package, which can be
witnessed by issuing the command:

    $ fedabipkgdiff --self-compare -a --from fc36 qt6-qtbase

	* include/abg-corpus.h (corpus::lookup_variables): Replace
	corpus::lookup_variable with this one which returns the set of
	variables associated with a given ID of variable.
	* src/abg-corpus-priv.h (istr_var_ptr_set_map_type): Define new
	typedef.
	(corpus::exported_decls_builder::priv::id_vars_map_): Replace
	id_var_map_ with this new data member of type
	istr_var_ptr_set_map_type.
	(corpus::exported_decls_builder::priv::id_fns_map): Fix comment.
	(corpus::exported_decls_builder::priv::id_vars_map): Replace
	previous id_var_map with this member function.
	(corpus::exported_decls_builder::priv::var_id_is_in_id_vars_map):
	Replace the var_id_is_in_id_var_map member function.
	(corpus::exported_decls_builder::priv::var_is_in_vars): Define new
	static member function.
	(corpus::exported_decls_builder::priv::{var_is_in_id_vars_map, add_var_to_id_vars_map}):
	Define new member functions.
	(corpus::exported_decls_builder::priv::add_var_to_map): Remove.
	(corpus::exported_decls_builder::priv::add_var_to_exported):
	Adjust by using the new var_is_in_id_vars_map and
	add_var_to_id_vars_map.
	* src/abg-corpus.cc
	(corpus::exported_decls_builder::maybe_add_var_to_exported_vars):
	Adjust, use the new
	corpus::exported_decls_builder::priv::var_is_in_id_vars_map.
	(corpus::lookup_variables): Replace corpus::lookup_variable with
	this one which returns the set of variables associated with a
	given ID of variable.
	* tools/abicompat.cc
	(compare_expected_against_provided_variables): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-09-06 22:35:22 +02:00
.github
autoconf-archive
bash-completion
big-tests@d84f5ef7b4 big-tests: Update git sub-module 2024-08-29 17:15:44 +02:00
doc abidw: Add a --kmi-stablelist option alongside existing --kmi-whitelist 2024-08-29 17:15:44 +02:00
docker
include corpus: Allow several variables with same ID to be exported 2024-09-06 22:35:22 +02:00
m4
relicensing-scripts
scripts
src corpus: Allow several variables with same ID to be exported 2024-09-06 22:35:22 +02:00
tests ir: Strip typedefs from pointed-to-types during comparison 2024-09-05 17:56:24 +02:00
tools corpus: Allow several variables with same ID to be exported 2024-09-06 22:35:22 +02:00
.clang-format
.gitignore
.gitmodules
.mailmap
abigail.m4
ABIXML-FORMAT-VERSIONS
AUTHORS
ChangeLog
COMMIT-LOG-GUIDELINES
COMPILING
configure.ac ir: Remove the now useless type propagation optimization 2024-08-29 17:15:43 +02:00
CONTRIBUTING
default.abignore
gen-changelog.py
install-sh
libabigail.pc.in
license-change-2020.txt
LICENSE.txt
ltmain.sh
Makefile.am
NEWS
README
README-DOCKER.md
release-text-template.txt
update-copyright.sh
VISIBILITY

This is the Application Binary Interface Generic Analysis and
Instrumentation Library.

It aims at constructing, manipulating, serializing and de-serializing
ABI-relevant artifacts.

The set of artifacts that we are intersted is made of quantities like
types, variable, functions and declarations of a given library or
program.  For a given library or program this set of quantities is
called an ABI corpus.

This library aims at (among other things) providing a way to compare
two ABI Corpora (apparently the plural of corpus is copora, heh,
that's cool), provide detailed information about their differences,
and help build tools to infer interesting conclusions about these
differences.

You are welcome to contribute to this project after reading the files
CONTRIBUTING and COMMIT-LOG-GUIDELINES files in the source tree.

Communicating with the maintainers of this project -- including
sending patches to be include to the source code -- happens via email
at libabigail@sourceware.org.