Commit Graph

2194 Commits

Author SHA1 Message Date
Dodji Seketeli
e89bf5abe8 Peel array types when peeling pointers from a type
In peel_typedef_pointer_or_reference_type, we want to peel typedefs
and pointer types (in general) from a given type.  We need to peel
array types as well, as those are conceptually a pointer-like type as
well.

This patch does that.

	* src/abg-ir.cc (peel_typedef_pointer_or_reference_type): In the
	overloads for type_base_sptr and type_base*, peel array type off
	as well.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 11:58:02 +02:00
Dodji Seketeli
fa5ff32afb Fix DWARF type DIE canonicalization
While looking at something else, I noticed that the DWARF type DIE
canonicalization code wasn't taking the type of array elements into
account when comparing arrays.

This patch fixes that.

	* src/abg-dwarf-reader.cc (compare_dies): When comparing array
	type DIEs, take into account the type of the elements of the
	arrays.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 11:39:04 +02:00
Dodji Seketeli
073185e7ab Miscellaneous indentation and comments cleanups
While looking at something else, I did some indentation and comments cleanups.

	* src/abg-ir.cc (environment::priv::{config_, canonical_types_,
	sorted_canonical_types_, void_type_, variadic_marker_type_}):
	Re-indent these data members.
	(peel_typedef_pointer_or_reference_type): Fix comment.
	(var_decl::var_decl): Likewise.
	(function_decl::function_decl): Add a comment.
	* src/abg-reader.cc (handle_reference_type_def): Fix indentation
	of parameters.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 11:26:14 +02:00
Dodji Seketeli
26c41c060b Fix thinko in configure.ac
* configure.ac: Fix a thinko I spotted while looking at something
	else.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-25 10:38:16 +02:00
Dodji Seketeli
1656f9dd7b reader: Use xmlFirstElementChild/xmlNextElementSibling to iterate over children elements
Use xmlFirstElementChild/xmlNextElementSibling to iterate over element
children nodes rather than doing it by hand in the various for loops.

	* src/abg-reader.cc (walk_xml_node_to_map_type_ids)
	(read_translation_unit, read_translation_unit_from_input)
	(read_symbol_db_from_input, build_needed)
	(read_elf_needed_from_input, read_corpus_group_from_input)
	(build_namespace_decl, build_elf_symbol_db, build_function_decl)
	(build_function_type, build_array_type_def, build_enum_type_decl)
	(build_class_decl, build_union_decl, build_function_tdecl)
	(build_class_tdecl, build_type_composition)
	(build_template_tparameter): Use
	xmlFirstElementChild/xmlNextElementSibling rather than poking at
	xmlNode::children and looping over xmlNode::next by hand.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-03 17:15:25 +02:00
Dodji Seketeli
09c7a773a3 reader: Use xmlFirstElementChild and xmlNextElementSibling rather than xml::advance_to_next_sibling_element
The xml::advance_to_next_sibling_element is redundant with the
xmlNextElementSibling API of libxml.  Similarly, xmlFirstElementChild
is redundant with using xml::advance_to_next_sibling_element on the
xmlNode::children data member.  Let's use the libxml API instead.

	* include/abg-libxml-utils.h (advance_to_next_sibling_element):
	Remove the declaration of this function.
	* src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay)
	(advance_to_next_sibling_element): Remove definitions of these functions.
	* src/abg-reader.cc (read_translation_unit_from_input)
	(read_elf_needed_from_input, read_corpus_group_from_input): Use xmlNextElementSibling instead
	of xml::advance_to_next_sibling_element.
	(read_corpus_from_input): Likewise.  Also, use
	xmlFirstElementChild instead of
	xml::advance_to_next_sibling_element on the xmlNode::children data
	member.
	(read_corpus_group_from_input): use xmlFirstElementChild instead
	of xml::advance_to_next_sibling_element on the xmlNode::children
	data member.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-03 17:15:22 +02:00
Dodji Seketeli
dd55550355 reader: Handle 'abi-corpus' element being possibly empty
This problem was reported at https://sourceware.org/bugzilla/show_bug.cgi?id=27616.

The abixml reader wrongly assumes that the 'abi-corpus' element is
always non-empty.  Note that until now, the only emitter of abixml
consumed in practice was abg-writer.cc and it only emits non-empty
'abi-corpus' elements.  So the issue wasn't exposed.

So, the reader assumes that an 'abi-corpus' element has at least a
text node.

For instance, consider this minimal input file named test-v0.abi:

    $cat test-v0.abi

    <abi-corpus-group architecture='elf-arm-aarch64'>
     <abi-corpus path='vmlinux' architecture='elf-arm-aarch64'>
     </abi-corpus>
    </abi-corpus-group>

    $

Now, compare it to this file where the abi-corpus element is an empty
element (doesn't even contain any text):

    $cat test-v0.abi

    <abi-corpus-group architecture='elf-arm-aarch64'>
     <abi-corpus path='vmlinux'/>
    </abi-corpus-group>

    $

comparing the two files with abidiff (wrongly) reports:

    $ abidiff test-v0.abi test-v1.abi
    ELF architecture changed
    Functions changes summary: 0 Removed, 0 Changed, 0 Added function
    Variables changes summary: 0 Removed, 0 Changed, 0 Added variable

    architecture changed from 'elf-arm-aarch64' to ''
    $

What's happening is that read_corpus_from_input is getting out early
when it sees that the node is empty.  This is at:

   xmlNodePtr node = ctxt.get_corpus_node();
@@ -1907,10 +1925,14 @@ read_corpus_from_input(read_context& ctxt)
 	corp.set_soname(reinterpret_cast<char*>(soname_str.get()));
     }

  if (!node->children)  // <---- we get out early here and we
    return nil;         // forget about the properties of
                        // the current empty corpus element node

So, at its core, fixing the issue at hand involves avoiding the early
return there.

But then, it turns out that's not enough.

In the current setting, the different abixml processing entry points
are designed to be used in a semi "streaming" mode.

So for instance, read_translation_unit_from_input can be invoked
repeatedly to "stream in" the next translation unit at each
invocation.

Alternatively, the lower level xmlTextReaderNext can be used to
iterate over XML node until we reach the translation unit XML element
we are interested in.  At that point xmlTextReaderExpand can be used
to expand the XML node, then we let the context know that this is
the current node of the corpus that needs to be processed, using
read_context::get_corpus_node.  Once we've done that,
read_translation_unit_from_input can be called to process that
particular corpus node.  Note that the corpus node at hand, that needs
to be processed will be retrieved by read_context::get_corpus_node.

These two modes of operation are also available for
read_corpus_from_input, read_symbol_db_from_input,
read_elf_needed_from_input etc.

Today, these functions all assume that the current node returned by
read_context::get_corpus_node is the node /before/ the node of the
corpus to be processed.  So they all start looking at the /next sibling/
of the node returned by read_context::get_corpus_node.  So the code
was implicitly assuming that read_context::get_corpus_node was
pointing to a text node that was before the node of the corpus that we
want to process.

This is wrong.  read_context::get_corpus_node should just return the
current node of the corpus that needs to be processed and voila.

And so read_context::set_corpus_node should be used to set the current
node of the corpus to the current element node that needs to be processed.

That's the spirit of the change done by this patch.

As its name suggests, the existing
xml::advance_to_next_sibling_element is used to skip non element xml
nodes (including text nodes) and move to the next element node to
process, which is set to the context using
read_context::set_corpus_node.

Then the actual processing functions like read_corpus_from_input get
the node to process, using read_context::get_corpus_node and process
it rather than processing the sibling node that comes after it.

The other changes are either to prevent related crashes that I noticed
while doing various tests, update the abilint tool used to read and
debug abixml input files and add better documentation.

	* src/abg-reader.cc (read_context::get_corpus_node): Add comment
	to this member function.
	(read_translation_unit_from_input, read_symbol_db_from_input)
	(read_elf_needed_from_input): Start processing the current node of
	the corpus that needs to be processed rather than its next
	sibling.  Once the processing is done, set the new "current node
	of the corpus to be processed" properly by skipping to the next
	element node to be processed.
	(read_corpus_from_input): Don't get out early when the
	'abi-corpus' element is empty.  If, however, it has children node,
	skip to the first child element and flag it -- using
	read_context::set_corpus_node -- as being the element node to be
	processed by the processing facilities of the reader.  If we are
	in a mode where we called xmlTextReaderExpand ourselves to get the
	node to process, then it means we need to free that node
	indirectly by calling xmlTextReaderNext.  In that case, that node
	should not be flagged by read_context::set_corpus_node.  Add more
	comments.
	* src/abg-corpus.cc (corpus::is_empty): Do not crash when no
	symtab is around.
	* src/abg-libxml-utils.cc (go_to_next_sibling_element_or_stay):
	Fix typo in comment.
	(advance_to_next_sibling_element): Don't crash when given a nil
	node.
	* tests/data/test-abidiff/test-PR27616-squished-v0.abi: Add new
	test input.
	* tests/data/test-abidiff/test-PR27616-squished-v1.abi: Likewise.
	* tests/data/test-abidiff/test-PR27616-v0.xml: Likewise.
	* tests/data/test-abidiff/test-PR27616-v1.xml: Likewise.
	* tests/data/Makefile.am: Add the new test inputs above to source
	distribution.
	* tests/test-abidiff.cc (specs): Add the new tests inputs above to
	this harness.
	* tools/abilint.cc (main): Support writing corpus groups.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-05-03 17:13:31 +02:00
