mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-15 22:44:41 +00:00
01e5bfc4a4
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> |
||
---|---|---|
.. | ||
data | ||
.gitignore | ||
Makefile.am | ||
mockfedabipkgdiff.in | ||
print-diff-tree.cc | ||
runtestcanonicalizetypes.sh.in | ||
runtestdefaultsupprs.py.in | ||
runtestdefaultsupprspy3.sh.in | ||
runtestfedabipkgdiff.py.in | ||
runtestfedabipkgdiffpy3.sh.in | ||
test-abicompat.cc | ||
test-abidiff-exit.cc | ||
test-abidiff.cc | ||
test-alt-dwarf-file.cc | ||
test-annotate.cc | ||
test-core-diff.cc | ||
test-diff2.cc | ||
test-diff-dwarf-abixml.cc | ||
test-diff-dwarf.cc | ||
test-diff-filter.cc | ||
test-diff-pkg.cc | ||
test-diff-suppr.cc | ||
test-dot.cc | ||
test-ini.cc | ||
test-ir-walker.cc | ||
test-lookup-syms.cc | ||
test-read-dwarf.cc | ||
test-read-write.cc | ||
test-svg.cc | ||
test-tools-utils.cc | ||
test-types-stability.cc | ||
test-utils.cc | ||
test-utils.h | ||
test-valgrind-suppressions.supp | ||
test-write-read-archive.cc | ||
update-test-output.py |