public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] Bug 28450 - Fix cloned member function handling in DWARF
@ 2021-11-12 17:36 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2021-11-12 17:36 UTC (permalink / raw)
  To: libabigail

Hello,

When the DWARF reader encounters a function DIE 'f' that has a
DW_AT_specification that points to a member function, the current
implementation creates a function IR for the member function.  The
problem is that the member function has no ELF symbol associated to
it.  The ELF symbol is associated to 'f', not to the member function.
The DWARF reader then wrongly drops the member function on the floor
because it has no ELF symbol function associated.  So that member
function specification never gets its concrete function represented in
the IR.

This patch fixes the issue by detecting that the member function is
the "specification" for 'f' and that the ELF symbol associated to it
might not be there.  In that case, if the ELF symbol is on the 'f' DIE
itself, we get it from there.

The patch makes more member functions to be represented so it uncovers
a latent issue which is explained below.

Today, some compilers can emit redundant DWARF constructs like "const
reference" or "const void".  A reference is always const so the const
is superfluous.  A similar thing can be said about "const void".
maybe_strip_qualification detects those constructs and rewrites the IR
into a "no-op qualified reference", or a "no-op qualified void".  The
no-op was needed in the previous incarnations of the DWARF reader
because it was expecting a 'qualified type' IR to be associated to a
qualified type DIE.  Note, however, that that expectation has been
generally relaxed since then.

The problem is that the comparison engine, when building the diff IR
needs to strip those no-op qualified types off, to avoid having
spurious change diagnostics.  That stripping introduces some
challenges because the tree is more or less un-mutable at that point
(after type canonicalization) so the stripping can only be partial.

This patch removes the no-op qualified types altogether, rather than
trying harder to handle them down the line.  In other words,  a const
reference is now represented as a reference and a const void as a
void.  This makes things much simpler.

The problem however is that the in-memory IR (and thus the emitted
ABIXML) doesn't have any no-op qualified type anymore.  So comparing
an old ABIXML that contains those no-op qualified types against its
origin ELF corpus can yield some spurious diagnostics.  To fix it, one
needs to re-generate the ABIXML file.

This patch bumps the ABIXML version to 2.1 and introduces a new
ABIXML-FORMAT-VERSIONS file that documents the format changes.

	* ABIXML-FORMAT-VERSIONS: New file that documents the version
	changes of the ABIXML-FORMAT-VERSIONS.
	* include/abg-fwd.h (look_through_no_op_qualified_type): Remove
	this function declaration.
	(strip_useless_const_qualification): Declare new function
	declaration.
	* src/abg-comparison.cc (compute_diff_for_types): Avoid stripping
	off no-op-qualified types as these beasts don't exist anymore.
	(redundancy_marking_visitor::visit_end): Allow a variable which
	type has local changes to be considered redundant if its type is
	itself redundant.
	* src/abg-config.cc (config::config): Bump the abixml version from
	2.0 to 2.1.
	* src/abg-dwarf-reader.cc (maybe_strip_qualification): Factorize
	out the new strip_useless_const_qualification function from here.
	(build_or_get_fn_decl_if_not_suppressed): If the function is
	created but doesn't have an ELF symbol associated to it, then
	update it so that the ELF symbol can be associated.  Otherwise,
	potential_member_fn_should_be_dropped might later drop that
	function on the floor because it doesn't have any ELF symbol
	associated.
	* src/abg-ir.cc (strip_useless_const_qualification): Define this,
	which is has been factorized out of maybe_strip_qualification.
	(look_through_no_op_qualified_type): Remove this definition.
	(equals): In the overload for reference_type_def, do not peel
	typedefs off from the reference before comparison.  This is now
	useless as the comparison infrastructure got a lot better.  In the
	overload for references, stop using
	look_through_no_op_qualified_type as this function doesn't exist
	anymore.
	* src/abg-tools-utils.cc (abidiff_status_has_error): Detect when
	there is a usage error as well.
	* tests/data/test-types-stability/PR28450-libepetra.so.13.0: Add
	new testing binary to the repository.
	* tests/data/Makefile.am: Add the new testing binary above to
	source distribution.
	* tests/test-types-stability.cc (elf_paths): Add the new test to
	this test harness.
	* tests/test-diff-dwarf-abixml.cc (main): Add better error messages.
	* tests/data/test-abidiff-exit/test-member-size-report0.txt: Adjust.
	* tests/data/test-annotate/libtest23.so.abi: Likewise.
	* 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/test-anonymous-members-0.o.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test1.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.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/test6.so.abi: Likewise.
	* tests/data/test-annotate/test7.so.abi: Likewise.
	* tests/data/test-annotate/test8-qualified-this-pointer.so.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-libaaudio.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/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.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/test3-alias-1.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.abi: Likewise.
	* tests/data/test-read-dwarf/test4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.abi: Likewise.
	* tests/data/test-read-dwarf/test5.o.hash.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/test7.so.abi: Likewise.
	* tests/data/test-read-dwarf/test7.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.
	* tests/data/test-read-write/test-crc.xml: Likewise.
	* tests/data/test-read-write/test26.xml: Likewise.
	* tests/data/test-read-write/test27.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to the master branch.