Dodji Seketeli
b215a21153 dwarf-reader: properly set artificial-ness in opaque types
get_opaque_version_of_type forgets to set the "is-artificial" property
according to the initial type the opaque type is derived from.  This
can lead to some instability in the abixml output.

Fixed thus.

	* src/abg-dwarf-reader.cc (get_opaque_version_of_type): Propagate
	the artificial-ness of the original type here.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-04-13 16:28:27 +02:00
Dodji Seketeli
a16b922b11 dwarf-reader: Canonicalize opaque enums and classes
This issue was reported in bug https://sourceware.org/bugzilla/show_bug.cgi?id=27700.

When we construct an opaque type (triggered by the use of
--drop-private-types along with the --headers-dir option on abidw, for
instance) with get_opaque_version_of_type we forget to canonicalize
the resulting type.

Later, at abixml emitting time (for instance)
hash_as_canonical_type_or_constant would rightfully abort because the
type wasn't canonicalized.  We want all types (okay, modulo one
exception) in the system to be canonicalized.

This patch fixes the problem by canonicalizing opaque types.

	* src/abg-dwarf-reader.cc (build_ir_node_from_die): Canonicalize
	opaque enums and classes.
	* tests/data/test-read-dwarf/PR27700/include-dir/priv.h: New test
	header file.
	* tests/data/test-read-dwarf/PR27700/include-dir/pub.h: Likewise
	* tests/data/test-read-dwarf/PR27700/pub-incdir/inc.h: Likewise.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.o: New binary
	input file.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Reference
	abi file of the binary above.
	* tests/data/test-read-dwarf/PR27700/test-PR27700.c: Source file
	of the binary above.
	* tests/data/Makefile.am: Add the test material above to source
	distribution.
	* tests/test-read-dwarf.cc (InOutSpec::in_public_headers_path):
	Add new data member.
	(in_out_specs): Adjust to reflect the new data member in the
	InOutSpec type.  Add a new test input.
	(set_suppressions_from_headers): Define new static function.
	(test_task::perform): Use the content of the new
	InOutSpec::in_public_headers_path to construct and add
	"--headers-dir <headers-dir> --drop-private-types" to the options
	of the abidw program run.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-04-12 15:47:44 +02:00
Matthias Maennich
acc4bea0b8 symtab: Add support for MODVERSIONS (CRC checksums)
The Linux Kernel has a mechanism (MODVERSIONS) to checksum symbols based
on their type. In a way similar to what libabigail does, but different.
The CRC values for symbols can be extracted from the symtab either by
following the __kcrctab_<symbol> entry or by using the __crc_<symbol>
value directly.

This patch adds support for extracting those CRC values and storing them
as a property of elf_symbol. Subsequently, 'crc' gets emitted as an
attribute of 'elf-symbol' in the XML representation.

CRC comparisons are also added to the abidiff machinery such that if
both representations of a comparison contain a CRC value, they will be
compared and if any of the values is unset (i.e. == 0), equality is
assumed. Differences will be reported in the format that the Kernel
presents them e.g. via Module.symvers. It is likely, but not necessary,
that a CRC difference comes along with an ABI difference reported by
libabigail. Not everything that leads to a change of the CRC value an
ABI breakage in the libabigail sense.

In case a function or variable symbol changes in a harmless way, we
would previously also consider a CRC change harmless (or more precise:
not harmful). Explicitly testing for CRC changes when analyzing whether
diff nodes need to be considered harmful, allows to still classify them
harmful.

Also add some test cases to ensure reading CRC values from kernel
binaries works as expected. The empty-report files have been
consolidated to one file: empty-report.txt. That also clarifies the
expected outcome for the affected tests.

	* include/abg-ir.h (elf_symbol::elf_symbol): Add CRC parameter.
	(elf_symbol::create): Likewise.
	(elf_symbol::get_crc): New member method.
	(elf_symbol::set_crc): New member method.
	* src/abg-comp-filter.cc (crc_changed): New function.
	(categorize_harmful_diff_node): Also test for CRC changes.
	* src/abg-ir.cc (elf_symbol::priv::crc_): New data member.
	* src/abg-ir.cc (elf_symbol::priv::priv): Add CRC parameter.
	(elf_symbol::elf_symbol): Likewise.
	(elf_symbol::create): Likewise.
	(elf_symbol::textually_equals): Add CRC support.
	(elf_symbol::get_crc): New member method.
	(elf_symbol::set_crc): New member method.
	* src/abg-reader.cc (build_elf_symbol): Add CRC support.
	* src/abg-reporter-priv.cc (maybe_report_diff_for_symbol): Likewise.
	* src/abg-symtab-reader.cc (symtab::load): Likewise.
	* src/abg-writer.cc (write_elf_symbol): Likewise.
	* tests/data/Makefile.am: Add new test data files.
	* tests/data/test-abidiff-exit/test-crc-report.txt: New test file.
	* tests/data/test-abidiff-exit/test-crc-v0.abi: Likewise.
	* tests/data/test-abidiff-exit/test-crc-v1.abi: Likewise.
	* tests/data/test-abidiff/empty-report.txt: New file.
	* tests/data/test-abidiff/test-PR18166-libtirpc.so.report.txt: Deleted.
	* tests/data/test-abidiff/test-PR24552-report0.txt: Deleted.
	* tests/data/test-abidiff/test-crc-0.xml: New test file.
	* tests/data/test-abidiff/test-crc-1.xml: Likewise.
	* tests/data/test-abidiff/test-crc-2.xml: Likewise.
	* tests/data/test-abidiff/test-crc-report.txt: Likewise.
	* tests/data/test-abidiff/test-empty-corpus-report.txt: Deleted.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Add CRC values.
	* tests/data/test-read-write/test-crc.xml: New test data file.
	* tests/data/test-symtab/kernel-modversions/Makefile: New test source.
	* tests/data/test-symtab/kernel-modversions/one_of_each.c: Likewise.
	* tests/data/test-symtab/kernel-modversions/one_of_each.ko: Likewise.
	* tests/test-abidiff-exit.cc: Add new test case.
	* tests/test-abidiff.cc: Add new test case.
	* tests/test-read-write.cc: Likewise.
	* tests/test-symtab.cc (Symtab::KernelSymtabsWithCRC): New test case.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 16:13:13 +02:00
Giuliano Procida
328f206efb abg-writer.cc: fix write_elf_symbol_reference loop
The function write_elf_symbol_reference iterates through aliases,
looking for an unsuppressed alias to use. The existing code went wrong
in the case when aliases are present. In the case of all symbols
suppressed, it would also have selected the last alias, rather than
the first, if the data structure invariants had matched the code's
expectations.

The main symbol is always distinguished. When aliases are absent, the
sole symbol's next pointer is null, but when aliases are present, they
form a circular list. This makes traversal of aliases a bit tricky.

The code now picks the first symbol from the following:

- the given symbol, if unsuppressed
- the main symbol, if unsuppressed
- the unsuppressed aliases in the remainder of the alias chain
- the main symbol (suppressed)

The given symbol, which need not be the same as the main symbol, will
be tested twice, if suppressed, but addressing this would make the
code even more elaborate and fragile.

The last case may be unreachable if symbol suppression triggers when
all aliases are suppressed.

I left this change stand-alone for easier review and to credit Giuliano for his
work on it, though it fixes a previous commit.

	* src/abg-writer.cc (write_elf_symbol_reference): Check main
	symbol and aliases with more care.

Fixes: commmit ("dwarf-reader/writer: consider aliases when dealing with suppressions")
Signed-off-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 16:08:14 +02:00
Matthias Maennich
7e223bfc04 dwarf-reader/writer: consider aliases when dealing with suppressions
When the symbol of a decl 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 decl from the internal
representation altogether upon reading and thus the writer will not be
able to connect that decl to the non-suppressed aliased elf symbol.

In order to address this, ensure we are not suppressing decls for which
an alias is not suppressed. We therefore keep the decl in the IR when at
least one its underlying aliased symbols is non-suppressed.

Likewise, when the abg-writer is having to attach an elf-symbol-id to
the decl, 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>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 16:05:32 +02:00
Matthias Maennich
ff4b4a56b4 symtab/dwarf-reader: allow hinting of main symbols for aliases
In case of aliased symbols, the "main symbol" cannot be deduced from
the symtab as this solely contains a name->addr mapping and aliases
are represented by multiple names resolving to the same address.
Therefore the main symbol can only be picked rather randomly and
unpredictable.

Unlike DWARF, which contains a single symbol entry for only the main
symbol. Hence we can (late) detect the main symbol. Exploiting that
property allows to correct the addr->symbol lookup in the symtab to
return the correct main symbol and it also allows to correct the aliased
symbols to maintain the correct main symbol.

This patch adds the `update_main_symbol` functionality to `elf_symbol`
to update the main symbol by name (ELF symbols need unique names) and
adds `update_main_symbol` to `symtab` that makes use of said new method.

When we discover a main symbol during DWARF reading, we instruct the
symtab to update the mapping.

This creates consistent representations across different builds of the
same binary with the same ABI by pinning down the main symbol to the
defined one. Knowing the main symbol also helps to keep the correct
dwarf information in the representation in the presence of symbol
suppressions. A later patch will address that.

Some test cases in tests/data need adjustment and they have all been
verified to be valid changes.

