]> sourceware.org Git - libabigail.git/commit
Fix size calculations for multidimensional arrays.
authorGiuliano Procida <gprocida@google.com>
Thu, 26 Mar 2020 15:38:14 +0000 (15:38 +0000)
committerDodji Seketeli <dodji@redhat.com>
Tue, 31 Mar 2020 17:48:35 +0000 (19:48 +0200)
commit2d5389f2656d3ca248b1f3d848bbd51e8cfa7e75
treeb1ad168bf2bd852ae74d4c9480698f225968d3b0
parent88c90d14d96f99978e2016f936c5dfca6e273cbd
Fix size calculations for multidimensional arrays.

The code in abg-ir.cc that calculated the memory size of an array
summed, rather than multiplied, the dimensions. It also did duplicate
work for each dimension after the first.

Existing code in abg-reader.cc asserted that array size information
read from XML match freshly calculated values.

This patch corrects the calculation, eliminates the duplicate work and
updates the XML reader validation to just emit a warning if old bad
array size information is found.

* include/abg-ir.h (array_type_def::append_subrange): Remove
this function.
* src/abg-ir.cc (array_type_def::set_element_type): Add a note
about safe usage.
(array_type_def::append_subrange): Inline this function into
its only caller append_subranges and remove it.
(array_type_def::append_subranges): Do correct multiplicative
calculation of multidimensional array sizes.
* src/abg-reader.cc (build_array_type_def): When checking
calculated against read array sizes, warn once if value
matches old behaviour rather than raising an assertion.
Otherwise, before raising an assertion, emit an informative
error message.
* tests/data/test-annotate/test14-pr18893.so.abi: Correct
array sizes.
* tests/data/test-annotate/test17-pr19027.so.abi: Ditto.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Ditto.
* tests/data/test-annotate/test7.so.abi: Ditto.
* tests/data/test-diff-dwarf/test10-report.txt: Ditto.
* tests/data/test-diff-dwarf/test11-report.txt: Ditto.
* tests/data/test-read-write/test25.xml: Ditto.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
include/abg-ir.h
src/abg-ir.cc
src/abg-reader.cc
tests/data/test-annotate/test14-pr18893.so.abi
tests/data/test-annotate/test17-pr19027.so.abi
tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi
tests/data/test-annotate/test7.so.abi
tests/data/test-diff-dwarf/test10-report.txt
tests/data/test-diff-dwarf/test11-report.txt
tests/data/test-read-write/test25.xml
This page took 0.038102 seconds and 5 git commands to generate.