libabigail/include
Dodji Seketeli 1bb3461d1d Bug 19638 - DWARF reader fails to link clone function to its declaration
There are three mains issues that cause the reported problem.  Let's
look at them closely.

Suppose there is a DIE of a member function Klass::clone_of_foo, which
is a clone of the DIE of the function Klass_foo, which is the concrete
instance of the DIE of the declaration of Klass::foo.

When libabigail's DWARF reader sees the DIE for Klass::clone_of_foo,
it fails to get the context of the declaration of Klass::clone_of_foo
-- which is Klass::foo.

So, in the model built by libabigail, the symbol of
Klass::clone_of_foo never gets associated to Klass::foo.  It thus
looks like Klass::clone is never defined.  It also looks like that
symbol is unreferenced.  From there, a number of bad things happen.
This is the first root cause of the reported problem.  I call it issue
1/.

2/ While looking at this, I noticed that libabigail uses the
underlying symbol name of a given function as the linkage name of that
function, rather than using the value of the DW_AT_linkage_name DWARF
property.  This usually works, until the the function has a symbol
which has several aliases.  In that case, depending on the symbol
alias that is used, a given function can have different linkage names.
This causes problems later at comparison time.  This is issue 2/.

3/ I also noticed that in the libabigail model, even if type Klass
does have all its member functions (including Klass::foo) defined in
in a particular translation unit TU1 , the same Klass in another
translation unit TU2 might not have that Klass::foo defined, just
because that function is not used in TU2.  So after type
canonicalization, if the version of Klass that is kept is the one from
TU2, we end up with a type Klass *NOT* having Klass::foo defined.
Sometimes, it's just that one member function in the canonical type
doesn't have any underlying symbol, whereas the same member function
in another type of the same class of equivalence as the canonical type
does have that an underlying symbol.  This is issue 3/.

To address issue 1/ the patch fixes build_ir_node_from_die, in the
case where a DW_TAG_subprogram DIE is being handled.  It fixes the
case of finding the root interface of the clone of a function
definition.  The patch also fixes a bug in build_function_decl that
prevents it to update the linkage name of a function, *if* that
function already had one.  This was preventing build_function_decl to
adjust the linkage name of a function which is a clone of an original
function which already had a non-empty linkage name.

To address 2/ the patch makes function_decl::get_id return the linkage
name of the function, *if* it exists (rather than primarily returning
the ID of the underlying symbol).

To address 3/ the patch implements the copying of member functions or
underlying function symbols missing from the canonical type -- but
otherwise present in the type that has just been canonicalized.

	* include/abg-ir.h (decl_base::set_linkage_name): Make this member
	function virtual.
	(class_decl::string_mem_fn_ptr_map_type): Define new member type.
	(class_decl::find_member_function): Declare new member function.
	(copy_member_function): Declare new function.  Declare it as
	friend of class_decl.
	(method_decl::set_linkage_name): Declare an overload for this
	virtual function.
	* src/abg-dwarf-reader.cc (build_function_decl): Allow updating of
	linkage_name even if the linkage_name was already defined.
	(build_ir_node_from_die): In the case DW_TAG_subprogram, make the
	lookup of scope of the DIE work even if it has both an abstract
	origin and a specification (DW_AT_abstract_origin and
	DW_AT_specification).
	* src/abg-ir.cc (maybe_adjust_canonical_type): Define new
	function.
	(canonicalize): Use it.
	(function_decl::get_id): Return the linkage name first, if it
	exist.
	(class_decl::priv::mem_fns_map_): New data member.
	(class_decl::find_member_function): Define new member function.
	(class_decl::method_decl::set_linkage_name): Likewise.
	(class_decl::add_member_function): Update the new data member
	class_decl::priv::mem_fns_map_.
	(copy_member_function): Define new static function.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Adjust.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Adjust.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-02-17 16:30:01 +01:00
..
abg-comp-filter.h Bug 17649 Avoid endless looping on diff graph with cycles 2015-02-21 15:16:48 +01:00
abg-comparison.h Bug 19596 - Incorrect exit status for incompatible ABI change 2016-02-10 21:31:53 +01:00
abg-config.h Add --version option to several libabigail tools 2015-11-16 12:54:10 +01:00
abg-corpus.h Add function lookup by linkage name to libabigail::corpus 2016-02-17 14:20:43 +01:00
abg-diff-utils.h Constify some diff-utils functor operators 2015-09-21 10:46:06 +02:00
abg-dwarf-reader.h Bug 19138 - Failure to relate variables address from DWARF and ELF 2016-01-08 22:38:58 +01:00
abg-fwd.h [PERF] Pass a bunch of perf-sensitive smart pointers by reference 2015-12-11 11:19:57 +01:00
abg-hash.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-ini.h Support source_location_not_in and source_location_not_regexp suppressions 2015-09-16 20:54:40 +02:00
abg-ir.h Bug 19638 - DWARF reader fails to link clone function to its declaration 2016-02-17 16:30:01 +01:00
abg-libxml-utils.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-libzip-utils.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-reader.h Introduce the concept of environment 2015-09-07 23:35:29 +02:00
abg-sptr-utils.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-tools-utils.h Prefix abidiff error message with the 'abidiff' program name 2016-02-12 10:12:38 +01:00
abg-traverse.h Canonicalize types either early or late after TU reading 2015-02-18 21:32:37 +01:00
abg-version.h.in Add --version option to several libabigail tools 2015-11-16 12:54:10 +01:00
abg-viz-common.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-viz-dot.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-viz-svg.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-workers.h Use worker threads pattern to speed up some tests 2016-01-18 18:23:18 +01:00
abg-writer.h Update copyright years 2015-01-07 17:52:10 +01:00
Makefile.am Use worker threads pattern to speed up some tests 2016-01-18 18:23:18 +01:00