- main symbol changed for various elf symbols
  - test-annotate/test15-pr18892.so.abi
  - test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi
  - test-annotate/test3.so.abi
  - test-read-dwarf/test15-pr18892.so.abi
  - test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi
  - test-read-dwarf/test3.so.abi
  - test-read-dwarf/test3.so.hash.abi

- due to main symbol changes, the symbol diff needs to be corrected
  - test-diff-dwarf/test12-report.txt
  - test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt
  - test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt

- the test scenario needed adjustments as the main symbol changed
  - test-diff-suppr/test23-alias-filter-4.suppr
  - test-diff-suppr/test23-alias-filter-report-0.txt
  - test-diff-suppr/test23-alias-filter-report-2.txt

As usual, the complete changelog follows.

	* include/abg-ir.h (elf_symbol::update_main_symbol): New method.
	* include/abg-symtab-reader.h (symtab::update_main_symbol): New method.
	* src/abg-dwarf-reader.cc
	(build_var_decl): Hint symtab about main symbol discovered in DWARF.
	(build_function_decl): Likewise.
	* src/abg-ir.cc (elf_symbol::get_main_symbol): Lock the weak_ptr
	  on access in both overloads.
	(update_main_symbol): New method to allow updating the main symbol.
	* src/abg-symtab-reader.cc (symtab::update_main_symbol): New method.
	* data/Makefile.am: Add new test data files.
	* tests/data/test-annotate/test15-pr18892.so.abi: Updated test file.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-annotate/test2.so.abi: Likewise.
	* tests/data/test-annotate/test3.so.abi: Likewise.
	* tests/data/test-diff-dwarf/test12-report.txt: Likewise.
	* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-4.suppr: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise.
	* tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.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/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.abi: Likewise.
	* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.abi: Likewise.
	* tests/data/test-read-dwarf/test3.so.hash.abi: Likewise.
	* tests/data/test-symtab/basic/aliases.c: New test source file.
	* tests/data/test-symtab/basic/aliases.so: Likewise.
	* tests/test-symtab.cc (Symtab::AliasedFunctionSymbols): New test case.
	(Symtab::AliasedVariableSymbols): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 15:54:23 +02:00
Matthias Maennich
f427346262 test-symtab: add tests for whitelisted functions
Extend the test functionality in test-symtab to allow processing of KMI
whitelists and add additional test cases for whitelist handling.

	* tests/data/Makefile.am: add new test files
	* tests/data/test-symtab/basic/one_function_one_variable_all.whitelist: New test file,
	* tests/data/test-symtab/basic/one_function_one_variable_function.whitelist: Likewise.
	* tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist: Likewise.
	* tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist: Likewise.
	* tests/test-symtab.cc (read_corpus): Add support for whitelists.
	(assert_symbol_count): Likewise.
	(Symtab::SymtabWithWhitelist): New testcase.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 15:54:15 +02:00
Matthias Maennich
3abd9742b7 dwarf reader: drop (now) unused code related to symbol table reading
The introduction of the new symtab reader incorporated much of the
existing functionality. Now that the most code parts are migrated to the
new symtab reader, we can safely remove the old code paths.

Ignoring the symbol table is not a thing anymore. The new symtab reader
does read the symtab unconditionally for consistency reasons. Hence also
remove all functionality around conditional symtab reading.

	* include/abg-dwarf-reader.h (set_ignore_symbol_table): Remove.
	(get_ignore_symbol_table): Likewise.
	* src/abg-dwarf-reader.cc (add_symbol_to_map): Likewise.
	(read_context::options_type::ignore_symbol_table): Likewise.
	(read_context::options_type): Adjust.
	(read_context::fun_addr_sym_map_): Remove.
	(read_context::fun_entry_addr_sym_map_): Likewise.
	(read_context::fun_syms_): Likewise.
	(read_context::var_addr_sym_map_): Likewise.
	(read_context::var_syms_): Likewise.
	(read_context::undefined_fun_syms_): Likewise.
	(read_context::undefined_var_syms_): Likewise.
	(read_context::initialize): Adjust.
	(read_context::lookup_elf_symbol_from_index): Remove.
	(read_context::fun_entry_addr_sym_map_sptr): Likewise.
	(read_context::fun_entry_addr_sym_map): Likewise.
	(read_context::fun_syms_sptr): Likewise.
	(read_context::fun_syms): Likewise.
	(read_context::var_syms_sptr): Likewise.
	(read_context::var_syms): Likewise.
	(read_context::undefined_fun_syms_sptr): Likewise.
	(read_context::undefined_var_syms_sptr): Likewise.
	(read_context::load_symbol_maps_from_symtab_section): Likewise.
	(read_context::load_symbol_maps): Likewise.
	(read_context::maybe_load_symbol_maps): Likewise.
	(set_ignore_symbol_table): Likewise.
	(get_ignore_symbol_table): Likewise.
	(create_default_var_sym): Likewise.
	(build_var_decl): Adjust.
	(function_is_suppressed): Likewise.
	(variable_is_suppressed): Likewise.
	(build_function_decl): Likewise.
	(add_symbol_to_map): Remove.
	(read_corpus_from_elf): Adjust.
	(build_corpus_group_from_kernel_dist_under): Likewise.
	* tools/abidw.cc (main): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 15:48:23 +02:00
Matthias Maennich
7851ca2b91 abg-corpus: remove symbol maps and their setters
With the prework in previous commits, we are now able to drop the
public symbols maps in corpus::priv and replace them by private members
with access through getters. The getters use the new symtab
implementation to generate the maps on the fly. Setters are not required
anymore and are removed. Also remove redundant getters.

We could also remove the getters for the symbol maps and the local
caching variable and leave it all to lookup_symbol, but this is left for
a later change.

	* include/abg-corpus.h (corpus::set_fun_symbol_map): Remove
	method declaration.
	(corpus::set_undefined_fun_symbol_map): Likewise.
	(corpus::set_var_symbol_map): Likewise.
	(corpus::set_undefined_var_symbol_map): Likewise.
	(corpus::get_fun_symbol_map_sptr): Likewise.
	(corpus::get_undefined_fun_symbol_map_sptr): Likewise.
	(corpus::get_var_symbol_map_sptr): Likewise.
	(corpus::get_undefined_var_symbol_map_sptr): Likewise.
	* src/abg-corpus-priv.h (corpus::priv::var_symbol_map): make
	private and mutable
	(corpus::priv::undefined_var_symbol_map): Likewise.
	(corpus::priv::fun_symbol_map): Likewise.
	(corpus::priv::undefined_fun_symbol_map): Likewise.
	(corpus::priv::get_fun_symbol_map): New method declaration.
	(corpus::priv::get_undefined_fun_symbol_map): Likewise.
	(corpus::priv::get_var_symbol_map): Likewise.
	(corpus::priv::get_undefined_var_symbol_map): Likewise.
	* src/abg-corpus.cc (corpus::priv::get_fun_symbol_map): New
	method implementation.
	(corpus::priv::get_undefined_fun_symbol_map): Likewise.
	(corpus::priv::get_var_symbol_map): Likewise.
	(corpus::priv::get_undefined_var_symbol_map): Likewise.
	(corpus::is_empty): depend on symtab only.
	(corpus::set_fun_symbol_map): Remove method.
	(corpus::set_undefined_fun_symbol_map): Likewise.
	(corpus::set_var_symbol_map): Likewise.
	(corpus::set_undefined_var_symbol_map): Likewise.
	(corpus::get_fun_symbol_map_sptr): Likewise.
	(corpus::get_undefined_fun_symbol_map_sptr): Likewise.
	(corpus::get_var_symbol_map_sptr): Likewise.
	(corpus::get_undefined_var_symbol_map_sptr): Likewise.
	(corpus::get_fun_symbol_map): Use corpus::priv proxy method.
	(corpus::get_undefined_fun_symbol_map): Likewise.
	(corpus::get_var_symbol_map): Likewise.
	(corpus::get_undefined_var_symbol_map): Likewise.
	* src/abg-dwarf-reader.cc (read_debug_info_into_corpus): Do not
	set corpus symbol maps anymore.
	* src/abg-reader.cc (read_corpus_from_input): Likewise.
	* tests/test-symtab.cc (assert_symbol_count): Do not access the
	corpus symbol maps through sptr anymore.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Adjust
	expected test output.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-04-02 15:48:01 +02:00
Matthias Maennich
8bfdb0f548 symtab_reader: add support for ppc64 ELFv1 binaries
When loading the symtab from an ppc64 binary, also keep track of the
function entry addresses as a key for the symbol lookup. That
accommodates the differences in DWARF pointing to the function entry
address while the symbol table points to the function pointer.

The implementation is mostly copied and adopted from abg-dwarf-reader's
read_context to add this functionality also to the new symtab reader.

	* src/abg-symtab-reader.cc (symtab::lookup_symbol): fall back to
	  lookup the address in entry_addr_symbol_map_.
	  (symtab::load): update the function entry address map for
	  ppc64 targets.
	  (symtab::update_function_entry_address_symbol_map): New
	  function implementation.
	* src/abg-symtab-reader.h
	  (symtab::entry_addr_symbol_map_): New data member.
	  (symtab::update_function_entry_address_symbol_map): New
	  function declaration.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 15:29:56 +02:00
