Bug 22913 - Correctly de-duplicate pointers to anonymous structs inside a given
authorDodji Seketeli <dodji@redhat.com>
Fri, 2 Mar 2018 14:47:15 +0000 (15:47 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 2 Mar 2018 15:49:17 +0000 (16:49 +0100)
commit30314e3a62d15055a4fb484c690840318efcf946
treeca5438a296c7f8ef23f07990924a0f50c3b357bf
parent59c0a2ac7ca8e569f81144e563bb975403b671d5
Bug 22913 - Correctly de-duplicate pointers to anonymous structs inside a given

During type DIE canonicalization, libabigail performs an optimization
while comparing two types defined in the same translation unit.  That
is, inside a given translation unit two pointers that point to a type
named T (that is, two T*) are considered equal.  They are considered
equal without having to structurally compare the two types named T.

This generally makes sense, because if two types of the same kind,
defined in the same translation unit, have the same name then we can
safely conclude that they are actually the same type.  Unless the two
T are anonymous structs.

If the two T are anonymous structs defined in the same translation
unit, we really need to compare them structurally to know if they are
equal or not.

This is what this patch does.

* src/abg-dwarf-reader.cc
(pointer_or_qual_die_of_anonymous_class_type)
(die_is_qualified_type): Define new functions.
(compare_dies): If pointers, reference or qualified type have an
anonymous struct as their underlying type, then we need to
structurally compare the underlying anonymous struct.
* tests/data/test-diff-dwarf/libtest43-PR22913-v{0,1}.so: New
binary test input files.
* tests/data/test-diff-dwarf/test43-PR22913-report-0.txt: New
reference output of the comparison of the two binaries above.
* tests/data/test-diff-dwarf/test43-PR22913-v{0,1}.c: Source code
of the binaries above.
* tests/test-diff-dwarf.cc (in_out_specs): Make the test harness
compare the two binaries above.
* tests/data/Makefile.am: Add the new test files above to the
source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc
tests/data/Makefile.am
tests/data/test-diff-dwarf/libtest43-PR22913-v0.so [new file with mode: 0755]
tests/data/test-diff-dwarf/libtest43-PR22913-v1.so [new file with mode: 0755]
tests/data/test-diff-dwarf/test43-PR22913-report-0.txt [new file with mode: 0644]
tests/data/test-diff-dwarf/test43-PR22913-v0.c [new file with mode: 0644]
tests/data/test-diff-dwarf/test43-PR22913-v1.c [new file with mode: 0644]
tests/test-diff-dwarf.cc