This patch adds support for the DW_AT_data_bit_offset DWARF 5
attribute. Note that this attribute has been introduced in prior
versions of DWARF, but since the version 5, it supersedes the
DW_AT_bit_offset attribute.
Note that Libabigail was wrongly interpreting the DW_AT_bit_offset
attribute. It was considering it as the offset of the bit field data
member, starting from the least significant bit of the containing
structure. That is not the case on little endian machines,
unfortunately.
So this patch fixes that mistake.
So with this patch, we can now compare a binary using DW_AT_bit_offset
against a binary using DW_AT_data_bit_offset and expect things to work
correctly.
The problem is that abixml files generated with Libabigail versions
prior to this patch contain bit field data member offset values that
are not compatible with those contained in abixml files generated with
this version, onward.
So I guess a subsequent patch is needed to introduce a new abixml
version string (maybe "2.0") that would be deemed incompatible with
the previous "1.0" one. That way, we can prevent comparing 2.0 abixml
files against 1.0 ones in abidiff, for instance.
For now, the patch adjusts the various abixml files to make them
reflect the proper representation of DW_AT_bit_offset on little endian
machines.
* src/abg-dwarf-reader.cc (read_and_convert_DW_at_bit_offset):
Define new static function.
(die_member_offset): Primarily use DW_AT_data_bit_offset if its
present. Otherwise, look for DW_AT_bit_offset. Use the new
read_and_convert_DW_at_bit_offset function to properly interpret
DW_AT_bit_offset if its present. Update comment.
* tests/data/test-diff-filter/test-PR26684-dwarf{4,5}.o: New
binary test inputs.
* tests/data/test-diff-filter/test-PR26684.c: Source code of the
new binary test inputs above.
* tests/data/test-diff-filter/test-PR26684-report-0.txt: New
reference test output.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-diff-filter.cc (in_out_specs): Add the test inputs
above to this test harness.
* tests/data/test-annotate/test13-pr18894.so.abi: Adjust.
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
Adjust.
* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt:
Adjust.
* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Adjust.
* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
Adjust.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Adjust.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Adjust.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Adjust.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When running fedabipkgdiff as:
fedabipkgdiff --self-compare -a --from fc33 nfs-utils
I am getting:
Error encountered while running fedabipkgdiff with error message:
Running it with the --verbose option yields more clue, though.
It turns out that fedabipkgdiff runs abipkgdiff on an RPM and gives it
the wrong associated -debuginfo RPM.
This is because the member function
RPMCollection.get_sibling_debuginfo() doesn't returns the "first"
debuginfo package that comes with a given RPM. In the case of the
package nfs-utils-2.5.2-1.rc4.fc33.aarch64.rpm, it was using the
package nfs-utils-coreos-debuginfo-2.5.2-1.rc4.fc33.aarch64.rpm
instead of the package nfs-utils-debuginfo-2.5.2-1.rc4.fc33.aarch64.rpm.
So, of course, abipkgdiff could not find the proper debuginfo for the
binaries carried by nfs-utils-2.5.2-1.rc4.fc33.aarch64.rpm.
This happens only in cases where there a several debuginfo packages
for a given RPM. In that case, we need to be more careful to select
the right debuginfo package and not just a random one.
This patch adds a RPMCollection.get_matching_debuginfo() member function
that does the right thing. It thus teaches
generate_comparison_halves() to use the new function.
* tools/fedabipkgdiff (RPMCollection::get_sibling_debuginfo):
Update comment.
(RPMCollection::get_matching_debuginfo): Define new function.
(generate_comparison_halves): Use
RPMCollection::get_matching_debuginfo instead of
RPMCollection::get_sibling_debuginfo.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When running Libabigail on Fedora 34 it appeared that we don't support
DW_FORM_line_strp in the fast string comparison scheme, during DIE
de-duplication.
This patch fixes that.
* src/abg-dwarf-reader.cc (compare_dies_string_attribute_value):
Support DW_FORM_line_strp.
* tests/data/test-diff-pkg/sshpass-1.07-1.fc34.x86_64-self-check-report-0.txt:
New reference test output.
* tests/data/test-diff-pkg/sshpass-1.07-1.fc34.x86_64.rpm: New
test input.
* tests/data/test-diff-pkg/sshpass-debuginfo-1.07-1.fc34.x86_64.rpm:
Likewise.
* tests/data/Makefile.am: Add the new testing material above to
source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Add the test input above
to this harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When running fedabipkgdiff on the gawk-5.1.0-2.fc33.aarch64.rpm
package we get this error message:
Error encountered while running fedabipkgdiff with error message:
That is not a very useful error message to say the least.
The issue is that abipkgdiff returns with an "unknown error" which is
due to the fact that the gawk package contains a directory that is
owned by root. As abipkgdiff tries to write temporary files into that
directory, it fails to do so.
The patch now writes the temporary ABIXML file into a sub-directory
that is not owned the package where we should have write privileges.
It also improves error reporting.
* tools/abipkgdiff.cc (options::pkg{1,2}): Add new data members to
store the packages to compare and have them available for the
various functions that may need them down the road.
(package::create_abi_file_path): Add new function.
(compare_to_self): Use the new package::create_abi_file_path to
create the path to the ABI file in a directory not owned by the
package. That should increase our chances of having the rights to
write that one. Make sure to emit error message when the
comparison against self fails.
({compare_task, self_compare_task}::perform): During the process
of comparison if an internal error happens, report it. Cleanup
the existing reporting a little bit.
(pkg_extraction_task::perform): Fix comment.
* tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When compiling with clang, it (rightfully) complains about an operator
precedence issue:
abipkgdiff.cc:1646:7: error: operator '?:' has lower precedence than '<<'; '<<' will be evaluated first [-Wparentheses]
? string("Comparison against self SUCCEEDED\n")
^
Fix that by properly placing the parentheses. Also, drop the superfluous
string conversion.
* tools/abipkgdiff.cc (compare_to_self): address clang warning.
Signed-off-by: Matthias Maennich <maennich@google.com>
At the core of this issue, Libabigail is failing to canonicalize some
types in some cases. And that is triggering the assertion at the end
of hash_as_canonical_type_or_constant when emitting ABIXML.
It turns out read_context::canonicalize_types_scheduled in the dwarf
reader sometimes fails to canonicalize the types contained in
read_context::extra_types_to_canonicalize().
This patch fixes that.
Incidentally, this patch also fixes a previous issue where
hash_as_canonical_type_or_constant would hit that assert at its end
because of non-canonicalized function types. I am now removing the
band-aid I put in place at the time by loosening the assertion there.
* src/abg-dwarf-reader.cc
(read_context::canonicalize_types_scheduled): Don't forget to
canonicalize types stored in extra_types_to_canonicalize_.
* src/abg-ir.cc (type_base::get_canonical_type_for): Add better
comment.
(hash_as_canonical_type_or_constant): Remove crutch that is
useless now that we canonicalize almost all types in the system.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Support we have a type struct S and a type T defined as:
typedef struct S T;
Today, Libabigail considers that the two pointers "struct S*" and "T*"
are different.
The problem is that this can cause spurious change reports (as
reported by (abidw --abidiff) in binaries where we have the same type
defined more than once, each time using a different various around
this theme.
This patch make libabigail to now consider that "struct S*" and "T*"
are equal. It does the same for references and arrays.
* src/abg-ir.cc (equals): In the overloads for pointer_type_def,
reference_type_def and array_type_def, compare the pointed-to-type
modulo typedefs.
* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Adjust.
* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
Adjust.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
While looking at several ABIXML files I noticed that several (member)
functions didn't have any associated ELF symbol and that in some cases,
there were even duplicated member functions. Those are the source of
some spurious changes sometimes reported by abidiff.
In DWARF the same function F can be represented several times. One
representation of F has some properties and other representations of F
might have properties that complement the properties carried by the
former representations. It's the unions of the properties of all
representations of F that constitute the properties of F.
An example of that "linked" nature is how DWARF represents inlined
functions. A function F can be inlined somewhere else. That inlined
version is called F', for instance. The DWARF representation of F'
will carry a DW_AT_abstract_origin attribute that points back to F to
signify that F' is the concrete inlined version of the abstract F.
F' will carry properties that are specific to its "inlined nature"
whereas F will carry properties that are more generic and independent
from all its various potential inlined forms.
So when Libabigail sees the DWARF representation of F, if it's
associated with an ELF symbol, then it must wait to encounter an F'
representation that is associated with an ELF symbol before adding an
internal representation (IR) of F into the final IR graph. Otherwise
the IR of F can be unnecessarily duplicated, with some instances
having an associated ELF symbol and others not.
This is what this patch does, in essence. While working on this, I
encountered some tangential issues that needed to be fixed altogether
for the whole to function. A lot of regression tests output had to be
adjusted.
In the end, a number of spurious change reports could be fixed;
notably reports about removal of destructors like STR::~STR(int).
Note how that destructor has a parameter; it's a GCC-specific
implementation detail that should not appear at this level, I believe.
* include/abg-ir.h (class_or_union::string_mem_fn_sptr_map_type):
Add a typedef for unordered_map<string, method_decl_sptr>.
(class_or_union::find_member_function_sptr): Declare new function.
* src/abg-ir.cc (class_or_union::priv::mem_fns_map_): Change the
type of this to string_mem_fn_sptr_map_type, so that shared
pointers to functions can be stored in the map, instead of bare
pointers to functions. This is useful to implement
class_or_union::find_member_function_sptr which returns a shared
pointer to function.
(class_or_union::find_member_function_sptr): Define new function.
(class_or_union::find_member_function): Adjust.
(method_decl::set_linkage_name): Use a non-deleting shared pointer
to store the current instance of member function into
class_or_union::priv::mem_fns_map_.
(hash_as_canonical_type_or_constant): As we are seeing more
function types, it appears that some function types are not
canonicalized. I am not sure why exactly, but let's loosen the
assert here for now, I'll chase the root of this later.
* src/abg-dwarf-reader.cc (finish_member_function_reading):
Improve detection of member function 'static-ness' by handling
cases where a this pointer can be const. Also support
DW_AT_object_pointer when it's present. This fixes the occurrence
of spurious change reports about loss of 'static-ness' of member
functions.
(potential_member_fn_should_be_dropped): Define new static
function and ...
(build_ir_node_from_die): ... use it here. When a function DIE
has the same linkage name as an existing function IR, do not
create a new IR for it. Rather, re-use the existing one to
complete it with the properties found on the function DIE. If a
new function doesn't seem to have an associated ELF symbol and is
not meant to be a virtual member function then drop its IR on the
floor as well.
* tests/data/test-annotate/libtest23.so.abi: Adjust.
* 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/test0.abi: Likewise.
* tests/data/test-annotate/test1.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/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
* tests/data/test-annotate/test6.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-diff-dwarf/test0-report.txt: Likewise.
* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Likewise.
* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Likewise.
* tests/data/test-diff-filter/test0-report.txt: Likewise.
* tests/data/test-diff-filter/test01-report.txt: Likewise.
* tests/data/test-diff-filter/test10-report.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt: Likewise.
* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt: Likewise.
* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-1.txt: Likewise.
* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
* tests/data/test-diff-filter/test9-report.txt: Likewise.
* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Likewise.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-1.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-10.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-12.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-14.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-16.txt: Likewise.
* tests/data/test-diff-suppr/test24-soname-report-4.txt: Likewise.
* tests/data/test-diff-suppr/test31-report-1.txt: 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/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-libandroid.so.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/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/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/test6.so.abi: Likewise.
* tests/data/test-read-dwarf/test6.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.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sometimes when a symbol S' of a function F' aliases the symbol S of a function
F, the ABIXML reader might not add F' back into the set of exported
functions of the ABI corpus (as the DWARF reader has done initially).
That results in the apparent 'loss' of F' (and S') from the corpus.
This is due to the way F' is identified, using function_decl::get_id.
In the case where the symbol S' of F' has aliases,
function_decl::get_id (wrongly) uses the linkage name of F' as the
identifier. If F' and F happen to have the same linkage name and if F
is already in the set of exported functions of the corpus then F'
won't be added into that set.
To solve that problem, this patch makes function_decl::get_id
construct an ID that ensures that F and F' always have different IDs.
* src/abg-ir.cc (function_decl::get_id): If the elf symbol has
aliases, make the function name be part of the ID so that this ID
differs from the one of the other functions that share a symbol
alias with this one.
* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust.
* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise.
* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Likewise.
* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-diff-pkg/glibc-2.32-3.fc33.aarch64-self-check-report-0.txt:
New test reference output.
* tests/data/test-diff-pkg/glibc-2.32-3.fc33.aarch64.rpm: New test
input RPM.
* tests/data/test-diff-pkg/glibc-debuginfo-2.32-3.fc33.aarch64.rpm:
Likewise.
* tests/data/Makefile.am: Add the new test material to source
distribution.
* tests/test-diff-pkg.cc (in_out_specs): Add the new test input
RPMs to this test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is a common micro optimization suggested by clang-tidy to improve
string::find performance. I have not done any measurements as to how it
impacts performance for that particular piece of code, but generally
this overload is to prefer here.
* src/abg-ir.cc (elf_symbol::get_name_and_version_from_id):
use character literal overload for single character string::find.
(parse_integral_type): Likewise.
Suggested-by: Chris Kennelly <ckennelly@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
When a declaration of a class, named H, matches more than one
definition (let's call them D) of H (in several other translation
units of the abi corpus) then H is left unresolved; that is, H is
considered as being a declaration-only class. Note that down the
road, H will compare different to all those Ds.
However when those Ds are all equal, it turns out that this can lead
to issues down the road. This is because conceptually, H equals D.
But then by not resolving H to D (and there are several Ds), we
artificially create a situation where H is different from D. We can
even create situations where those Ds are different among themselves.
So doing comparisons inevitably leads to spurious changes.
This is the root cause of the issue described in this bug at
https://sourceware.org/bugzilla/show_bug.cgi?id=26992.
To fix the issue, this patch thus resolves H to D when the different
Ds are all equal.
Note that a similar thing should be done for the process of resolving
declaration-only enums as well. But I don't have an issue reproducer
at hand involving enums at the moment, so I am adding a comment to
read_context::resolve_declaration_only_enums for now.
I have also filled the enhancement request
https://sourceware.org/bugzilla/show_bug.cgi?id=27189 to track a task
that would do away with read_context::resolve_declaration_only_enums
altogether by factorizing out the resolution of declaration-only
abigail::ir::decl_base.
* src/abg-dwarf-reader.cc
(read_context::compare_before_canonicalisation): Define new member
function.
(read_context::resolve_declaration_only_classes): When there are
more than one definition that can resolve a given declaration, if
all those definitions are equal, then resolve the declaration to
those definitions.
(read_context::resolve_declaration_only_enums): Add a comment to
update similarly update this function (or do away with it
completely) later.
* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-diff-pkg/cogl-1.22.8-2.fc33.x86_64.rpm: Add new
test input.
* tests/data/test-diff-pkg/cogl-debuginfo-1.22.8-2.fc33.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/cogl-1.22.8-2.fc33.x86_64.self-check-report-0.txt:
Likewise.
* tests/test-diff-pkg.cc (in_out_specs): Add the new test inputs
to the test harness.
* tests/data/Makefile.am: Add the new test input files to source
distribution.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
We can now use the latest upstream stable version since we bumped up our
minimum C++ standard version.
* tests/lib/catch.hpp: update to v2.13.3
* tests/test-symtab.cc (TEST_CASE("Symtab::SimpleSymtabs")): Use
the corpus variable to avoid unused variable warnings.
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is mostly seen for nested templates like
std::pair<int, std::vector<int> > vs. std::pair<int, std::vector<int>>
^^^ ^^
* .clang-format: Set C++11 standard for formatting.
Signed-off-by: Matthias Maennich <maennich@google.com>
The test file test0-pr19026-libvtkIOSQL-6.1.so.1 is intended to be
used to check that diffing a binary entity against its ABI
representation results in an empty diff. In this case, the ABI of the
library is also under revision control and so the test also functions
to a certain extent as check on whether the generated ABI is stable
between revisions of libabigail.
Recent changes have affected attributes and ordering of elements. The
result is that there is now a non-empty diff between the library and
the saved ABI, albeit all "harmless" changes.
This commit refreshes the revision-controlled ABI, eliminating the
differences.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
Refreshed ABI.
* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1-report-0.txt:
File now empty.
Signed-off-by: Giuliano Procida <gprocida@google.com>
std::unordered_set is now provided through the language standard, hence
remove the compatibility code for <unordered_set> and adjust all users
accordingly.
* include/abg-cxx-compat.h: Drop compatibility for <unordered_set>.
* include/abg-comparison.h: migrate abg_compat use to std.
* include/abg-interned-str.h: Likewise.
* include/abg-suppression.h: Likewise.
* src/abg-comparison-priv.h: Likewise.
* src/abg-dwarf-reader.cc: Likewise.
* tests/test-diff-suppr.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
Signed-off-by: Matthias Maennich <maennich@google.com>
std::unordered_map is now provided through the language standard, hence
remove the compatibility code for <unordered_map> and adjust all users
accordingly.
* include/abg-cxx-compat.h: Drop compatibility layer for <unordered_map>.
* include/abg-comparison.h: migrate abg_compat use to std.
* include/abg-cxx-compat.h: Likewise.
* include/abg-fwd.h: Likewise.
* include/abg-ir.h: Likewise.
* src/abg-corpus.cc: Likewise.
* src/abg-dwarf-reader.cc: Likewise.
* src/abg-ir.cc: Likewise.
* src/abg-reader.cc: Likewise.
* src/abg-writer.cc: Likewise.
Signed-off-by: Matthias Maennich <maennich@google.com>
std::hash is now provided through the language standard, hence remove
the compatibility code for <functional> and adjust all users
accordingly.
* include/abg-cxx-compat.h: Drop compatibility layer for <functional>.
* include/abg-interned-str.h: migrate abg_compat use to std.
* include/abg-ir.h: Likewise.
* src/abg-hash.cc: Likewise.
* src/abg-ir.cc: Likewise.
Signed-off-by: Matthias Maennich <maennich@google.com>
Now with C++11 as minimum standard, we can drop the facilities required
to support earlier standards. Hence purge the use of std::tr1 from the
sources.
* include/abg-cxx-compat.h: remove compatibility with pre C++11.
* include/abg-ir.h: Remove mention of std::tr1 from comments.
* include/abg-sptr-utils.h: Likewise.
Signed-off-by: Matthias Maennich <maennich@google.com>
This change adds a test which exercises libabigail's handling of
qualified typedefs of arrays. The base type in the test case is an
array of pointers (chosen so we can also use restrict).
Various typedefs and (indirect) qualifications of this type are
created. In all cases, the resulting type should be an array of
qualified pointers.
However, abidiff reports things like
'const volatile void* const'
changed to
'restrict const volatile volatile void* const'
I've not attempted to check whether DWARF and ABI XML faithfully
reflect the source types. There may be trouble there as well.
For the record, these are the expected v0 types:
A = void *[7]
B = void *[7]
C = void *const[7]
D = void *const[7]
E = void *const volatile[7]
F = void *const volatile[7]
G = void *const volatile restrict[7]
H = void *const volatile restrict[7]
The v1 types should be these plus others with extra pointer
qualifiers.
* tests/data/Makefile.am: Add new test files
* tests/data/test-abidiff-exit/qualifier-typedef-array-v0.c:
New test file.
* tests/data/test-abidiff-exit/qualifier-typedef-array-v0.o:
New test file.
* tests/data/test-abidiff-exit/qualifier-typedef-array-v1.c:
New test file.
* tests/data/test-abidiff-exit/qualifier-typedef-array-v1.o:
New test file.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-0.txt:
Plain diff report.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
Harmless diff report.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-2.txt:
Leaf changes report.
* tests/data/test-abidiff-exit/qualifier-typedef-array-report-3.txt:
Harmless leaf changes report.
* tests/test-abidiff-exit.cc: Run new test.
Signed-off-by: Giuliano Procida <gprocida@google.com>
As described in the comments of types_have_similar_structure:
"Two indirect types have similar structure if their underlying
types are of the same kind and have the same name. [...] The size
of their underlying type does not matter"
Yet, the size of array elements (a.k.a the underlying type of an array
type) is wrongly considered to matter when assessing the "type
structure similarity" relationship for arrays.
This patch fixes that.
* src/abg-ir.cc (types_have_similar_structure): When examining
array types, always treat element types as being underlying types
of an indirect type.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-non-leaf-array-report.txt:
New test case showing correct --leaf-changes-only reporting.
* tests/data/test-abidiff-exit/test-non-leaf-array-v0.c:
Likewise.
* tests/data/test-abidiff-exit/test-non-leaf-array-v0.o:
Likewise.
* tests/data/test-abidiff-exit/test-non-leaf-array-v1.c:
Likewise.
* tests/data/test-abidiff-exit/test-non-leaf-array-v1.o:
Likewise.
* tests/test-abidiff-exit.cc: Run new test case.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-ir.cc (types_have_similar_structure): Arrays are also
indirect types, just like pointers and references, for the purpose
of the concept of "type similarity". Add that to the introductory
comment of the function. Add some more misc comments throughout
the code base.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-leaf-reporter.cc (leaf_reporter::report): In the
corpus_diff override, conclude by calling
maybe_dump_diff_tree.
Signed-off-by: Giuliano Procida <gprocida@google.com>
As the Enterprise Linux 6 platform has now essentially reached it's
end of life for what it's worth (the Fedora EPEL6 distribution is not
maintained anymore) nothing ties us to using C++03 only anymore.
So, I think it makes sense to move the code base to the C++11
standard.
Why C++11 and not, say, C++14 or more? Well, the more direct reason I
see is that we need to support long life cycle platforms, the older
one being Enterprise Linux 7 currently. This is the Fedora EPEL7
distribution, in concrete terms. And in that distribution, the
compiler is GCC 4.8.x. And it supports C++11.
In practise, nothing changes in the code that is already there.
The new code however can use C++11 constructs just fine.
I have updated the CONTRIBUTING file to write down some of the
unwritten cultural biases of the current code base. Hopefully these
few lines will help to shed some light on the choices made so far.
The update to that file also enacts the use of C++11 and sets some
limits to what we expects in terms of what the code base would look
like.
configure.ac is modified to unconditionally pass -std=c++11 to the
compiler and express that in the configuration text displayed at the
end of the configuration stage.
Some Makefile.am files are updated accordingly.
* CONTRIBUTING: Enact use of c++11. Also, we favor those who
read/debug/maintain the code as opposed to those who write it ;-)
* configure.ac: Switch to c++11 unconditionally.
* src/Makefile.am: Adjust.
* tests/Makefile.am: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The COPYING* files are not in the source distribution anymore.
Furthermore, LICENSE.txt and license-change-2020.txt files were newly
added. This patch updates Makefile.am accordingly.
* Makefile.am: Teach Automake that COPYING* files are gone and
that LICENSE.txt and license-change-2020.txt were added.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Add a license-change-2020.txt file which contains text explaining that
we went through a licence change in 2020 from LGPLv3+ to Apache-v2
with LLVM exception.
* license-change-2020.txt: New file.
Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
* relicensing-scripts/file-licenses.orig.txt: New file that
contains the raw set of files with SPDX identifiers denoting
LGPLv3+ files. It's the result of a simple command based on
"find" and "grep".
* relicensing-scripts/files-with-lgplv3.txt: New file
containing the same data as the file above, but massaged to be
easily useable by the script below.
* relicensing-scripts/do-relicensing.sh: This is a simple command
which performs the re-licensing on the files listed in the file
above.
Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
This script is to replace an SPDX license ID by another one.
I.e, it's to perform an actual re-licensing of a given file.
A way to use the script is this:
replace-spdx-license.sh --from LGPL-3.0-or-later \
--to "Apache-2.0 WITH LLVM-exception" \
some-file-to-relicense.cc
* relicensing-scripts/replace-spdx-license.sh: New script.
Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
Add a script to detect if a file has a SPDX header and what the
advertised license is.
* relicensing-scripts/has-spdx-header.sh: New script.
Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
This patch replaces license headers with SPDX identifiers in all files
containing license headers. For each file, the SPDX identifier
formally represents its current license. Note that the list of SPDX
identifiers is available on the SPDX web site at
https://spdx.org/licenses.
For autoconf-archive/ax_prog_python_version.m4 however, there is a
little catch. Dodji Seketeli wrote this ax_check_python_modules.m4.
Just like the other autoconf-archive macros, it makes sense to have it
under the FSF All Permissive license. Actually, the terms of that
license was already in the file but then the license header was
wrongly set to GPLv2 with autoconf exception. So I fixed that in this
commit by setting the SPDX identifier to FSFAP.
* abigail.m4: Replace the license header with the SPDX identifier
GPL-3.0-or-later WITH GCC-exception-3.1
* autoconf-archive/ax_check_python_modules.m4: Correctly set the
SPDX identifier to FSFAP.
* autoconf-archive/ax_compare_version.m4: Replace the license
header with the SPDX identifier FSFAP.
* autoconf-archive/ax_prog_python_version.m4: Likewise.
header with the SPDX identifier FSFAP.
* autoconf-archive/ax_valgrind_check.m4: Likewise.
* gen-changelog.py: Replace the license header with the SPDX
identifier LGPL-2.0-or-later.
* include/abg-comp-filter.h: Replace the license header with the
SPDX identifier LGPL-3.0-or-later.
* include/abg-comparison.h: Likewise.
* include/abg-config.h: Likewise.
* include/abg-corpus.h: Likewise.
* include/abg-cxx-compat.h: Replace the license header with the
SPDX identifier LGPL-2.0-or-later.
* include/abg-diff-utils.h: Replace the license header with the
SPDX identifier LGPL-3.0-or-later
* include/abg-dwarf-reader.h: Likewise.
* include/abg-fwd.h: Likewise.
* include/abg-hash.h: Likewise.
* include/abg-ini.h: Likewise.
* include/abg-interned-str.h: Likewise.
* include/abg-ir.h: Likewise.
* include/abg-libxml-utils.h: Likewise.
* include/abg-libzip-utils.h: Likewise.
* include/abg-reader.h: Likewise.
* include/abg-regex.h: Likewise.
* include/abg-reporter.h: Likewise.
* include/abg-sptr-utils.h: Likewise.
* include/abg-suppression.h: Likewise.
* include/abg-tools-utils.h: Likewise.
* include/abg-traverse.h: Likewise.
* include/abg-viz-common.h: Likewise.
* include/abg-viz-dot.h: Likewise.
* include/abg-viz-svg.h: Likewise.
* include/abg-workers.h: Likewise.
* include/abg-writer.h: Likewise.
* install-sh: Replace the license header with the SPDX identifier MIT.
* ltmain.sh: Replace the license header with the SPDX identifier
GPL-2.0-or-later. Note that this file has the libtool special
exception which allows us to redistribute it under the general
license of the project.
* src/abg-comp-filter.cc: Replace the license header with the SPDX
* src/abg-comparison-priv.h: Likewise.
* src/abg-comparison.cc: Likewise.
* src/abg-config.cc: Likewise.
* src/abg-corpus-priv.h: Likewise.
* src/abg-corpus.cc: Likewise.
* src/abg-default-reporter.cc: Likewise.
* src/abg-diff-utils.cc: Likewise.
* src/abg-dwarf-reader.cc: Likewise.
* src/abg-elf-helpers.cc: Likewise.
* src/abg-elf-helpers.h: Likewise.
* src/abg-regex.cc: Likewise.
* src/abg-hash.cc: Likewise.
* src/abg-ini.cc: Likewise.
* src/abg-internal.h: Likewise.
* src/abg-ir-priv.h: Likewise.
* src/abg-ir.cc: Likewise.
* src/abg-leaf-reporter.cc: Likewise.
* src/abg-libxml-utils.cc: Likewise.
* src/abg-libzip-utils.cc: Likewise.
* src/abg-reader.cc: Likewise.
* src/abg-reporter-priv.cc: Likewise.
* src/abg-reporter-priv.h: Likewise.
* src/abg-sptr-utils.cc: Likewise.
* src/abg-suppression-priv.h: Likewise.
* src/abg-suppression.cc: Likewise.
* src/abg-tools-utils.cc: Likewise.
* src/abg-traverse.cc: Likewise.
* src/abg-viz-common.cc: Likewise.
* src/abg-viz-dot.cc: Likewise.
* src/abg-viz-svg.cc: Likewise.
* src/abg-workers.cc: Likewise.
* src/abg-writer.cc: Likewise.
* tests/lib/catch.cc: Likewise.
* tests/lib/catch.hpp: Add an SPDX identifier BSL-1.0.
* tests/mockfedabipkgdiff.in: Replace the license header with the
SPDX identifier GPL-3.0-or-later.
* tests/print-diff-tree.cc: Likewise.
* tests/runtestfedabipkgdiff.py.in: Replaace the license header
with the SPDW identifier GPL-3.0-or-later.
* tests/test-abicompat.cc: Replace the license header with the
SPDX identifier LGPL-3.0-or-later.
* tests/test-abidiff-exit.cc: Likewise.
* tests/test-abidiff.cc: Likewise.
* tests/test-alt-dwarf-file.cc: Likewise.
* tests/test-annotate.cc: Likewise.
* tests/test-cxx-compat.cc: Likewise.
* tests/test-core-diff.cc: Likewise.
* tests/test-diff-dwarf-abixml.cc: Likewise.
* tests/test-diff-dwarf.cc: Likewise.
* tests/test-diff-filter.cc: Likewise.
* tests/test-diff-pkg.cc: Likewise.
* tests/test-diff-suppr.cc: Likewise.
* tests/test-diff2.cc: Likewise.
* tests/test-dot.cc: Replace the license header with the
SPDX identifier GPL-3.0-with-GCC-exception.
* tests/test-elf-helpers.cc: Replace the license header with the
SPDX identifier LGPL-3.0-or-later.
* tests/test-ini.cc: Likewise.
* tests/test-ir-walker.cc: Likewise.
* tests/test-kmi-whitelist.cc: Likewise.
* tests/test-lookup-syms.cc: Likewise.
* tests/test-read-dwarf.cc: Likewise.
* tests/test-read-write.cc: Likewise.
* tests/test-svg.cc: Replace the license header with the SPDX
identifier GPL-3.0-with-GCC-exception.
* tests/test-symtab.cc: Replace the license header with the SPDX
identifier LGPL-3.0-or-later.
* tests/test-tools-utils.cc: Likewise.
* tests/test-types-stability.cc: Likewise.
* tests/test-utils.cc: Likewise.
* tests/test-utils.h: Likewise.
* tests/test-write-read-archive.cc: Likewise.
* tools/abiar.cc: Likewise.
* tools/abicompat.cc: Likewise.
* tools/abidiff.cc: Likewise.
* tools/abidw.cc: Likewise.
* tools/abilint.cc: Likewise.
* tools/abipkgdiff.cc: Likewise.
* tools/abisym.cc: Likewise.
* tools/binilint.cc: Likewise.
* tools/fedabipkgdiff: Replace the license header with the
SPDX identifier GPL-3.0-or-later.
* tools/kmidiff.cc: Likewise.
Signed-off-by: Benjamin De Kosnik <bkoz@gnu.org>
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Ondrej Oprala <ondrej.oprala@gmail.com>
Signed-off-by: Roland McGrath <roland@hack.frob.com>
Signed-off-by: Sinny Kumari <ksinny@gmail.com>
Signed-off-by: Slava Barinov <v.barinov@samsung.com>
* Makefile.am: Make 'make tarball-and-all' run the
'check-self-compare' target as part of the release process.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It's useful to be able to force the build system into avoiding the use
of rpm 4.15 version or higher. That version of RPM is the one that
supports RPMs from Fedora 31 or higher. Those RPMs use the zstd
compression scheme. Prior to Fedora 31, RPM were not using the zstd
compression scheme. So, systems with rpm version lower than 4.15
cannot deal with RPMs coming from Fedora 31 or higher. So on those
systems, some regression tests of libabigail who use RPMs from Fedora
33 will fail.
With this patch, one can use the --disable-rpm415 option of the
configure script to prevent those tests from running on those pre 4.15
rpm systems.
* configure: Introduce the --{en, dis}able-rpm415 option.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sometimes a DW_TAG_partial_unit (imported via a DW_TAG_imported_unit)
has no children node. That means the the DW_TAG_partial_unit has no
sub-tree.
In those cases, the dwarf-reader crashes when
ctxt.build_die_parent_relations_under tries to record the point at
which the sub-tree (which is non-existent here) of the partial unit is
imported by the DW_TAG_imported_unit DIE.
This patch avoids crashing in those cases. As this problem is
reported on libclang-cpp.so (on Fedora 33) which takes "abidw --abidiff"
five hours and ~ 20GB of ram to complete at this point (on a power7 box)
this patch doesn't have a regression test attached.
* src/abg-dwarf-reader.cc (die_has_children): Define new static
function.
(read_context::build_die_parent_relations_under): Do not try to
instantiate an imported_unit_point type for an imported unit with
no children node.
(imported_unit_point::imported_unit_point): Assert that the
imported die has a sub-tree.
(imported_unit_point::imported_unit_point): Remove useless spaces.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-writer.cc (write_array_subrange_type): Fix off-by-one
error in assertion.
* src/abg-dwarf-reader.cc (build_subrange_type): Assert the length
of the array complies with its bounds.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Now that several subtle causes of spurious ABI change report when
comparing a binary against its own ABIXML have been addressed, this
patch makes 'abipkgdiff --self-check' to fail on any ABI change
reported. That is, harmless changes are not ignored anymore.
* tools/abipkgdiff.cc (compare_to_self): Report *any* ABI change.
Not just the "net" changes.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Sometimes, "abidw --abidiff <binary>" would pass while
"abidw <binary> > abi; abidiff <binary> abi" would fail.
This is because "abidw --abidiff" emits an error only when the
comparison between the binary and its ABIXML representation yields and
incompatible change.
Now that many subtle causes of spurious ABI change report emitted when
comparing a binary against its own ABIXML have been fixed, this patch
makes it so that *any* change would make abidw --abidiff to emit an
error.
* tools/abidw.cc (load_corpus_and_write_abixml): Emit an error
when comparing the binary to its ABIXML representation yields any
change.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In the DWARF debug info, a C++ class can be represented by pieces
throughout a given binary.
In this picture, a given virtual member function can be represented
several times; each time in one different piece of the C++ class. In
a given piece of the class, a virtual member function can be
represented with its ELF symbol set. In another one, the same virtual
member function can be represented without that ELF symbol set. And
there can also be pieces of the class that don't have a given virtual
function.
To handle this, the DWARF reader constructs one class from all its
pieces scattered around. It adds each virtual member function to the
class as it comes across them while scanning the DWARF.
Then there is a pass at the end of the process that sets ELF symbols
to the (virtual) member functions that need it.
The problem with that pass is that it sometimes sets the same ELF
symbol to more than one virtual member function. Those virtual member
functions all have the same mangled name that correspond to the ELF
symbol; but only one of them is meant to be associated with the ELF
symbol. In essence, that one is the one that is exported by the ELF
binary.
This patch teaches the pass that sets the ELF symbols of function to
avoid setting the same ELF symbol to more than one function.
The patch also avoids build_function_decl to set symbol to a function
if that symbol was already set to an existing function.
This patch thus fixes a class of issues what arise when comparing a
binary against its own ABIXML representation. Those several functions
having the same ELF symbol would cause spurious changes in that
context.
* src/abg-dwarf-reader.cc
(read_context::symbol_already_belongs_to_a_function): Define new
member function.
(read_context::fixup_functions_with_no_symbols): Use the new
symbol_already_belongs_to_a_function function to avoid setting a
symbol that already belongs to a function.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When reading an anonymous declaration-only class from ABIXML
libabigail forgets to set the is-anonymous class. This leads to
spurious change reports when comparing a binary against its ABIXML
representation. Fixed thus.
Note that this doesn't yet impact any regression test but is useful
for a coming patch that will make abidw --abidiff to emit an error for
all ABI changes, not just the hard incompatible ones. Without this
change, that coming patch will make runtestreaddwarf to fail.
* src/abg-reader.cc (build_class_decl): Set the is-anonymous flag
when reading a decl-only class.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
There are two views for internal pretty representation of anonymous
classes.
1/ When we look at the anonymous class itself, we use its 'flat
representation' i.e:
'class {int blah; char bleh;}'
2/ When we look at a pointer or a reference to the anonymous class we
use its generic anonymous internal name, i.e:
'__anonymous_struct__*'
As a general rule, libabigail always use the keyword 'class' to prefix
the name of classes for internal purposes, independent from the fact
that the type is a struct or a class. That is a pre-requisite to be
able to canonicalize classes and structs together. In other words, if
a class and a struct are structurally equal, they are going to be
considered equivalent by the canonicalization process.
Currently however, in the view 1/ of the pretty representation of
anonymous classes, a struct and a class will have different
representations. For instance, and empty anonymous struct would be
represented as 'struct {}', whereas an empty anonymous class would be
represented as 'class {}'. This prevents these two be considered
equivalent by the canonicalization process. This leads to spurious
change reports later down the road.
In the view 2/ we have a similar but different problem: the qualified
names of the anonymous classes are not taken into account when
representing pointer or references to said anonymous classes. Only
their unqualified generic anonymous internal names are taken into
account in the representation. This leads to pointers/references to
anonymous classes being wrongly considered equivalent even when they
belong to different namespaces.
This patch corrects the issues related to both views 1/ and 2/. It
should make libabigail correctly consider some anonymous classes as
equivalent (view 1) and correctly consider pointers/references to
anonymous classes as different when they belong to different
namespaces (view 2).
A number of reference tests are adjusted accordingly.
* include/abg-fwd.h (get_class_or_union_flat_representation):
Introduce an "internal" parameter.
* src/abg-ir.cc (get_class_or_union_flat_representation):
Introduce an "internal" parameter. In the flat representation of
a class for internal purposes, always use the prefix "class" even
if this is a struct.
(get_type_name): To build an internal name for a
reference or pointer to an anonymous type, consider the namespace
name of said type.
(equals): In the overload for decl_base, take the namespace name
of anonymous decls into account when comparing them.
({var_decl, union_decl}::get_pretty_representation): Adjust calls
to get_class_or_union_flat_representation to pass a proper
"internal" argument.
* src/abg-default-reporter.cc (default_reporter::report): Adjust
the call to get_class_or_union_flat_representation to pass an
"internal" argument set to 'false'.
* tests/data/test-annotate/libtest23.so.abi: Adjust.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
* tests/data/test-read-dwarf/libtest23.so.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/test9-pr18818-clang.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>