Matthias Maennich
e87f2672d9 abg-elf-helpers: migrate ppc64 specific helpers
This migrates more helpers to abg-elf-helpers:
  lookup_ppc64_elf_fn_entry_point_address  with dependencies
    read_uint64_from_array_of_bytes
    read_int_from_array_of_bytes

  address_is_in_opd_section  with dependency
    address_is_in_section

read_context::find_opd_section and read_context::opd_section_ are obsolete.

	* src/abg-dwarf-reader.cc (read_context::opd_section_): Delete.
	(read_context::find_opd_section): Delete.
	(read_context::read_uint64_from_array_of_bytes): Delete.
	(read_context::read_int_from_array_of_bytes): Delete.
	(read_context::lookup_ppc64_elf_fn_entry_point_address): Delete.
	(read_context::address_is_in_opd_section): Delete.
	(read_context::address_is_in_section): Delete.
	(read_context::load_symbol_maps_from_symtab_section): Adjust.
	* src/abg-elf-helpers.cc (read_int_from_array_of_bytes): New.
	(read_uint64_from_array_of_bytes): New.
	(lookup_ppc64_elf_fn_entry_point_address): New.
	(address_is_in_section): New.
	(address_is_in_opd_section): New.
	* src/abg-elf-helpers.h
	(lookup_ppc64_elf_fn_entry_point_address): New declaration.
	(address_is_in_opd_section): New declaration.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-04-02 15:29:38 +02:00
Matthias Maennich
9cd191b3c4 Switch kernel stuff over to new symtab and drop unused code
Now that the new symtab implementation is capable of reading the
ksymtab, we can switch over the implementation to gather information
from there and delete all now-obsolete code.

	* src/abg-dwarf-reader.cc (read_context::ksymtab_format_): Delete.
	(read_context::ksymtab_entry_size_): Likewise.
	(read_context::nb_ksymtab_entries_): Likewise.
	(read_context::nb_ksymtab_gpl_entries_): Likewise.
	(read_context::ksymtab_section_): Likewise.
	(read_context::ksymtab_reloc_section_): Likewise.
	(read_context::ksymtab_gpl_section_): Likewise.
	(read_context::ksymtab_gpl_reloc_section_): Likewise.
	(read_context::ksymtab_strings_section_): Likewise.
	(read_context::linux_exported_fn_syms): Likewise.
	(read_context::linux_exported_var_syms): Likewise.
	(read_context::linux_exported_gpl_fn_syms): Likewise.
	(read_context::linux_exported_gpl_var_syms): Likewise.
	(read_context::initialize): Remove initializations accordingly.
	(read_context::find_ksymtab_section): Delete.
	(read_context::find_ksymtab_gpl_section): Likewise.
	(read_context::find_ksymtab_reloc_section): Likewise.
	(read_context::find_ksymtab_gpl_reloc_section): Likewise.
	(read_context::find_ksymtab_strings_section): Likewise.
	(read_context::find_any_ksymtab_section): Likewise.
	(read_context::find_any_ksymtab_reloc_section): Likewise.
	(read_context::lookup_elf_symbol_from_index): Adjust.
	(read_context::linux_exported_fn_syms): Delete.
	(read_context::create_or_get_linux_exported_fn_syms): Likewise.
	(read_context::linux_exported_var_syms): Likewise.
	(read_context::create_or_get_linux_exported_var_syms): Likewise.
	(read_context::linux_exported_gpl_fn_syms): Delete.
	(read_context::create_or_get_linux_exported_gpl_fn_syms): Likewise.
	(read_context::linux_exported_gpl_var_syms): Likewise.
	(read_context::create_or_get_linux_exported_gpl_var_syms): Likewise.
	(read_context::try_reading_first_ksymtab_entry): Likewise.
	(read_context::try_reading_first_ksymtab_entry_using_pre_v4_19_format): Likewise.
	(read_context::try_reading_first_ksymtab_entry_using_v4_19_format): Likewise.
	(read_context::get_ksymtab_format_module): Likewise.
	(read_context::get_ksymtab_format): Likewise.
	(read_context::get_ksymtab_symbol_value_size): Likewise.
	(read_context::get_ksymtab_entry_size): Likewise.
	(read_context::get_nb_ksymtab_entries): Likewise.
	(read_context::get_nb_ksymtab_gpl_entries): Likewise.
	(read_context::populate_symbol_map_from_ksymtab): Likewise.
	(read_context::populate_symbol_map_from_ksymtab_reloc): Likewise.
	(read_context::load_kernel_symbol_table): Likewise.
	(read_context::load_ksymtab_symbols): Likewise.
	(read_context::load_ksymtab_gpl_symbols): Likewise.
	(read_context::load_linux_specific_exported_symbol_maps): Likewise.
	(read_context::load_symbol_maps): Do not load kernel symbol maps.
	(read_context::maybe_adjust_sym_address_from_v4_19_ksymtab): Delete.
	(read_context::add_fn_symbols_to_map): Likewise.
	(read_context::add_var_symbols_to_map): Likewise.
	(read_context::read_debug_info_into_corpus): Fill export maps
	from new symtab.
	(read_context::lookup_elf_fn_symbol_from_address): Delete.
	(read_context::lookup_elf_var_symbol_from_address): Likewise.
	(read_context::lookup_elf_symbol_from_address): Likewise.
	(read_context::lookup_public_function_symbol_from_elf): Likewise.
	(read_context::fun_entry_addr_sym_map_sptr): Likewise.
	(read_context::fun_entry_addr_sym_map): Likewise.
	(read_context::var_addr_sym_map): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-04-02 15:24:35 +02:00
Matthias Maennich
c1c38164c8 dwarf-reader: read_context: use new symtab in *_symbols_is_exported
Testing whether a symbol is exported can be simplified using the new
symtab implementation. The same holds true for whether a symbol is
exported via ksymtab in case of linux kernel binaries. So, do that.

	* src/abg-dwarf-reader.cc (function_symbol_is_exported): Use new
	  symtab implementation.
	  (variable_symbol_is_exported): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 15:15:30 +02:00
Matthias Maennich
2d73f822fd abg-reader: avoid using the (var|function)_symbol_map
Instead of using the corpus var|function_symbol_maps for symbol lookups,
let build_elf_symbol_from_reference use the symtab::lookup_symbol
method. That leads to a shorter implementation and we can drop the
indicative parameter.

	* src/abg-reader.cc (build_elf_symbol_from_reference): drop
	  last parameter indicating the lookup type and use corpus
	  symtab for the lookup
	  (build_function_decl): Adjust accordingly.
	  (build_var_decl): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 11:34:10 +02:00
Matthias Maennich
b0994f6133 corpus: make get_unreferenced_(function|variable)_symbols use the new symtab
Make the corresponding members an implementation detail of corpus::priv.
They get computed based on the new symtab whenever they are accessed
first with an atomic instantiation. That simplifies the implementation
and homogenizes the access to functions and variables. Sorting does not
need to be done as the symtab already gives a guarantee for that.

        * src/abg-corpus-priv.h (corpus::priv::unrefed_var_symbols): make
          private, mutable and optional.
          (corpus::unrefed_fun_symbols): Likewise.
          (corpus::priv::get_unreferenced_function_symbols): New method declaration.
          (corpus::priv::get_unreferenced_variable_symbols): Likewise.
        * src/abg-corpus.cc
          (corpus::priv::build_unreferenced_symbols_tables): Delete method.
          (corpus::priv::get_unreferenced_function_symbols): New method implementation.
          (corpus::priv::get_unreferenced_variable_symbols): Likewise.
          (corpus::get_unreferenced_function_symbols): Proxy call to corpus::priv.
          (corpus::get_unreferenced_variable_symbols): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 11:09:41 +02:00
Matthias Maennich
2ed1ca7031 corpus: make get_(undefined_)?_(var|fun)_symbols use the new symtab
Make the corresponding members an implementation detail of corpus::priv.
They get computed based on the new symtab whenever they are accessed
first with an atomic instantiation. That simplifies the implementation
and homogenizes the access to functions and variables. Sorting does not
need to be done as the symtab already gives a guarantee for that.

Due to improved alias detection in the new symtab reader, ensure we only
write symbol aliases to ksymtab symbols if having a ksymtab main symbol.

Test data needed to be adjusted as the new symtab reader is stricter in
regards to symbols listed in ksymtab. I.e. init_module is not an
exported symbol in the ksymtab of a kernel module.

	* src/abg-corpus-priv.h (corpus::priv::sorted_var_symbols): make
	  private, mutable and optional.
	  (corpus::sorted_undefined_var_symbols): Likewise.
	  (corpus::sorted_fun_symbols): Likewise.
	  (corpus::sorted_undefined_fun_symbols): Likewise.
	  (corpus::priv::get_sorted_fun_symbols): New method declaration.
	  (corpus::priv::get_sorted_undefined_fun_symbols): Likewise.
	  (corpus::priv::get_sorted_var_symbols): Likewise.
	  (corpus::priv::get_sorted_undefined_var_symbols): Likewise.
	* src/abg-corpus.cc
	  (corpus::elf_symbol_comp_functor): Delete struct.
	  (corpus::priv::get_sorted_fun_symbols): New method implementation.
	  (corpus::priv::get_sorted_undefined_fun_symbols): Likewise.
	  (corpus::priv::get_sorted_var_symbols): Likewise.
	  (corpus::priv::get_sorted_undefined_var_symbols): Likewise.
	  (corpus::get_sorted_fun_symbols): Proxy call to corpus::priv.
	  (corpus::get_sorted_undefined_fun_symbols): Likewise.
	  (corpus::get_sorted_var_symbols): Likewise.
	  (corpus::get_sorted_undefined_var_symbols): Likewise.
	* src/abg-writer.cc (write_elf_symbol_aliases): When emitting
	  aliases for a kernel symbol, ensure to only emit exported,
	  public aliases.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: update test
	  data.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-02 10:40:10 +02:00
