[gold patch] When comparing two symbols, handle the forwarding case

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gold patch] When comparing two symbols, handle the forwarding case

Sourceware - binutils list mailing list
The function Cref_inputs::Cref_table_compare::operator() claims that
two different symbols can't have the same name and version.

But this can actually happen in obscure cases dealing with forwarding
symbols. See the complicated comment in
Symbol_table::define_default_version for those circumstances.

I'm having trouble writing a small test case to demonstrate the
failure, but I believe it's straightforward fix.

The enclosed patch adds logic to handle such a case.

2018-1-10 Sterling Augustine <[hidden email]>
* cref.cc (Cref_inputs::Cref_table_compare::operator): Add conditionals and
calls to is_forwarder

diff --git a/gold/cref.cc b/gold/cref.cc
index 84a9e46c84..0777453501 100644
--- a/gold/cref.cc
+++ b/gold/cref.cc
@@ -236,9 +236,13 @@ Cref_inputs::Cref_table_compare::operator()(const
Symbol* s1,
     }

   // We should never have two different symbols with the same name and
-  // version.
+  // version, where one doesn't forward to the other.
   if (s1 == s2)
     return false;
+  if (s1->is_forwarder() && !s2->is_forwarder())
+    return true;
+  if (!s1->is_forwarder() && s2->is_forwarder())
+    return false;
   gold_unreachable();
 }

gold.patch (762 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [gold patch] When comparing two symbols, handle the forwarding case

ccoutant
> 2018-1-10 Sterling Augustine <[hidden email]>
> * cref.cc (Cref_inputs::Cref_table_compare::operator): Add conditionals and
> calls to is_forwarder

This is OK, but please s/-1-/-01-/ in the ChangeLog. Thanks!

-cary
Reply | Threaded
Open this post in threaded view
|

Re: [gold patch] When comparing two symbols, handle the forwarding case

Sourceware - binutils list mailing list
On Fri, Jan 12, 2018 at 9:24 AM, Cary Coutant <[hidden email]> wrote:
>> 2018-1-10 Sterling Augustine <[hidden email]>
>> * cref.cc (Cref_inputs::Cref_table_compare::operator): Add conditionals and
>> calls to is_forwarder
>
> This is OK, but please s/-1-/-01-/ in the ChangeLog. Thanks!

Done, committed, and backported to release branches thanks to Eric Christopher.