public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ir: Use linkage name to sort virtual function members
@ 2024-03-01 17:24 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2024-03-01 17:24 UTC (permalink / raw)
  To: libabigail; +Cc: dodji

Hello,

There is some instability in the abixml output whenever two virtual
member functions have the same vtable offset and different mangling
name.  This patch takes the mangling into account.

	* src/abg-ir.cc (virtual_member_function_less_than::operator()):
	Take the linkage name into account during sorting before taking
	into account the presence of elf symbols.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applying to the master branch
---
 src/abg-ir.cc                                        |  9 ++++-----
 tests/data/test-read-dwarf/test12-pr18844.so.abi     | 12 ++++++------
 .../data/test-read-dwarf/test9-pr18818-clang.so.abi  |  4 ++--
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index fcacc382..d3fbafb4 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -25006,6 +25006,10 @@ struct virtual_member_function_less_than
     if (f_offset != s_offset) return f_offset < s_offset;
 
     string fn, sn;
+    // Try the linkage names (important for destructors).
+    fn = f.get_linkage_name();
+    sn = s.get_linkage_name();
+    if (fn != sn) return fn < sn;
 
     // If the functions have symbols, then compare their symbol-id
     // string.
@@ -25019,11 +25023,6 @@ struct virtual_member_function_less_than
 	if (fn != sn) return fn < sn;
       }
 
-    // Try the linkage names (important for destructors).
-    fn = f.get_linkage_name();
-    sn = s.get_linkage_name();
-    if (fn != sn) return fn < sn;
-
     // None of the functions have symbols or linkage names that
     // distinguish them, so compare their pretty representation.
     fn = f.get_pretty_representation();
diff --git a/tests/data/test-read-dwarf/test12-pr18844.so.abi b/tests/data/test-read-dwarf/test12-pr18844.so.abi
index 8d95aa18..25c649ac 100644
--- a/tests/data/test-read-dwarf/test12-pr18844.so.abi
+++ b/tests/data/test-read-dwarf/test12-pr18844.so.abi
@@ -25632,18 +25632,18 @@
       <typedef-decl name='BSONElementMSet' type-id='type-id-3494' filepath='src/mongo/bson/bsonobj.h' line='53' column='1' id='type-id-3523'/>
       <namespace-decl name='repl'>
         <class-decl name='ScatterGatherAlgorithm' size-in-bits='64' visibility='default' filepath='src/mongo/db/repl/scatter_gather_algorithm.h' line='55' column='1' id='type-id-3475'>
-          <member-function access='public' vtable-offset='0'>
-            <function-decl name='getRequests' mangled-name='_ZNK5mongo4repl22ScatterGatherAlgorithm11getRequestsEv' filepath='src/mongo/db/repl/scatter_gather_algorithm.h' line='60' column='1' visibility='default' binding='global' size-in-bits='64'>
-              <parameter type-id='type-id-3477' is-artificial='yes'/>
-              <return type-id='type-id-3498'/>
-            </function-decl>
-          </member-function>
           <member-function access='protected' destructor='yes' vtable-offset='0'>
             <function-decl name='~ScatterGatherAlgorithm' mangled-name='_ZN5mongo4repl22ScatterGatherAlgorithmD0Ev' filepath='src/mongo/db/repl/scatter_gather_algorithm.h' line='76' column='1' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='_ZN5mongo4repl22ScatterGatherAlgorithmD2Ev'>
               <parameter type-id='type-id-3478' is-artificial='yes'/>
               <return type-id='type-id-2697'/>
             </function-decl>
           </member-function>
+          <member-function access='public' vtable-offset='0'>
+            <function-decl name='getRequests' mangled-name='_ZNK5mongo4repl22ScatterGatherAlgorithm11getRequestsEv' filepath='src/mongo/db/repl/scatter_gather_algorithm.h' line='60' column='1' visibility='default' binding='global' size-in-bits='64'>
+              <parameter type-id='type-id-3477' is-artificial='yes'/>
+              <return type-id='type-id-3498'/>
+            </function-decl>
+          </member-function>
           <member-function access='public' vtable-offset='1'>
             <function-decl name='processResponse' mangled-name='_ZN5mongo4repl22ScatterGatherAlgorithm15processResponseERKNS_8executor20RemoteCommandRequestERKNS_10StatusWithINS2_21RemoteCommandResponseEEE' filepath='src/mongo/db/repl/scatter_gather_algorithm.h' line='65' column='1' visibility='default' binding='global' size-in-bits='64'>
               <parameter type-id='type-id-3478' is-artificial='yes'/>
diff --git a/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi b/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi
index 94d766c5..a7ee1ef3 100644
--- a/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi
+++ b/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi
@@ -4804,13 +4804,13 @@
             </function-decl>
           </member-function>
           <member-function access='public' destructor='yes' vtable-offset='0'>
-            <function-decl name='~system_error' mangled-name='_ZN5boost6system12system_errorD2Ev' filepath='src/third_party/boost-1.56.0/boost/system/system_error.hpp' line='47' column='1' visibility='default' binding='global' size-in-bits='64'>
+            <function-decl name='~system_error' mangled-name='_ZN5boost6system12system_errorD0Ev' filepath='src/third_party/boost-1.56.0/boost/system/system_error.hpp' line='47' column='1' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='_ZN5boost6system12system_errorD2Ev'>
               <parameter type-id='type-id-206' is-artificial='yes'/>
               <return type-id='type-id-118'/>
             </function-decl>
           </member-function>
           <member-function access='public' destructor='yes' vtable-offset='0'>
-            <function-decl name='~system_error' mangled-name='_ZN5boost6system12system_errorD0Ev' filepath='src/third_party/boost-1.56.0/boost/system/system_error.hpp' line='47' column='1' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='_ZN5boost6system12system_errorD2Ev'>
+            <function-decl name='~system_error' mangled-name='_ZN5boost6system12system_errorD2Ev' filepath='src/third_party/boost-1.56.0/boost/system/system_error.hpp' line='47' column='1' visibility='default' binding='global' size-in-bits='64'>
               <parameter type-id='type-id-206' is-artificial='yes'/>
               <return type-id='type-id-118'/>
             </function-decl>
-- 
2.39.3


-- 
		Dodji


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-01 17:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-01 17:24 [PATCH] ir: Use linkage name to sort virtual function members Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).