Matthias Maennich
ae094e349e Integrate new symtab reader into corpus and read_context
While reading the corpus in the read_context, also load the new type
symtab object side-by-side and set it accordingly in the resulting
corpus. This is still side by side and passive code that gets active in
the following changes. This is applicable for the dwarf reader as well
as for the reader that consumes XML.

	* include/abg-corpus.h (corpus::set_symtab): New method declaration.
	  (corpus::get_symtab): New method declaration.
	* include/abg-fwd.h (symtab_reader::symtab_sptr): New forward
	  declaration.
	* src/abg-corpus-priv.h (corpus::priv::symtab_): New data member.
	* src/abg-corpus.cc
	  (corpus::set_symtab): Likewise.
	  (corpus::get_symtab): Likewise.
	* src/abg-dwarf-reader.cc (read_context::symtab_): New data member.
	  (read_context::initialize): reset symtab_ as well
	  (read_context::symtab): new method that loads a symtab on
	  first access and returns it.
	  (read_debug_info_into_corpus): also set the new symtab object
	  on the current corpus.
	  (read_corpus_from_elf): Also determine (i.e. load) the new
	  symtab object and contribute to the load status.
	* src/abg-reader.cc (read_corpus_from_input): also set the new
	  type symtab when reading from xml.
	* tests/test-symtab.cc: Add test assertions.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-01 14:37:26 +02:00
Matthias Maennich
4ba6b80251 Refactor ELF symbol table reading by adding a new symtab reader
Based on existing functionality, implement the reading of ELF symbol
tables as a separate component. This reduces the complexity of
abg-dwarf-reader's read_context by separating and delegating the
functionality. This also allows dedicated testing.

The new namespace symtab_reader contains a couple of new components that
work loosely coupled together. Together they allow for a consistent view
on a symbol table. With filter criteria those views can be restricted,
iterated and consistent lookup maps can be built on top of them. While
this implementation tries to address some shortcomings of the previous
model, it still provides the high level interfaces to the symbol table
contents through sorted iterating and name/address mapped access.

symtab_reader::symtab

  While the other classes in the same namespace are merely helpers, this
  is the main implementation of symtab reading and storage.
  Symtab objects are factory created to ensure a consistent construction
  and valid invariants. Thus a symtab will be loaded by either passing
  an ELF handle (when reading from binary) or by passing a set of
  function/variable symbol maps (when reading from XML).
  When constructed they are considered const and are not writable
  anymore. As such, all public methods are const.

  The load reuses the existing implementation for loading symtab
  sections, but since the new implementation does not distinguish
  between functions and variables, the code could be simplified. The
  support for ppc64 function entry addresses has been deferred to a
  later commit.

  Linux Kernel symbol tables are now directly loaded by name when
  encountering symbols prefixed with the __ksymtab_ as per convention.
  This has been tricky in the past due to various different binary
  layouts (relocations, position relative relocations, symbol
  namespaces, CFI indirections, differences between vmlinux and kernel
  modules). Thus the new implementation is much simpler and is less
  vulnerable to future ksymtab changes. As we are also not looking up
  the Kernel symbols by addresses, we could resolve shortcomings with
  symbol aliasing: Previously a symbol and its alias were
  indistinguishable as they are having the same symbol address. We could
  not identify the one that is actually exported via ksymtab.

  One major architectural difference of this implementation is that we
  do not early discard suppressed symbols. While we keep them out of the
  vector of exported symbols, we still make them available for lookup.
  That helps addressing issues when looking up a symbol by address (e.g.
  from the ksymtab read implementation) that is suppressed. That would
  fail in the existing implementation.

  Still, we intend to only instantiate each symbol once and pass around
  shared_ptr instances to refer to it from the vector as well as from
  the lookup maps.

  For reading, there are two access paths that serve the existing
  patterns:
	1) lookup_symbol: either via a name or an address
	2) filtered iteration with begin(), end()

  The former is used for direct access with a clue in hand (like a name
  or an address), the latter is used for iteration (e.g. when emitting
  the XML).

symtab_reader::symtab_iterator

  The symtab_iterator is an STL compatible iterator that is returned
  from begin() and end() of the symtab. It allows usual forward iterator
  operations and can optionally take a filter predicate to skip non
  matching elements.

symtab_reader::symtab_filter

  The symtab_filter serves as a predicate for the symtab_iterator by
  providing a matches(const elf_symbol_sptr&) function.  The predicate
  is built by ANDing together several conditions on attributes a symbol
  can have. The filter conditions are implemented in terms of
  std::optional<bool> members to allow a tristate: "needs to have the
  condition set", "must not have it set" and "don't care".

symtab_reader::filtered_symtab

  The filtered_symtab is a convenience zero cost abstraction that allows
  prepopulating the symtab_filter (call it a capture) such that begin()
  and end() are now accessible without the need to pass the filter
  again. Argumentless begin() and end() are a requirement for range-for
  loops and other STL based algorithms.

	* src/abg-symtab-reader.h (symtab_filter): New class.
	(symtab_iterator): Likewise.
	(symtab): Likewise.
	(filtered_symtab): Likewise.
	* src/abg-symtab-reader.cc (symtab_filter::matches): New.
	(symtab::make_filter): Likewise.
	(symtab::lookup_symbol): Likewise.
	(symbol_sort): Likewise.
	(symtab::load): Likewise.
	(symtab::load_): Likewise.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-04-01 14:37:12 +02:00
Matthias Maennich
29d1d80165 clang-format: Minor correction to not break parameters on the first line
Before:
   someLongFunction(
    argument1,
    argument2);

After:
   someLongFunction(argument1,
                    argument2);

	* .clang-format: correct function parameter break/indentation

Signed-off-by: Matthias Maennich <maennich@google.com>
2021-04-01 09:51:20 +02:00
Dodji Seketeli
2f8e1db0e7 Bug 27598 - abidiff mishandles union member functions
abidiff segfaults when a union member function is involved in the
comparison.  This patch fixes that.

	* src/abg-default-reporter.cc (default_reporter::report): Assume
	the parent type of the method can be either a class or a union.
	* tests/data/test-diff-filter/test-PR27598-report-0.txt: New
	reference output for the test.
	* tests/data/test-diff-filter/test-PR27598-v{0,1}.cc: New source
	code for the input binaries below.
	* tests/data/test-diff-filter/test-PR27598-v{0,1}.o: New input
	test binaries.
	* tests/data/Makefile.am: Add the new test material to source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the test inputs
	above to this test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-31 18:21:28 +02:00
Dodji Seketeli
2eefd17276 Bug 27569 - abidiff misses a function parameter addition
Adding or deleting function parameters are changes that have not yet
been categorized in the comparison engine.  As a result, those changes
can be considered harmless and thus be filtered out.  Oops.

This patch categorizes function addition and removal as
FN_PARM_ADD_REMOVE_CHANGE_CATEGORY, which is a new category being
introduced.  Changes in this category are considered harmful and are
thus always reported by default.

	* include/abg-comparison.h (enum diff_category): Add a new
	FN_PARM_ADD_REMOVE_CHANGE_CATEGORY enumerator and adjust the
	following enumerator values.  Update the EVERYTHING_CATEGORY
	accordingly.
	(function_type_diff::{sorted_deleted_parms, sorted_added_parms}):
	Add new member functions.
	* src/abg-comparison.cc
	(function_type_diff::{sorted_deleted_parms, sorted_added_parms}):
	Define new accessors.
	(get_default_harmful_categories_bitmap):
	Consider changes of the category
	FN_PARM_ADD_REMOVE_CHANGE_CATEGORY as harmful.
	(operator<<(ostream& o, diff_category c)): Support the new
	FN_PARM_ADD_REMOVE_CHANGE_CATEGORY while serializing a category
	bitmap.
	* src/abg-comp-filter.cc
	(has_added_or_removed_function_parameters): Define new static
	function.
	(categorize_harmful_diff_node): Categorize diff nodes representing
	function parameter addition or removal as
	FN_PARM_ADD_REMOVE_CHANGE_CATEGORY.
	* tests/data/test-diff-filter/test-PR27569-report-0.txt: New test
	reference output.
	* tests/data/test-diff-filter/test-PR27569-v{0,1}.abi: New test inputs.
	* tests/data/Makefile.am: Add the new test inputs to the source
	distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the new test
	inputs to this test harness.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Adjust.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Likewise.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-29 12:34:48 +02:00
