libabigail/tests
Dodji Seketeli 01e5bfc4a4 Bug 25007 - Don't use section-relative symbol values on ET_REL binaries
In relocatable files, two symbols listed in the .symtab section can
have the same value and yet be different.  That is because those
symbols can be *defined* in different sections.  And the value of
those symbols represent addresses (offsets) within their own
respective sections (a.k.a section-relative addresses).

In the same time, symbol address as referred-to in the DWARF
information are *not* section-relative, rather, they are relative to
the beginning of the whole binary.

Until now, the DWARF-referred-to symbol addresses were translated into
section-relative addresses, so that they could be compared to the
other section-relative addresses we were getting from listing the
symbols and their values from the .symtab section.  The problem with
that approach is that, during the translation from binary-relative to
section-relative addresses we were wrongly assuming that all symbols
referenced from the DWARF were defined in the .text section.  This is
wrong especially for ET_REL files because they could be defined in
sections named .foo.text or .bar.text, for instance.

This leads to issues where we wrongly consider that two symbols having the
same value are the same.  Because we wrongly assume that they are all
defined in the same .text section.

This patch fixes this problem by translating the section-relative
addresses we see in .symtab into binary-relative addresses by adding
the address of the section to the section-relative address.  Those
binary-addresses can thus safely be compared to the binary-relative
addresses we see in the DWARF.  And also, when two symbols have the
same binary-relative address, we can now safely assume that they are
the same -- they are aliases, basically.

	* src/abg-dwarf-reader.cc
	(read_context::{lookup_native_elf_symbol_from_index,
	maybe_adjust_et_rel_sym_addr_to_abs_addr}): Define new member
	functions.
	(read_context::lookup_elf_symbol_from_index): Add a new overload.
	Write the old overloads in terms of the new one.
	(read_context::{load_symbol_maps_from_symtab_section,
	populate_symbol_map_from_ksymtab_reloc}): Use the new
	maybe_adjust_et_rel_sym_addr_to_abs_addr function to translate the
	symbol value/address into a binary-relative address before adding
	it to the addr->sym maps.
	(read_context::maybe_adjust_{fn, var}_sym_address): Do not adjust
	DWARF-referred-to addresses of ET_REL symbols anymore.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko: New binary test input.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: ABI
	representation of the above.
	* tests/test-read-dwarf.cc: Add the new test input to the harness.
	* tests/data/test-diff-dwarf/test28-vtable-changes-report-0.txt: Adjust.
	* tests/data/test-diff-filter/test20-inline-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test20-inline-report-1.txt: Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test9-report.txt: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-09-20 14:13:12 +02:00
..
data Bug 25007 - Don't use section-relative symbol values on ET_REL binaries 2019-09-20 14:13:12 +02:00
.gitignore Update tests/.gitignore to ignore runtesttoolsutils 2019-07-09 17:33:58 +02:00
Makefile.am Ensure a consistent C++ standard use 2019-07-22 11:18:13 +02:00
mockfedabipkgdiff.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
print-diff-tree.cc abilint: fix return types bool -> int 2019-04-16 16:11:01 +02:00
runtestcanonicalizetypes.sh.in
runtestdefaultsupprs.py.in Fix typo in tests/runtestdefaultsupprs.py 2018-05-24 10:48:56 +02:00
runtestdefaultsupprspy3.sh.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
runtestfedabipkgdiff.py.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
runtestfedabipkgdiffpy3.sh.in Bug 22722 - Make fedabipkgdiff and its tests support both python 3 and 2 2018-03-29 13:46:50 +02:00
test-abicompat.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-abidiff-exit.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-abidiff.cc Bug 24552 - abidiff fails comparing a corpus against a corpus group 2019-05-16 18:10:08 +02:00
test-alt-dwarf-file.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-annotate.cc Handle several member anonymous types of the same kind 2019-05-07 14:31:16 +02:00
test-core-diff.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-diff2.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-diff-dwarf-abixml.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-diff-dwarf.cc Conditionalize the Rust support regression test 2019-01-24 11:06:57 +01:00
test-diff-filter.cc Bug 24787 - Filter out enum changes into compatible integer types 2019-07-19 18:22:12 +02:00
test-diff-pkg.cc Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
test-diff-suppr.cc Bug 24139 - Support suppressing some enumerator changes 2019-01-31 09:20:06 +01:00
test-dot.cc
test-ini.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-ir-walker.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-lookup-syms.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-read-dwarf.cc Bug 25007 - Don't use section-relative symbol values on ET_REL binaries 2019-09-20 14:13:12 +02:00
test-read-write.cc Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
test-svg.cc
test-tools-utils.cc Fully account for anonymous-ness of scopes when comparing decl names 2019-06-21 11:42:44 +02:00
test-types-stability.cc Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
test-utils.cc Update copyright for 2019 2019-01-07 14:54:47 +01:00
test-utils.h Conditionalize the Rust support regression test 2019-01-24 11:06:57 +01:00
test-valgrind-suppressions.supp Shut down a helgrind false positive in the "system" libc call 2017-03-17 09:02:19 +01:00
test-write-read-archive.cc Add compatibility layer for C++11 mode 2019-07-09 18:05:28 +02:00
update-test-output.py Rename tests/update-test-read-dwarf-output.py 2016-12-02 12:59:32 +01:00