libabigail/tests/data/test-read-dwarf/test4.so.abi

24 lines
1.4 KiB
Plaintext
Raw Normal View History

<abi-corpus path='data/test-read-dwarf/test4.so'>
Support reading and comparing soname from ELF files Libabigail's DWARF reader doesn't read the DT_SONAME tag from the .dynamic section. The abigail::corpus type doesn't have a property for that tag either. And the comparison engine doesn't take that tag in when comparing corpora. This patch modifies the DWARF reader to read the DT_SONAME and DT_NEEDED tags from the .dynamic section. The value of DT_SONAME tag is then saved in the new corpus property accessed by the new abigail::corpus::get_soname() accessor. The comparison engine has also been modified to compare the sonames of two corpora being compared. Note that the value of the DT_NEEDED elf tag is saved in a new corpus property that is accessed via the new abigail::corpus::get_needed() getter. This property is not used yet. This patch also adds a unit test for this new feature. * include/abg-corpus.h (corpus::{get_needed, set_needed, get_soname, set_soname}): Declare new accessors. * src/abg-corpus.cc (corpus::priv::{needed, soname}): New data members. (corpus::{get_needed, set_needed, get_soname, set_soname}): Define new accessors. (corpus::is_empty): Take dt_needed and dt_soname in account in computing empty-ness. * src/abg-dwarf-reader.cc (read_context::{dt_needed_, dt_soname_}): New data members. (read_context::{dt_needed, dt_soname}): New accessors. (read_context::load_dt_soname_and_needed): New member function. (read_corpus_from_elf): Call the new read_context::load_dt_soname_and_needed() to read the dt_soname and dt_needed tags. Set them to the corpus. * include/abg-comparison.h (diff_context::show_soname_change): Declare new accessors. * src/abg-comparison.cc (diff_context::priv::show_soname_change_): New data member. (diff_context::priv::priv): Initialize the new data member diff_context::priv::show_soname_change_. (diff_context::show_soname_change): Define new accessors. (corpus_diff::priv::sonames_equal_): New data member. (corpus_diff::priv::priv): Initialize the new data member corpus_diff::priv::sonames_equal_. (corpus_diff::length): Take the new priv_->sonames_equals_ data member in account. (corpus_diff::{report, priv::emit_diff_stats}): If the sonames changed and we are allowed to report it, then report it. (compute_diff): In the variant for corpus_diff, do not forget to compare the sonames. * src/abg-reader.cc (build_needed, read_elf_needed_from_input): Define new static functions. (read_corpus_from_input): Read the 'soname' attribute from the 'abi-corpus' xml element node. * src/abg-writer.cc (write_elf_needed): Define new static function. (write_corpus_to_native_xml): Write a new 'elf-needed' xml element node that contains one xml 'dependency' element node per dependency to emit. This uses the new write_elf_needed() function above. * tests/data/test-diff-dwarf/libtest19-soname-v0.so: New test input data. * tests/data/test-diff-dwarf/libtest19-soname-v1.so: Likewise. * tests/data/test-diff-dwarf/test19-soname-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test19-soname-v0.c: Source code of the first binary above. * tests/data/test-diff-dwarf/test19-soname-v1.c: Source code of the second binary above. * tests/test-diff-dwarf.cc (in_out_specs): Add the test input above to the list of test input to run this harness on. * tests/data/Makefile.am: Add the new test input data above. * tests/data/test-read-dwarf/test{0,1}.abi: Adjust. * tests/data/test-read-dwarf/test{2,3,4,6,}.so.abi: Adjust. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-12-07 20:01:20 +00:00
<elf-needed>
<dependency name='libc.so.6'/>
</elf-needed>
<elf-function-symbols>
<elf-symbol name='cpy' type='func-type' binding='global-binding' is-defined='yes'/>
</elf-function-symbols>
<abi-instr version='1.0' address-size='64' path='test4.c'>
Type read from DWARF don't have alignment information Types read from DWARF don't have any alignment information so we shouldn't try to guess it, especially for structures. So this patch sets the alignment to zero in that case. This helps remove some spurious alignment changes detected by abidiff just because in some cases we fail to guess that. In the process, I noticed that when calculating the hash value of a given data member, we were not including the hash value of its context. This led to mistakenly considering some data member changes as redundant. So the patch fixes that too. * src/abg-dwarf-reader.cc (build_type_decl) (build_class_type_and_add_to_ir, build_pointer_type_def) (build_reference_type, build_function_decl): Set the alignment for native types, class, reference and function type to zero, effectively meaning that they don't have alignment information. * src/abg-hash.cc (var_decl::hash::operator): Take the hash value of the data member context in account when computing the hash value of a given data member. * tests/data/test-diff-dwarf/test-23-diff-arch-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-05-24 15:16:41 +00:00
<type-decl name='char' size-in-bits='8' id='type-id-1'/>
<pointer-type-def type-id='type-id-1' size-in-bits='64' id='type-id-2'/>
<qualified-type-def type-id='type-id-2' restrict='yes' id='type-id-3'/>
<qualified-type-def type-id='type-id-1' const='yes' id='type-id-4'/>
Type read from DWARF don't have alignment information Types read from DWARF don't have any alignment information so we shouldn't try to guess it, especially for structures. So this patch sets the alignment to zero in that case. This helps remove some spurious alignment changes detected by abidiff just because in some cases we fail to guess that. In the process, I noticed that when calculating the hash value of a given data member, we were not including the hash value of its context. This led to mistakenly considering some data member changes as redundant. So the patch fixes that too. * src/abg-dwarf-reader.cc (build_type_decl) (build_class_type_and_add_to_ir, build_pointer_type_def) (build_reference_type, build_function_decl): Set the alignment for native types, class, reference and function type to zero, effectively meaning that they don't have alignment information. * src/abg-hash.cc (var_decl::hash::operator): Take the hash value of the data member context in account when computing the hash value of a given data member. * tests/data/test-diff-dwarf/test-23-diff-arch-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-05-24 15:16:41 +00:00
<pointer-type-def type-id='type-id-4' size-in-bits='64' id='type-id-5'/>
<qualified-type-def type-id='type-id-5' restrict='yes' id='type-id-6'/>
Type read from DWARF don't have alignment information Types read from DWARF don't have any alignment information so we shouldn't try to guess it, especially for structures. So this patch sets the alignment to zero in that case. This helps remove some spurious alignment changes detected by abidiff just because in some cases we fail to guess that. In the process, I noticed that when calculating the hash value of a given data member, we were not including the hash value of its context. This led to mistakenly considering some data member changes as redundant. So the patch fixes that too. * src/abg-dwarf-reader.cc (build_type_decl) (build_class_type_and_add_to_ir, build_pointer_type_def) (build_reference_type, build_function_decl): Set the alignment for native types, class, reference and function type to zero, effectively meaning that they don't have alignment information. * src/abg-hash.cc (var_decl::hash::operator): Take the hash value of the data member context in account when computing the hash value of a given data member. * tests/data/test-diff-dwarf/test-23-diff-arch-report-0.txt: Adjust. * tests/data/test-diff-dwarf/test10-report.txt: Likewise. * tests/data/test-diff-dwarf/test13-report.txt: Likewise. * tests/data/test-diff-dwarf/test22-changed-parm-c-report-0.txt: Likewise. * tests/data/test-diff-dwarf/test26-added-parms-before-variadic-report.txt: Likewise. * tests/data/test-diff-dwarf/test8-report.txt: Likewise. * tests/data/test-diff-dwarf/test9-report.txt: Likewise. * tests/data/test-diff-filter/test13-report.txt: Likewise. * tests/data/test-diff-filter/test6-report.txt: Likewise. * tests/data/test-diff-suppr/test9-changed-parm-c-report-0.txt: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test5.o.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2015-05-24 15:16:41 +00:00
<type-decl name='unsigned int' size-in-bits='32' id='type-id-7'/>
<function-decl name='cpy' mangled-name='cpy' filepath='/home/mark/src/tests/test4.c' line='2' column='1' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='cpy'>
<parameter type-id='type-id-3' name='s1' filepath='/home/mark/src/tests/test4.c' line='2' column='1'/>
<parameter type-id='type-id-6' name='s2' filepath='/home/mark/src/tests/test4.c' line='2' column='1'/>
<parameter type-id='type-id-7' name='n' filepath='/home/mark/src/tests/test4.c' line='2' column='1'/>
<return type-id='type-id-2'/>
</function-decl>
</abi-instr>
</abi-corpus>