Giuliano Procida
ba3ceabdaa dwarf-reader: Treat union members as public by default.
This fixes a bug where abidw reports the access of members of C unions
and of C++ unions without any access specifiers as private.

	* src/abg-dwarf-reader.cc (add_or_update_union_type): Replace
        "class" with "union" in comments; give union members public
        access by default.
	(finish_member_function_reading): Give union members public access
	by default.
	(maybe_set_member_type_access_specifier): Give union members
	public access by default.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Refresh.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Refresh.
	* tests/data/test-annotate/test-anonymous-members-0.o.abi:
	Refresh.
	* tests/data/test-annotate/test13-pr18894.so.abi: Refresh.
	* tests/data/test-annotate/test14-pr18893.so.abi: Refresh.
	* tests/data/test-annotate/test15-pr18892.so.abi: Refresh.
	* tests/data/test-annotate/test17-pr19027.so.abi: Refresh.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Refresh.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
        Refresh.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
        Refresh.
	* tests/data/test-annotate/test21-pr19092.so.abi: Refresh.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi:
        Refresh.
	* tests/data/test-diff-dwarf-abixml/test0-pr19026-libvtkIOSQL-6.1.so.1.abi:
        Refresh.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Refresh.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/test-PR26568-1.o.abi: Refresh.
	* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Refresh.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Refresh.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Refresh.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Refresh.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Refresh.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Refresh.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Refresh.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Refresh.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Refresh.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Refresh.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
        Refresh.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi:
        Refresh.

Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-19 17:06:25 +01:00
Ben Woodard via Libabigail
05d33d607a Bug 27512 - Remove broken zip-archive support
The optional zip archive feature was broken when the concept of
environment was introduced by commit b2e5366d3 back in 2015. Since it
wouldn't even compile and nobody noticed, we are fairly sure nobody
uses that feature. Therefore, we decided to remove it rather than fix
it.

	* configure.ac: remove --enable-zip-archive option and logic
	associated with it.
	* include/abg-libzip-utils.h: Remove.
	* src/abg-libzip-utils.cc: Likewise.
	* include/Makefile.am: remove reference to include/abg-libzip-utils.h
	that no longer exists.
	* src/Makefile.am: remove reference to src/abg-libzip-utils.cc that no
	longer exists.
	* relicensing-scripts/file-licenses.orig.txt: remove references to
	files that no longer exist.
	* relicensing-scripts/files-with-lgplv3.txt: remove references to
	files that no longer exist.
	* tests/test-write-read-archive.cc: Remove because it tests code
	that no longer exists.
	* tests/Makefile.am: remove reference to tests that no longer exist.
	* include/abg-reader.h: remove conditionally compiled code for zip
	archives.
	* include/abg-tools-utils.h: remove conditionally compiled code for
	zip archives.
	* src/abg-corpus.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-reader.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-tools-utils.cc: remove conditionally compiled code for zip
	archives.
	* src/abg-writer.cc: remove conditionally compiled code for zip
	archives.
	* tools/abidiff.cc: remove conditionally compiled code for zip
	archives.
	* tools/abilint.cc: remove conditionally compiled code for zip
	archives.
	* tools/abiar.c: Remove.
	* tools/Makefile.am: remove references to abiar a utility that no
	longer has a reason for existing.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-19 10:52:57 +01:00
Dodji Seketeli
40aab37cf0 dwarf-reader: Support more DWARF-5 type DIEs
When analyzing DWARF-5 some binaries, is_type_tag chokes on the new
DWARF-5 type DIEs it doesn't know about.

This patch teaches it about them.

	* src/abg-dwarf-reader.cc (is_type_tag): Support
	DW_TAG_coarray_type, DW_TAG_atomic_type and DW_TAG_immutable_type.
	* tests/data/test-diff-pkg/elfutils-debuginfo-0.183-1.el9.x86_64.rpm:
	Add new binary test input.
	* tests/data/test-diff-pkg/elfutils-libs-debuginfo-0.183-1.el9.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/elfutils-libs-0.183-1.el9.x86_64.rpm: Likewise.
	* tests/data/test-diff-pkg/elfutils-libs-debuginfo-0.183-1.el9.x86_64-self-check-report-0.txt:
	Add new reference test output.
	* tests/test-diff-pkg.cc (in_out_specs): Add the test inputs above
	to the harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-18 13:41:18 +01:00
Giuliano Procida
915c66718b DWARF reader: Comment ARM32 ELF address interpretation
Bug 27552 - libabigail needs to interpret ARM32 symbol addresses specially

The previous commit omitted any code commentary. This adds a link to
the relevant reference. The code is shortened slightly as well.

	* src/abg-dwarf-reader.cc
	(read_context::load_symbol_maps_from_symtab_section): Add
	descriptive comment to ARM32 address handling; shorten
	the assignment using &=.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-03-11 08:54:28 +01:00
Matthias Maennich
07816b2d59 dwarf-reader split: create abg-symtab-reader.{h,cc} and test case
abg-symtab-reader.{h,cc} shall contain the refactored symtab reader.
Create the stub files, an empty unit test and hook everything up in the
make system.

    * src/abg-symtab-reader.h: New header file.
    * src/abg-symtab-reader.cc: New source file.
    * src/Makefile.am: Add new source files.
    * tests/Makefile.am: Add new test case runtestsymtabreader.
    * tests/test-symtab-reader.cc: New test source file.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-03-10 18:54:55 +01:00
Giuliano Procida
32c7829e41 DWARF reader: Interpret ARM32 ELF addresses correctly
Bug 27552 - libabigail needs to interpret ARM32 symbol addresses specially

The ARM32 ELF specification specifies that bit 0 of an ELF function
address is a flag specifying whether the instructions are Thumb or
ARM. So clear this bit before using the addresses for symbol mapping.

	* src/abg-dwarf-reader.cc
	(read_context::load_symbol_maps_from_symtab_section): Clear
	bit zero of ARM32 function addresses.
	* src/abg-elf-helpers.cc (architecture_is_arm32): Add new
	function.
	* src/abg-elf-helpers.h (architecture_is_arm32): Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Update.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-03-10 11:12:51 +01:00
Matthias Maennich
b67fb3f2e3 abg-ir: elf_symbol: add is_suppressed field
In the context of libabigail and a single library run (when reading from
dwarf or from xml), a symbol is either suppressed or it is not. While
one could argue that this is a property of the read_context, the
read_context might not be around anymore when the symbol still is.
Hence, persist the 'is_suppressed' state along with the symbol itself.

        * include/abg-ir.h (elf_symbol::elf_symbol): Add is_suppressed
        parameter.
        (elf_symbol::create): Likewise.
        (elf_symbol::is_suppressed): New getter declaration.
        (elf_symbol::set_is_suppressed): New setter declaration.
        * src/abg-ir.cc (elf_symbol::priv::priv): Add is_suppressed
        parameter.
        (elf_symbol::priv::is_suppressed_): New field.
        (elf_symbol::elf_symbol): Add is_suppressed parameter.
        (elf_symbol::create): Likewise.
        (elf_symbol::is_suppressed): New getter implementation.
        (elf_symbol::set_is_suppressed): New setter implementation.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-09 18:48:13 +01:00
Matthias Maennich
573c4cad5a abg-ir: elf_symbol: add is_in_ksymtab field
Being exported through a ksymtab (in case of Linux Kernel binaries) is
actually a property of the Elf symbol itself and we can therefore track
it along with the symbol that we collect from symtab. While tracking is
currently done by keeping separate symbol lists and maps for symtab and
ksymtab symbols, they can be consolidated having a property to indicate
whether this symbol also appeared as a ksymtab entry.

Hence, and for future changes in this area, add this property and update
all references. The flag is false initially unless otherwise specified.

	* include/abg-ir.h (elf_symbol::elf_symbol): Add is_in_ksymtab
	parameter.
	(elf_symbol::create): Likewise.
	(elf_symbol::is_in_ksymtab): New getter declaration.
	(elf_symbol::set_is_in_ksymtab): New setter declaration.
	* src/abg-ir.cc (elf_symbol::priv::priv): Add is_in_ksymtab
	parameter.
	(elf_symbol::priv::is_in_ksymtab_): New field.
	(elf_symbol::elf_symbol): Add is_in_ksymtab parameter.
	(elf_symbol::create): Likewise.
	(elf_symbol::is_in_ksymtab): New getter implementation.
	(elf_symbol::set_is_in_ksymtab): New setter implementation.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-09 14:56:39 +01:00
Matthias Maennich
c92d724e01 abg-cxx-compat: add simplified version of std::optional
In the absence (but desire) of std::optional<T>, add a simplified
version of it to abg_compat:: in case we are compiling with a pre-C++17
standard. Otherwise use std::optional from <optional> directly.

This is being used by a later patch and serves as a prerequisite.
It only serves the purpose of being a compatibility implementation and
does not claim to be complete at all. Just enough for the project's
needs.

	* include/abg-cxx-compat.h (abg_compat::optional): Add new class.
	* tests/tests-cxx-compat.cc: Add new test cases.

Reviewed-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
2021-03-09 10:41:10 +01:00
Ben Woodard via Libabigail
701de3ba5d Fix declaratons of conditionally defined functions
Functions relating to zip archives are declared but are never compiled
when --enable-zip-archive=no, the default.

This makes sure that they are not declared when they won't be defined
due to conditional compilation.

	* include/abg-reader.h (read_corpus_from_file): Guard the
	declaration of these overloads with #ifdef WITH_ZIP_ARCHIVE.
	* tools/abilint.cc: Guard the use of
	abigail::xml_reader::read_corpus_from_file with #ifdef
	WITH_ZIP_ARCHIVE.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-08 13:05:43 +01:00
Dodji Seketeli
f433d4dbdb Revert "Fix declaratons of conditionally defined functions"
I forgot to edit the commit message of this commit to make it comply
with the rules in https://sourceware.org/git/?p=libabigail.git;a=blob;f=COMMIT-LOG-GUIDELINES.