---
 ABIXML-FORMAT-VERSIONS                        |    67 +
 include/abg-fwd.h                             |     6 +-
 src/abg-comparison.cc                         |    22 +-
 src/abg-config.cc                             |     2 +-
 src/abg-dwarf-reader.cc                       |    39 +-
 src/abg-ir.cc                                 |    76 +-
 src/abg-tools-utils.cc                        |     2 +-
 tests/data/Makefile.am                        |     1 +
 .../test-member-size-report0.txt              |     6 +-
 tests/data/test-annotate/libtest23.so.abi     |   194 +-
 .../test-annotate/libtest24-drop-fns-2.so.abi |   352 +-
 .../test-annotate/libtest24-drop-fns.so.abi   |   352 +-
 .../test-anonymous-members-0.o.abi            |    10 +-
 tests/data/test-annotate/test0.abi            |    32 +-
 tests/data/test-annotate/test1.abi            |    18 +-
 .../data/test-annotate/test13-pr18894.so.abi  |     2 +-
 .../data/test-annotate/test14-pr18893.so.abi  | 16629 +++++---
 .../data/test-annotate/test15-pr18892.so.abi  | 14971 ++++---
 .../data/test-annotate/test17-pr19027.so.abi  | 23331 ++++++++---
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  9439 +++--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi | 19508 +++++----
 tests/data/test-annotate/test2.so.abi         |     2 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 17546 ++++++---
 .../data/test-annotate/test21-pr19092.so.abi  |     2 +-
 tests/data/test-annotate/test3.so.abi         |     2 +-
 tests/data/test-annotate/test4.so.abi         |     2 +-
 tests/data/test-annotate/test5.o.abi          |     2 +-
 tests/data/test-annotate/test6.so.abi         |    10 +-
 tests/data/test-annotate/test7.so.abi         |     6 +-
 .../test8-qualified-this-pointer.so.abi       |    12 +-
 .../test0-pr19026-libvtkIOSQL-6.1.so.1.abi    |  8552 ++--
 tests/data/test-diff-dwarf/test0-report.txt   |    32 +-
 .../test28-vtable-changes-report-0.txt        |     3 -
 .../test42-PR21296-clanggcc-report0.txt       |    11 +-
 tests/data/test-diff-filter/test0-report.txt  |    36 +-
 tests/data/test-diff-filter/test01-report.txt |    36 +-
 tests/data/test-diff-filter/test10-report.txt |    11 +-
 .../test30-pr18904-rvalueref-report0.txt      |   338 +-
 .../test30-pr18904-rvalueref-report1.txt      |   344 +-
 .../test30-pr18904-rvalueref-report2.txt      |   344 +-
 .../test31-pr18535-libstdc++-report-0.txt     |    46 +-
 .../test31-pr18535-libstdc++-report-1.txt     |    46 +-
 .../test35-pr18754-no-added-syms-report-0.txt |   236 +-
 .../test35-pr18754-no-added-syms-report-1.txt |     6 +-
 .../data/test-diff-filter/test41-report-0.txt |   106 +-
 tests/data/test-diff-filter/test9-report.txt  |    11 +-
 ...-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt |   161 +-
 ...bb-4.3-3.20141204.fc23.x86_64-report-0.txt |   259 +-
 ...bb-4.3-3.20141204.fc23.x86_64-report-1.txt |   142 +-
 .../test24-soname-report-1.txt                |    13 +-
 .../test24-soname-report-10.txt               |    13 +-
 .../test24-soname-report-12.txt               |    13 +-
 .../test24-soname-report-14.txt               |    13 +-
 .../test24-soname-report-16.txt               |    13 +-
 .../test24-soname-report-4.txt                |    13 +-
 .../data/test-diff-suppr/test31-report-1.txt  |    11 +-
 .../PR22015-libboost_iostreams.so.abi         |   332 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    |  3993 +-
 .../PR24378-fn-is-not-scope.abi               |     2 +-
 .../data/test-read-dwarf/PR25007-sdhci.ko.abi |     2 +-
 .../PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi |     2 +-
 .../test-read-dwarf/PR26261/PR26261-exe.abi   |     2 +-
 .../test-read-dwarf/PR27700/test-PR27700.abi  |     2 +-
 tests/data/test-read-dwarf/libtest23.so.abi   |   193 +-
 .../libtest24-drop-fns-2.so.abi               |   350 +-
 .../test-read-dwarf/libtest24-drop-fns.so.abi |   324 +-
 .../data/test-read-dwarf/test-PR26568-1.o.abi |     2 +-
 .../data/test-read-dwarf/test-PR26568-2.o.abi |     2 +-
 .../test-read-dwarf/test-libaaudio.so.abi     |   264 +-
 .../test-read-dwarf/test-libandroid.so.abi    |  3062 +-
 .../test-suppressed-alias.o.abi               |     2 +-
 tests/data/test-read-dwarf/test0.abi          |    30 +-
 tests/data/test-read-dwarf/test0.hash.abi     |    10 +-
 tests/data/test-read-dwarf/test1.abi          |    14 +-
 tests/data/test-read-dwarf/test1.hash.abi     |     8 +-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |  3351 +-
 .../test-read-dwarf/test11-pr18828.so.abi     | 11744 +++---
 .../test-read-dwarf/test12-pr18844.so.abi     | 18574 ++++-----
 .../test-read-dwarf/test13-pr18894.so.abi     |     2 +-
 .../test-read-dwarf/test14-pr18893.so.abi     | 10091 +++--
 .../test-read-dwarf/test15-pr18892.so.abi     | 12866 +++---
 .../test-read-dwarf/test16-pr18904.so.abi     | 16376 ++++----
 .../test-read-dwarf/test17-pr19027.so.abi     | 18295 ++++++---
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  7511 ++--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi | 16418 +++++---
 tests/data/test-read-dwarf/test2.so.abi       |     2 +-
 tests/data/test-read-dwarf/test2.so.hash.abi  |     2 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 14431 ++++---
 .../test-read-dwarf/test21-pr19092.so.abi     |     2 +-
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 32596 +++++++++-------
 .../test-read-dwarf/test3-alias-1.so.hash.abi |     2 +-
 .../test-read-dwarf/test3-alias-2.so.hash.abi |     2 +-
 .../test-read-dwarf/test3-alias-3.so.hash.abi |     2 +-
 .../test-read-dwarf/test3-alias-4.so.hash.abi |     2 +-
 tests/data/test-read-dwarf/test3.so.abi       |     2 +-
 tests/data/test-read-dwarf/test3.so.hash.abi  |     2 +-
 tests/data/test-read-dwarf/test4.so.abi       |     2 +-
 tests/data/test-read-dwarf/test4.so.hash.abi  |     2 +-
 tests/data/test-read-dwarf/test5.o.abi        |     2 +-
 tests/data/test-read-dwarf/test5.o.hash.abi   |     2 +-
 tests/data/test-read-dwarf/test6.so.abi       |     7 +-
 tests/data/test-read-dwarf/test6.so.hash.abi  |     5 +-
 tests/data/test-read-dwarf/test7.so.abi       |     5 +-
 tests/data/test-read-dwarf/test7.so.hash.abi  |     5 +-
 .../test8-qualified-this-pointer.so.abi       |     9 +-
 .../test8-qualified-this-pointer.so.hash.abi  |     7 +-
 .../test9-pr18818-clang.so.abi                |    34 +-
 tests/data/test-read-write/test-crc.xml       |     2 +-
 tests/data/test-read-write/test26.xml         |     2 +-
 tests/data/test-read-write/test27.xml         |     2 +-
 .../test28-without-std-fns-ref.xml            |     2 +-
 .../test28-without-std-vars-ref.xml           |     2 +-
 .../PR28450-libepetra.so.13.0                 |   Bin 0 -> 11875576 bytes
 tests/test-diff-dwarf-abixml.cc               |    10 +-
 tests/test-types-stability.cc                 |     1 +
 115 files changed, 180097 insertions(+), 104325 deletions(-)
 create mode 100644 ABIXML-FORMAT-VERSIONS
 create mode 100644 tests/data/test-types-stability/PR28450-libepetra.so.13.0
--

This patch is too big to be sent to the list so you can read it at
https://sourceware.org/git/?p=libabigail.git;a=commit;h=861e4670b611b2f95d69f68bb1edaa15ab5f3aa5

Cheers,


		Dodji


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-12 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-12 17:36 [PATCH, applied] Bug 28450 - Fix cloned member function handling in DWARF Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).