public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Cc: dodji@redhat.com
Subject: [PATCH] ir: Use linkage name to sort virtual function members
Date: Fri, 01 Mar 2024 18:24:16 +0100	[thread overview]
Message-ID: <87il257tmn.fsf@redhat.com> (raw)

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


                 reply	other threads:[~2024-03-01 17:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il257tmn.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).