So I am reverting commit cd2af9e5f5
2021-03-08 13:04:13 +01:00
Ben Woodard via Libabigail
cd2af9e5f5 Fix declaratons of conditionally defined functions
Functions relating to zip archives are declared but are never compiled
when --enable-zip-archive=no, the default.

This makes sure that they are not declared when they won't be defined
due to conditional compilation.

Signed-off-by: Ben Woodard <woodard@redhat.com>
2021-03-08 12:52:50 +01:00
Dodji Seketeli
b918ec8f77 tests/catch.hpp: Add SPDX header back
* tests/lib/catch.hpp: Add SPDX header back.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-08 11:33:56 +01:00
Dodji Seketeli
e3aa28ac7b dwarf-reader: Keep stable order when de-duplicating class definitions
During de-duplication of class definition while resolving decl-only
classes to their definition, the order in which classes of the same
name are compared is not always the same.  That results in an
instability of the particular class being kept.  This can have an
impact when some classes have member types because member types are
not meaningful during comparison; so in the end that can lead to
spurious order instability during ABIXML serialization.

	* src/abg-dwarf-reader.cc
	(read_context::resolve_declaration_only_classes): Compare the
	classes that have the same name across several TU, always in the
	same order.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-01 10:34:38 +01:00
Dodji Seketeli
f022e3e993 Better sorting of (anonymous) types in ABIXML files
I am still seeing in some cases, some instability in type sorting in
ABIXML.

It looks related to anonymous types sorting, so this patch tries
harder to have anonymous types have names more suitable for internal
matters this.

	* src/abg-writer.cc (type_ptr_cmp::operator()): Use the internal
	pretty representation of types, for comparison.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Adjust.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.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/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.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/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.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.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* 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-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-03-01 10:34:26 +01:00
Dodji Seketeli
8ae8dcb8d5 tests: Update to catch.hpp v2.13.4 and fix #2178
This patch is about fixing a compilation error that we are seeing on
Fedora Rawhide with glibc 2.33.9000, which makes MINSIGSTKSZ not be a
constant value anymore.  Thus, the sigStackSize variable that is
declared constexpr cannot use that MINSIGSTKSZ as initializer anymore.

So as suggested in the issue
https://github.com/catchorg/Catch2/issues/2178 filed against
'catchorg' for this purpose, I am hardwiring the initialization value
of sigStackSize for now.

	* tests/lib/catch.hpp: Update to v2.13.4 and initialize
	sigStackSize to 32768 for now, as suggested by
	https://github.com/catchorg/Catch2/issues/2178.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-24 09:12:06 +01:00
Dodji Seketeli
77bc4b7b15 Don't consider type name when comparing typedefs
This is from a problem report originating from Red Hat bugzilla at
https://bugzilla.redhat.com/show_bug.cgi?id=1925876

I some C programs, the same type can be defined more than once in a
binary, as there is no "One Definition Rule[1]" in C.

    [1]: https://en.wikipedia.org/wiki/One_Definition_Rule

The definition of those two types can be slightly different and yet be
equivalent.

For instance, the data member of a struct S might be defined once as
having a type which is a typedef Foo of, say, "long int" and that
struct S might be defined again elsewhere with a data member of type
typedef Bar of "long int" as well.

With the current code, because Foo and Bar have different names, they
are are going to compare different; so the two struct S are doing to
compare different even though they are equivalent.

Down the road, this is likely going to imply that the several 'struct
S' that are declaration-only will not be resolved as being
declarations of the definition of "struct S", because they is more
than one such definition, and those definitions are different.

This is going to lead to spurious (and hard to debug) type differences
that are going to be detected and reported by libabigail later down
the road.

This patch addresses the problem by not taking typedef names into
account when comparing typedefs before canonicalization.  That allows
the comparison of classes and structs that happens during the
resolution of declaration-only classes to correctly deduce their
equivalence even in cases like the one exposed above.  It thus reduces
the amount of declaration-only classes that are unnecessarily
considered to be different from the definition they ought to equal.

	* include/abg-ir.h (maybe_compare_as_member_decls): Declare new
	function.  Make it a friend of class decl_base.
	* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Don't early
	canonicalize typedefs because they can be "part" of a type that is
	not yet completed, especially considering that class declaration
	resolution is part of type building, stricto sensu.
	* src/abg-ir.cc (maybe_compare_as_member_decls): Factorize this
	out of ...
	(equals): ... the overload for decl_base.  Use it in the overload
	for typedef_decl.
	* tests/data/test-diff-pkg/nmap-7.70-5.el8_testjcc.x86_64-self-check-report-0.txt:
	New test reference output.
	* tests/data/test-diff-pkg/nmap-7.70-5.el8_testjcc.x86_64.rpm: New
	binary input.
	* tests/data/test-diff-pkg/nmap-debuginfo-7.70-5.el8_testjcc.x86_64.rpm: Likewise.
	* tests/data/Makefile.am: Add these new testing material to source
	distribution.
 	* tests/test-diff-pkg.cc (in_out_specs): Add the new test input to
	the harness.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt:
	Adjust.
	* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-11 17:23:42 +01:00
Dodji Seketeli
a8c0199df5 Use generic internal type name to canonicalize anonymous enums
This is from the problem report in Red Hat bugzilla

    https://bugzilla.redhat.com/show_bug.cgi?id=1924624
    "comparing 'libpinyin.so.13.0.0' to itself wrongly yielded result"

During the canonicalization of an anonymous enum, the algorithm uses
its internal pretty representation to limit the number of types to
compare it to.  That internal pretty representation is based on its
type name.

For anonymous types, the type name is not unique; it's constructed for
internal purposes that are different from the purpose of
canonicalization.  So using that in the pretty representation might
negatively impact the accuracy of the canonicalization; it might make
it so that two anonymous in the same namespace types might wrongly be
considered canonically different.

To fix that, this change makes the internal pretty representation of
anonymous enum types essentially be "enum
<namespace-name>::__anonymous_enum__".

This is on part with what is done for unions and classes in commit:
    005ab5c9 Use flat representation to canonicalize anonymous classes and unions

	* src/abg-ir.cc (has_generic_anonymous_internal_type_name) :
	Define new static function.
	(get_generic_anonymous_internal_type_name): Use it here.
	(decl_base::get_pretty_representation): For internal purposes,
	build an anonymous name that is stable.
	* tests/data/test-annotate/test21-pr19092.so.abi: Adjust.
	* tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: Adjust.
	* tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt: Adjust.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Adjust.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-10 20:03:11 +01:00
Giuliano Procida
25904b3212 abg-dwarf-reader: Fix typo in compare_dies_string_attribute_value
A recent commit to add DW_FORM_line_strp support had a small typo in
an assertion. This commit corrects that.

	* src/abg-dwarf-reader.cc
	(compare_dies_string_attribute_value): Typo fix.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-02-09 15:29:19 +01:00
Giuliano Procida
89de572d7b abidiff: do not qualify member names in diff report
Bug 26012 - abidiff: do not emit qualified name for data members

