From: Dodji Seketeli Date: Mon, 12 Jun 2017 17:10:20 +0000 (+0200) Subject: Symbols with the same zero value are not aliases X-Git-Tag: upstream/1.0~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bb0c1c322d0d834214b8f13561823bf1b5deb8e4;p=platform%2Fupstream%2Flibabigail.git Symbols with the same zero value are not aliases When looking at ELF file of the ET_REL kind (i.e, relocatable object files), several kinds of symbols (for instance weak symbols) can have the symbol value zero. Although they have the same value, the fact that that value is zero prevents us from considering those symbols as being aliases. Libabigail was wrongly considering those symbols with value zero as being aliases. So, in practice, it was considering all WEAK symbols as being aliases, because the value of a weak symbols is zero. When comparing two binaries originating from the same source code, one compiled with g++ and the other one compiled with clang++, abidiff was thus reporting spurious function aliases changes due to this issue. Note that the two binaries in question come from the bug PR21486. Comparing them using abidiff exhibits several other issues that were fixed in previous commits, such as - Reporting changes about top cv qualifier changes on function parameter types. - Not supporting ELF symbol visibility * src/abg-dwarf-reader.cc (load_symbol_maps_from_symtab_section): Do not consider symbols with zero value as being aliases. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Likewise. * test-diff-filter/test41-PR21486-abg-writer.gcc.o: New test binary input. * tests/data/test-diff-filter/test41-PR21486-abg-writer.llvm.o: Likewise. * tests/data/Makefile.am: Add the new test material to source distribution. * tests/test-diff-filter.cc (in_out_specs): Run the test harness on the new test input above. * tests/data/test-diff-dwarf/test5-report.txt: Adjust. * tests/data/test-diff-filter/test9-report.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-0.txt: Adjust. * tests/data/test-diff-filter/test20-inline-report-1.txt: Adjust. Signed-off-by: Dodji Seketeli --- diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index f6faa34e..01e83fb7 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -6682,7 +6682,7 @@ public: fun_addr_sym_map_->find(sym->st_value); if (it == fun_addr_sym_map_->end()) (*fun_addr_sym_map_)[sym->st_value] = symbol; - else + else if (sym->st_value != 0) it->second->get_main_symbol()->add_alias(symbol); if (is_ppc64) diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index c7e405ef..bc107303 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -625,6 +625,9 @@ test-diff-filter/libtest40-v1.so \ test-diff-filter/test40-report-0.txt \ test-diff-filter/test40-v0.cc \ test-diff-filter/test40-v1.cc \ +test-diff-filter/test41-PR21486-abg-writer.gcc.o \ +test-diff-filter/test41-PR21486-abg-writer.llvm.o \ +test-diff-filter/test41-report-0.txt \ \ test-diff-suppr/test0-type-suppr-v0.cc \ test-diff-suppr/test0-type-suppr-v1.cc \ diff --git a/tests/data/test-diff-dwarf/test5-report.txt b/tests/data/test-diff-dwarf/test5-report.txt index 2f099dbc..c8c9830f 100644 --- a/tests/data/test-diff-dwarf/test5-report.txt +++ b/tests/data/test-diff-dwarf/test5-report.txt @@ -4,8 +4,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some indirect sub-type change: [C]'function C0 foo()' has some indirect sub-type changes: - Please note that the symbol of this function is _ZN2C0C2Ev - and it aliases symbols: _ZN2C0C1Ev, _Z3foov return type changed: entity changed from 'class C0' to compatible type 'typedef c0_type' type size hasn't changed diff --git a/tests/data/test-diff-filter/test20-inline-report-0.txt b/tests/data/test-diff-filter/test20-inline-report-0.txt index e69de29b..9666a8fd 100644 --- a/tests/data/test-diff-filter/test20-inline-report-0.txt +++ b/tests/data/test-diff-filter/test20-inline-report-0.txt @@ -0,0 +1,3 @@ +Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + diff --git a/tests/data/test-diff-filter/test20-inline-report-1.txt b/tests/data/test-diff-filter/test20-inline-report-1.txt index e69de29b..2abdae77 100644 --- a/tests/data/test-diff-filter/test20-inline-report-1.txt +++ b/tests/data/test-diff-filter/test20-inline-report-1.txt @@ -0,0 +1,9 @@ +Functions changes summary: 0 Removed, 1 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +1 function with some indirect sub-type change: + + [C]'function int bar()' has some indirect sub-type changes: + 'function int bar() {_ZN1S3fooEv}' now becomes 'method int S::foo() {_ZN1S3fooEv}' + + diff --git a/tests/data/test-diff-filter/test41-PR21486-abg-writer.gcc.o b/tests/data/test-diff-filter/test41-PR21486-abg-writer.gcc.o new file mode 100644 index 00000000..2927c249 Binary files /dev/null and b/tests/data/test-diff-filter/test41-PR21486-abg-writer.gcc.o differ diff --git a/tests/data/test-diff-filter/test41-PR21486-abg-writer.llvm.o b/tests/data/test-diff-filter/test41-PR21486-abg-writer.llvm.o new file mode 100644 index 00000000..1a9f8f95 Binary files /dev/null and b/tests/data/test-diff-filter/test41-PR21486-abg-writer.llvm.o differ diff --git a/tests/data/test-diff-filter/test41-report-0.txt b/tests/data/test-diff-filter/test41-report-0.txt new file mode 100644 index 00000000..b167de0a --- /dev/null +++ b/tests/data/test-diff-filter/test41-report-0.txt @@ -0,0 +1,42 @@ +Functions changes summary: 0 Removed, 0 Changed (4 filtered out), 1 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable +Function symbols changes summary: 12 Removed, 15 Added function symbols not referenced by debug info +Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info + +1 Added function: + + 'function bool abigail::xml_writer::annotate(const abigail::ir::function_type_sptr&, abigail::xml_writer::write_context&, unsigned int)' {_ZN7abigail10xml_writer13write_context10sort_typesERKSt6vectorINSt3tr110shared_ptrINS_2ir13function_typeEEESaIS7_EERS2_INS4_INS5_9type_baseEEESaISD_EE} + +12 Removed function symbols not referenced by debug info: + + _ZN7abigail10xml_writer13write_context32record_decl_only_type_as_emittedEPNS_2ir9type_baseE + _ZN7abigail10xml_writer13write_contextC1EPKNS_2ir11environmentERSob + _ZN7abigail10xml_writer13write_contextD1Ev + _ZNKSt3tr18__detail20_Prime_rehash_policy14_M_need_rehashEmmm + _ZNSt11_Deque_baseIjSaIjEED1Ev + _ZNSt11_Deque_baseIjSaIjEED2Ev + _ZNSt3tr114__shared_countILN9__gnu_cxx12_Lock_policyE2EEaSERKS3_ + _ZNSt3tr116_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE12emplace_backIJS5_EEEvDpOT_ + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE16_M_push_back_auxIJS5_EEEvDpOT_ + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EED1Ev + _ZNSt5dequeIjSaIjEE16_M_push_back_auxIJRKjEEEvDpOT_ + +15 Added function symbols not referenced by debug info: + + _ZN7abigail10xml_writer13write_context10sort_typesERNSt3tr113unordered_mapIPNS_2ir9type_baseENS_15interned_stringENS0_11type_hasherENS_10diff_utils19deep_ptr_eq_functorESaISt4pairIKS6_S7_EEEERSt6vectorIS6_SaIS6_EE + _ZN7abigail10xml_writer13write_context18get_id_for_fn_tmplB5cxx11ERKNSt3tr110shared_ptrINS_2ir14function_tdeclEEE + _ZN7abigail10xml_writer13write_context21get_id_for_class_tmplB5cxx11ERKNSt3tr110shared_ptrINS_2ir11class_tdeclEEE + _ZN7abigail10xml_writer13write_context25record_type_id_as_emittedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE + _ZNSt11_Deque_baseINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE15_M_create_nodesEPPS5_S9_ + _ZNSt11_Deque_baseIjSaIjEE15_M_create_nodesEPPjS3_ + _ZNSt20__uninitialized_copyILb0EE13__uninit_copyISt15_Deque_iteratorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKS8_PS9_ES2_IS8_RS8_PS8_EEET0_T_SH_SG_ + _ZNSt3tr116_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EED2Ev + _ZNSt3tr132__enable_shared_from_this_helperILN9__gnu_cxx12_Lock_policyE2EEEvRKNS_14__shared_countIXT_EEEz + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE16_M_push_back_auxERKS5_ + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE17_M_reallocate_mapEmb + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE19_M_destroy_data_auxESt15_Deque_iteratorIS5_RS5_PS5_ESB_ + _ZNSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EEC2ERKS7_ + _ZNSt5dequeIjSaIjEE17_M_reallocate_mapEmb + _ZNSt5stackINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt5dequeIS5_SaIS5_EEE4pushERKS5_ + diff --git a/tests/data/test-diff-filter/test9-report.txt b/tests/data/test-diff-filter/test9-report.txt index a600efe5..94b973ba 100644 --- a/tests/data/test-diff-filter/test9-report.txt +++ b/tests/data/test-diff-filter/test9-report.txt @@ -1,5 +1,7 @@ Functions changes summary: 0 Removed, 1 Changed, 2 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable +Function symbols changes summary: 0 Removed, 1 Added function symbol not referenced by debug info +Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info 2 Added functions: @@ -16,3 +18,7 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 'int S::m0', at offset 0 (in bits) +1 Added function symbol not referenced by debug info: + + _ZN1SC1Ev + diff --git a/tests/test-diff-filter.cc b/tests/test-diff-filter.cc index 4254aaa2..1b8e38d5 100644 --- a/tests/test-diff-filter.cc +++ b/tests/test-diff-filter.cc @@ -471,6 +471,13 @@ InOutSpec in_out_specs[] = "data/test-diff-filter/test40-report-0.txt", "output/test-diff-filter/test40-report-0.txt", }, + { + "data/test-diff-filter/test41-PR21486-abg-writer.gcc.o", + "data/test-diff-filter/test41-PR21486-abg-writer.llvm.o", + "--no-default-suppression", + "data/test-diff-filter/test41-report-0.txt", + "output/test-diff-filter/test41-report-0.txt", + }, // This should be the last entry {NULL, NULL, NULL, NULL, NULL} };