public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH 8/8, applied] RHBZ 1925886 - Compare anonymous types without qualified names
Date: Wed, 11 Aug 2021 18:11:32 +0200	[thread overview]
Message-ID: <87czqkc66j.fsf@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 4645 bytes --]

Hello,

An anonymous struct/union is, by definition an entity that is not
named (unless a naming typedef is provided for it).

It turns out that in C++ binaries, there are anonymous types that are
logically equivalent (as far as ABI is concerned) because they have
the same members and layout, but turn out to be evaluated as being
different because they are defined in different name spaces.  And
because they are not named, showing them as being different just
because of their name space doesn't bring anything but spurious error
reporting.

Consider the DWARF representing this:

struct S
{
  union
  {
   int a;
   int b;
  } member;
};

where the 'member' is of type S::<anonymous-union>.

Probably due to LTO, we see some DWARF that represents the type of
'member' as just <anonymous-union>, in some translation units.

I could not generate that DWARF from a small test case, myself.  But
it comes from the binary 'usr/bin/lto-dump', from the
https://bugzilla.redhat.com/show_bug.cgi?id=1925886 problem report.

So in that case, we want the S::<anonymous-union> to compare equal to
the <anonymous-union>, otherwise, this produces spurious type changes,
especially when doing self comparison.

This is what this patch does.

	* include/abg-fwd.h (is_anonymous_type): Constify this function.
	* src/abg-ir.cc (equals): In the overload for decl_base, do not
	take scope of anonymous types into account.  In the overload for
	array_type_def do not peel of typedefs.  This is not directly
	related to anonymous types, but it make comparison more robust
	against naming typedefs used for anonymous types in array
	elements.
	(get_type_name): Do not take into account the scope of anonymous
	types when building internal representation of types.  Note that
	the internal representation is what is used for canonicalization.
	This means that all anonymous types are compared against each
	others during type canonicalization.
	* src/abg-reader.cc (build_class_decl): Do not try to re-use
	anonymous types, just like we already do for DWARF.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* 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-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.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/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/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/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 include/abg-fwd.h                             |     2 +-
 src/abg-ir.cc                                 |    28 +-
 src/abg-reader.cc                             |    11 +-
 .../data/test-annotate/test17-pr19027.so.abi  |   430 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |    21 +-
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |    15 +-
 .../test31-pr18535-libstdc++-report-0.txt     |     4 +-
 .../test31-pr18535-libstdc++-report-1.txt     |     4 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    |  3983 ++---
 .../test-read-dwarf/test-libaaudio.so.abi     |     2 +-
 .../test-read-dwarf/test-libandroid.so.abi    |   281 +-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |   232 +-
 .../test-read-dwarf/test11-pr18828.so.abi     |   635 +-
 .../test-read-dwarf/test12-pr18844.so.abi     |  2782 ++-
 .../test-read-dwarf/test16-pr18904.so.abi     | 14034 ++++++++-------
 .../test-read-dwarf/test17-pr19027.so.abi     |   417 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |    20 +-
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |    14 +-
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 14786 ++++++++--------
 .../test9-pr18818-clang.so.abi                |  3298 ++--
 20 files changed, 20359 insertions(+), 20640 deletions(-)

The patch is big so I am attaching it gzipped.


[-- Attachment #2: 0008-RHBZ-1925886-Compare-anonymous-types-without-qualifi.patch.gz --]
[-- Type: application/gzip, Size: 455124 bytes --]

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]



-- 
		Dodji

                 reply	other threads:[~2021-08-11 16:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87czqkc66j.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).