dwarf-reader/writer: consider aliases when dealing with suppressions

When a symbol is suppressed and it happens to be the main symbol of a
group of aliased symbols where another symbol is not suppressed, the
dwarf reader discards the DWARF information upon reading and the writer
will not be able to connect dwarf information to the aliased elf symbol.

In order to address this, ensure we are not suppressing symbols
(actually functions and variables) for which an alias is not suppressed.
We therefore keep the DWARF information even if only a non-main symbol
is asked for.

Likewise, when the abg-writer is having to attach an elf-symbol-id to
the DWARF collected information (for functions and variables), instead
of omitting the symbol altogether, rather make use of the property of
aliases and connect the dwarf information to an alias instead. This way
the function dwarf information stays connected to the elf symbol that we
want to track.

When reading from XML with a symbol whitelist that leads to suppression
of aliased symbols, abidiff would hit an assertion and crash when
looking up the aliased symbol due to it being suppressed. In the new
symtab reader we can still suppress a symbol without removing it from
the lookup. Make use of that property to fix this bug.

A test has been added for this as well.

	* src/abg-dwarf-reader.cc(function_is_suppressed): Do not suppress
	  a function for which there is an alias that is not suppressed.
	(variable_is_suppressed): Likewise for variables.
	* src/abg-reader.cc (build_elf_symbol): Improve handling of
	suppressed aliased symbols when reading from XML.
	* src/abg-symtab-reader.cc (load): Likewise.
	* src/abg-writer.cc(write_elf_symbol_reference): Fall back to
	  any aliased symbol if the main symbol is suppressed.
	* tests/data/Makefile.am: Add new test files.
	* tests/data/test-abidiff-exit/test-missing-alias-report.txt: New test file.
	* tests/data/test-abidiff-exit/test-missing-alias.abi: Likewise.
	* tests/data/test-abidiff-exit/test-missing-alias.suppr: Likewise.
	* tests/test-abidiff-exit.cc: Add support for whitelists and add
	new testcase.
	* tests/data/test-read-dwarf/test-suppressed-alias.c: New test file.
	* tests/data/test-read-dwarf/test-suppressed-alias.o: Likewise.
	* tests/data/test-read-dwarf/test-suppressed-alias.o.abi: Likewise.
	* tests/data/test-read-dwarf/test-suppressed-alias.suppr: Likewise.
	* tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-1.suppr: Likewise.
	* tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-2.suppr: Likewise.
	* tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-3.suppr: Likewise.
	* tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test3-alias-4.suppr: Likewise.
	* tests/test-read-dwarf.cc: Add new test cases.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: I0dff1449f1becc0cc1f3c041cd67cc265273ee4c
25 files changed