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>