Bug 18892 - type degradation from DWARF to abixml on libtsan.so

abidiff-ing libtsan.so again the output of abidw libtsan.so does not
yield the empty set.  This is because some types, especially an enum (in
certain cases) when read (de-serialized) from DWARF doesn't hash the
same as when de-serialized from abixml.

This is because an enum type can have a linkage name, referred to by
the DW_AT_linkage_name DWARF attribute.  This linkage_name was being
read from DWARF but wasn't serialized to abixml.  At de-serialization
time, well, the linkage_name information was lost.  Oops.

Also, I have seen that in some case we can canonicalize enum types too
early, when we de-serialize them from abixml, before we are done
building them.

This patch addresses these issues.

	* src/abg-reader.cc (read_context::maybe_canonicalize_type): Late
	canonicalize enum types.
	(build_enum_type_decl): Read the linkage name of the enum type.
	* src/abg-writer.cc (write_enum_type_decl): Emit the linkage name
	of the enum type.
	* tests/data/test-read-dwarf/test15-pr18892.so: New binary test
	input.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: New test
	output reference.
	* tests/data/Makefile.am: Add the new test inputs above to source
	distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Run the two tests above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2015-08-30 17:56:19 +02:00
parent 60cdabd931
commit a4b9f670fe
6 changed files with 93261 additions and 3 deletions

View File

@ -718,7 +718,8 @@ public:
&& !is_reference_type(t)
&& !is_pointer_type(t)
&& !is_qualified_type(t)
&& !is_typedef(t))
&& !is_typedef(t)
&& !is_enum_type(t))
canonicalize(t);
else
schedule_type_for_late_canonicalizing(t);
@ -2927,6 +2928,10 @@ build_enum_type_decl(read_context& ctxt,
if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "name"))
name = xml::unescape_xml_string(CHAR_STR(s));
string linkage_name;
if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "linkage-name"))
linkage_name = xml::unescape_xml_string(CHAR_STR(s));
location loc;
read_location(ctxt, node, loc);
@ -2974,7 +2979,7 @@ build_enum_type_decl(read_context& ctxt,
shared_ptr<enum_type_decl> t(new enum_type_decl(name, loc,
underlying_type,
enums));
enums, linkage_name));
if (ctxt.push_and_key_type_decl(t, id, add_to_current_scope))
{
ctxt.map_xml_node_to_decl(node, t);

View File

@ -1447,6 +1447,9 @@ write_enum_type_decl(const enum_type_decl_sptr decl,
do_indent(o, indent);
o << "<enum-decl name='" << xml::escape_xml_string(decl->get_name()) << "'";
if (!decl->get_linkage_name().empty())
o << " linkage-name='" << decl->get_linkage_name() << "'";
write_location(decl, o);
string i = id;

View File

@ -277,6 +277,8 @@ test-read-dwarf/test13-pr18894.so \
test-read-dwarf/test13-pr18894.so.abi \
test-read-dwarf/test14-pr18893.so \
test-read-dwarf/test14-pr18893.so.abi \
test-read-dwarf/test15-pr18892.so \
test-read-dwarf/test15-pr18892.so.abi \
\
test-diff-filter/test0-v0.cc \
test-diff-filter/test0-v1.cc \

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -121,11 +121,16 @@ InOutSpec in_out_specs[] =
"data/test-read-dwarf/test13-pr18894.so.abi",
"output/test-read-dwarf/test13-pr18894.so.abi",
},
{
{
"data/test-read-dwarf/test14-pr18893.so",
"data/test-read-dwarf/test14-pr18893.so.abi",
"output/test-read-dwarf/test14-pr18893.so.abi",
},
{
"data/test-read-dwarf/test15-pr18892.so",
"data/test-read-dwarf/test15-pr18892.so.abi",
"output/test-read-dwarf/test15-pr18892.so.abi",
},
// This should be the last entry.
{NULL, NULL, NULL}
};