The enclosing struct (or union or class) is given by the surrounding
diff context. This change eliminates a lot of repetition in the diff
report.

	* src/abg-reporter-priv.cc (represent_data_member): Do not
	qualify member names. (represent): Do not qualify member names.
	* tests/data/test-abicompat/test0-fn-changed-report-0.txt: Refresh.
	* tests/data/test-abicompat/test0-fn-changed-report-2.txt: Refresh.
	* tests/data/test-abicompat/test5-fn-changed-report-0.txt: Refresh.
	* tests/data/test-abicompat/test5-fn-changed-report-1.txt: Refresh.
	* tests/data/test-abicompat/test6-var-changed-report-0.txt: Refresh.
	* tests/data/test-abicompat/test6-var-changed-report-1.txt: Refresh.
	* tests/data/test-abicompat/test7-fn-changed-report-0.txt: Refresh.
	* tests/data/test-abicompat/test7-fn-changed-report-1.txt: Refresh.
	* tests/data/test-abicompat/test7-fn-changed-report-2.txt: Refresh.
	* tests/data/test-abicompat/test8-fn-changed-report-0.txt: Refresh.
	* tests/data/test-abicompat/test9-fn-changed-report-0.txt: Refresh.
	* tests/data/test-abidiff-exit/qualifier-typedef-array-report-1.txt:
	Refresh.
	* tests/data/test-abidiff-exit/test-fun-param-report.txt: Refresh.
	* tests/data/test-abidiff-exit/test-headers-dirs/test-headers-dir-report-2.txt:
	Refresh.
	* tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt:
	Refresh.
	* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Refresh.
	* tests/data/test-abidiff-exit/test-leaf-redundant-report.txt: Refresh.
	* tests/data/test-abidiff-exit/test-member-size-report0.txt: Refresh.
	* tests/data/test-abidiff-exit/test-member-size-report1.txt: Refresh.
	* tests/data/test-abidiff-exit/test-net-change-report0.txt: Refresh.
	* tests/data/test-abidiff/test-PR18791-report0.txt: Refresh.
	* tests/data/test-abidiff/test-qual-type0-report.txt: Refresh.
	* tests/data/test-abidiff/test-struct0-report.txt: Refresh.
	* tests/data/test-abidiff/test-struct1-report.txt: Refresh.
	* tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test0-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test1-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test10-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test11-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test13-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test21-redundant-fn-report-0.txt: Refresh.
	* tests/data/test-diff-dwarf/test27-local-base-diff-report.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test3-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test32-fnptr-changes-report-0.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test33-fnref-changes-report-0.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test37-union-report-0.txt: Refresh.
	* tests/data/test-diff-dwarf/test38-union-report-0.txt: Refresh.
	* tests/data/test-diff-dwarf/test39-union-report-0.txt: Refresh.
	* tests/data/test-diff-dwarf/test4-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test40-report-0.txt: Refresh.
	* tests/data/test-diff-dwarf/test44-anon-struct-union-report-0.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt:
	Refresh.
	* tests/data/test-diff-dwarf/test46-rust-report-0.txt: Refresh.
	* tests/data/test-diff-dwarf/test5-report.txt: Refresh.
	* tests/data/test-diff-dwarf/test8-report.txt: Refresh.
	* tests/data/test-diff-filter/libtest45-basic-type-change-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test-PR26739-2-report-0.txt: Refresh.
	* tests/data/test-diff-filter/test0-report.txt: Refresh.
	* tests/data/test-diff-filter/test01-report.txt: Refresh.
	* tests/data/test-diff-filter/test1-report.txt: Refresh.
	* tests/data/test-diff-filter/test10-report.txt: Refresh.
	* tests/data/test-diff-filter/test11-report.txt: Refresh.
	* tests/data/test-diff-filter/test13-report.txt: Refresh.
	* tests/data/test-diff-filter/test14-0-report.txt: Refresh.
	* tests/data/test-diff-filter/test14-1-report.txt: Refresh.
	* tests/data/test-diff-filter/test15-0-report.txt: Refresh.
	* tests/data/test-diff-filter/test15-1-report.txt: Refresh.
	* tests/data/test-diff-filter/test16-report-2.txt: Refresh.
	* tests/data/test-diff-filter/test16-report.txt: Refresh.
	* tests/data/test-diff-filter/test17-0-report.txt: Refresh.
	* tests/data/test-diff-filter/test17-1-report.txt: Refresh.
	* tests/data/test-diff-filter/test18-report.txt: Refresh.
	* tests/data/test-diff-filter/test2-report.txt: Refresh.
	* tests/data/test-diff-filter/test25-cyclic-type-report-0.txt: Refresh.
	* tests/data/test-diff-filter/test25-cyclic-type-report-1.txt: Refresh.
	* tests/data/test-diff-filter/test26-qualified-redundant-node-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test26-qualified-redundant-node-report-1.txt:
	Refresh.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-1.txt:
	Refresh.
	* tests/data/test-diff-filter/test27-redundant-and-filtered-children-nodes-report-2.txt:
	Refresh.
	* tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test28-redundant-and-filtered-children-nodes-report-1.txt:
	Refresh.
	* tests/data/test-diff-filter/test29-finer-redundancy-marking-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test3-report.txt: Refresh.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Refresh.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Refresh.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
	Refresh.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Refresh.
	* tests/data/test-diff-filter/test32-ppc64le-struct-change-report0.txt:
	Refresh.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test36-report-0.txt: Refresh.
	* tests/data/test-diff-filter/test37-report-0.txt: Refresh.
	* tests/data/test-diff-filter/test39/test39-report-0.txt: Refresh.
	* tests/data/test-diff-filter/test42-leaf-report-output-0.txt: Refresh.
	* tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt:
	Refresh.
	* tests/data/test-diff-filter/test44-anonymous-data-member-report-1.txt:
	Refresh.
	* tests/data/test-diff-filter/test9-report.txt: Refresh.
	* tests/data/test-diff-pkg/GtkAda-gl-2.24.2-29.fc29.x86_64--2.24.2-30.fc30.x86_64-report-0.txt:
	Refresh.
	* tests/data/test-diff-pkg/PR24690/PR24690-report-0.txt: Refresh.
	* tests/data/test-diff-pkg/dirpkg-1-report-1.txt: Refresh.
	* tests/data/test-diff-pkg/dirpkg-3-report-1.txt: Refresh.
	* tests/data/test-diff-pkg/dirpkg-3-report-2.txt: Refresh.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
	Refresh.
	* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt:
	Refresh.
	* tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt:
	Refresh.
	* tests/data/test-diff-pkg/nss-3.23.0-1.0.fc23.x86_64-report-0.txt:
	Refresh.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
	Refresh.
	* tests/data/test-diff-pkg/symlink-dir-test1-report0.txt: Refresh.
	* tests/data/test-diff-pkg/tarpkg-0-report-0.txt: Refresh.
	* tests/data/test-diff-pkg/tarpkg-1-report-0.txt: Refresh.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
	Refresh.
	* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/libtest48-soname-abixml-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/test0-type-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test0-type-suppr-report-3.txt: Refresh.
	* tests/data/test-diff-suppr/test0-type-suppr-report-5.txt: Refresh.
	* tests/data/test-diff-suppr/test0-type-suppr-report-7.txt: Refresh.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test1-typedef-suppr-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test11-add-data-member-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test12-add-data-member-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test12-add-data-member-report-2.txt:
	Refresh.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test13-suppr-through-pointer-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/test14-suppr-non-redundant-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test14-suppr-non-redundant-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/test15-suppr-added-fn-report-5.txt:
	Refresh.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-2.txt:
	Refresh.
	* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt:
	Refresh.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-2.txt:
	Refresh.
	* tests/data/test-diff-suppr/test17-suppr-added-var-report-5.txt:
	Refresh.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-2.txt:
	Refresh.
	* tests/data/test-diff-suppr/test18-suppr-removed-var-report-5.txt:
	Refresh.
	* tests/data/test-diff-suppr/test2-struct-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test24-soname-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test24-soname-report-10.txt: Refresh.
	* tests/data/test-diff-suppr/test24-soname-report-12.txt: Refresh.
	* tests/data/test-diff-suppr/test24-soname-report-14.txt: Refresh.
	* tests/data/test-diff-suppr/test24-soname-report-16.txt: Refresh.
	* tests/data/test-diff-suppr/test24-soname-report-4.txt: Refresh.
	* tests/data/test-diff-suppr/test25-typedef-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test26-loc-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test26-loc-suppr-report-3.txt: Refresh.
	* tests/data/test-diff-suppr/test29-soname-report-3.txt: Refresh.
	* tests/data/test-diff-suppr/test29-soname-report-6.txt: Refresh.
	* tests/data/test-diff-suppr/test29-soname-report-8.txt: Refresh.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test3-struct-suppr-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test30-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test31-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test33-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test35-leaf-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test4-local-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test4-local-suppr-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-report-0.txt:
	Refresh.
	* tests/data/test-diff-suppr/test42-negative-suppr-type-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/test46-PR25128-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test46-PR25128-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test47-non-reachable-types-report-1.txt:
	Refresh.
	* tests/data/test-diff-suppr/test47-non-reachable-types-report-2.txt:
	Refresh.
	* tests/data/test-diff-suppr/test47-non-reachable-types-report-4.txt:
	Refresh.
	* tests/data/test-diff-suppr/test47-non-reachable-types-report-7.txt:
	Refresh.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-3.txt: Refresh.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-4.txt: Refresh.
	* tests/data/test-diff-suppr/test5-fn-suppr-report-5.txt: Refresh.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0-1.txt: Refresh.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-3.txt: Refresh.
	* tests/data/test-diff-suppr/test6-fn-suppr-report-4.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-1.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-2.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-3.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-4.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-7.txt: Refresh.
	* tests/data/test-diff-suppr/test7-var-suppr-report-8.txt: Refresh.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-0.txt: Refresh.
	* tests/data/test-diff-suppr/test8-redundant-fn-report-1.txt: Refresh.

Signed-off-by: Giuliano Procida <gprocida@google.com>
2021-02-08 16:29:13 +01:00
Dodji Seketeli
43c59daef5 dwarf-reader: Use DW_FORM_line_strp only if it's present
* configure.ac: Define if HAS_DW_FORM_line_strp if the
	DW_FORM_line_strp enumerator is present.
	* src/abg-dwarf-reader.cc (form_is_DW_FORM_line_strp): Define new
	static function.
	(compare_dies_string_attribute_value): Use it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-08 12:15:52 +01:00
Dodji Seketeli
e5c7fd3400 Bug 27267 - Better support for opaque enum types
Upon a request to build the IR for a opaque enum type,
get_opaque_version_of_type wrongly returns a nil type even though the
code is in there to construct an opaque variant of the enum.

This patch cleans up that code to let it build an opaque enum type.
It also ensures the opaque enum type is properly added to its lexical
scope to ensure proper life cycle management.

	* src/abg-dwarf-reader.cc (get_opaque_version_of_type): Do not
	quit early for enum types, because the code that comes a bit later
	can handle enums.  Add the newly built enum to its scope for
	proper life cycle management.
	* tests/data/test-diff-suppr/PR27267/include-dir-v{0,1}/include.h: New
	include files for the input test library.
	* tests/data/test-diff-suppr/PR27267/libtestpr27267-v{0,1}.so: New
	input test library.
	* tests/data/test-diff-suppr/PR27267/report-1.txt: New reference
	output for the comparison.
	* tests/data/test-diff-suppr/PR27267/v{0,1}.c: Source code for the
	new input test library.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
	above to the test harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-04 09:26:05 +01:00