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/binutils-2_27-branch] Fix potential crashes when Target::make_symbol() returns NULL.


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

commit 7ce7da866e7a4027237dc05574ef9228b1cf7675
Author: James Clarke <jrtc27@jrtc27.com>
Date:   Wed Aug 10 09:58:01 2016 -0700

    Fix potential crashes when Target::make_symbol() returns NULL.
    
    2016-08-10  James Clarke  <jrtc27@jrtc27.com>
    
    gold/
    	PR gold/20443
    	* symtab.cc (Symbol_table::add_from_relobj): Handle NULL symbols,
    	which will be present for STT_SPARC_REGISTER.
    	(Symbol_table::add_from_pluginobj): Likewise.
    	(Symbol_table::add_from_dynobj): Likewise.
    	(Symbol_table::add_from_incrobj): Removed dead code.

Diff:
---
 gold/ChangeLog |  9 +++++++++
 gold/symtab.cc | 13 +++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index d0a670b..10677c7 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,5 +1,14 @@
 2016-08-10  James Clarke  <jrtc27@jrtc27.com>
 
+	PR gold/20443
+	* symtab.cc (Symbol_table::add_from_relobj): Handle NULL symbols,
+	which will be present for STT_SPARC_REGISTER.
+	(Symbol_table::add_from_pluginobj): Likewise.
+	(Symbol_table::add_from_dynobj): Likewise.
+	(Symbol_table::add_from_incrobj): Removed dead code.
+
+2016-08-10  James Clarke  <jrtc27@jrtc27.com>
+
 	PR gold/20442
 	* sparc.cc (Target_sparc::Relocate::relocate): R_SPARC_GOTDATA_OP_LOX10
 	should fall back on R_SPARC_GOT10, not R_SPARC_GOT13.
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 5ce5c31..b31794a 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -1325,6 +1325,9 @@ Symbol_table::add_from_relobj(
       res = this->add_from_object(relobj, name, name_key, ver, ver_key,
 				  is_default_version, *psym, st_shndx,
 				  is_ordinary, orig_st_shndx);
+
+      if (res == NULL)
+	continue;
       
       if (is_forced_local)
 	this->force_local(res);
@@ -1406,6 +1409,9 @@ Symbol_table::add_from_pluginobj(
 		              is_default_version, *sym, st_shndx,
 			      is_ordinary, st_shndx);
 
+  if (res == NULL)
+    return NULL;
+
   if (is_forced_local)
     this->force_local(res);
 
@@ -1602,6 +1608,9 @@ Symbol_table::add_from_dynobj(
 	    }
 	}
 
+      if (res == NULL)
+	continue;
+
       // Note that it is possible that RES was overridden by an
       // earlier object, in which case it can't be aliased here.
       if (st_shndx != elfcpp::SHN_UNDEF
@@ -1640,7 +1649,6 @@ Symbol_table::add_from_incrobj(
 
   Stringpool::Key ver_key = 0;
   bool is_default_version = false;
-  bool is_forced_local = false;
 
   Stringpool::Key name_key;
   name = this->namepool_.add(name, true, &name_key);
@@ -1650,9 +1658,6 @@ Symbol_table::add_from_incrobj(
 		              is_default_version, *sym, st_shndx,
 			      is_ordinary, st_shndx);
 
-  if (is_forced_local)
-    this->force_local(res);
-
   return res;
 }


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