This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix problem where undef can fail to trigger archive rescan.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=71739b698d47945463f183619078ff680c277f0f

commit 71739b698d47945463f183619078ff680c277f0f
Author: Stephen Crane <sjc@immunant.com>
Date:   Fri Dec 1 12:10:02 2017 -0800

    Fix problem where undef can fail to trigger archive rescan.
    
    If a shared library contains an undefined symbol and LTO adds
    a new reference to that same undefined symbol, the reference in the new
    object added by the plugin would not trigger a rescan of the archive
    containing the symbol.
    
    2017-11-17  Stephen Crane  <sjc@immunant.com>
    
    gold/
    	PR gold/22448
    	* symtab.cc (Symbol_table::add_from_object): Only rescan for
    	undefined symbols in regular, not dynamic, objects.

Diff:
---
 gold/ChangeLog |  6 ++++++
 gold/symtab.cc | 15 ++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 43a3d70..e4b890e 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-17  Stephen Crane  <sjc@immunant.com>
+
+	PR gold/22448
+	* symtab.cc (Symbol_table::add_from_object): Only rescan for
+	undefined symbols in regular, not dynamic, objects.
+
 2017-11-30  Peter Smith  <peter.smith@linaro.org>
 
 	PR gold/20765
diff --git a/gold/symtab.cc b/gold/symtab.cc
index d1f71e0..e50b42c 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -990,7 +990,7 @@ Symbol_table::add_from_object(Object* object,
   // ins.second: true if new entry was inserted, false if not.
 
   Sized_symbol<size>* ret;
-  bool was_undefined;
+  bool was_undefined_in_reg;
   bool was_common;
   if (!ins.second)
     {
@@ -998,7 +998,7 @@ Symbol_table::add_from_object(Object* object,
       ret = this->get_sized_symbol<size>(ins.first->second);
       gold_assert(ret != NULL);
 
-      was_undefined = ret->is_undefined();
+      was_undefined_in_reg = ret->is_undefined() && ret->in_reg();
       // Commons from plugins are just placeholders.
       was_common = ret->is_common() && ret->object()->pluginobj() == NULL;
 
@@ -1049,7 +1049,7 @@ Symbol_table::add_from_object(Object* object,
 	  // it, then change it to NAME/VERSION.
 	  ret = this->get_sized_symbol<size>(insdefault.first->second);
 
-	  was_undefined = ret->is_undefined();
+	  was_undefined_in_reg = ret->is_undefined() && ret->in_reg();
 	  // Commons from plugins are just placeholders.
 	  was_common = ret->is_common() && ret->object()->pluginobj() == NULL;
 
@@ -1061,7 +1061,7 @@ Symbol_table::add_from_object(Object* object,
 	}
       else
 	{
-	  was_undefined = false;
+	  was_undefined_in_reg = false;
 	  was_common = false;
 
 	  Sized_target<size, big_endian>* target =
@@ -1105,9 +1105,10 @@ Symbol_table::add_from_object(Object* object,
 	ret->set_is_default();
     }
 
-  // Record every time we see a new undefined symbol, to speed up
-  // archive groups.
-  if (!was_undefined && ret->is_undefined())
+  // Record every time we see a new undefined symbol, to speed up archive
+  // groups. We only care about symbols undefined in regular objects here
+  // because undefined symbols only in dynamic objects should't trigger rescans.
+  if (!was_undefined_in_reg && ret->is_undefined() && ret->in_reg())
     {
       ++this->saw_undefined_;
       if (parameters->options().has_plugins())


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]