[gold patch] Fix problem with --export-dynamic-symbol and versioned symbols

Cary Coutant ccoutant@google.com
Tue May 22 21:13:00 GMT 2012


The --dynamic-list and --export-dynamic-symbol options can trigger an
internal error in Symbol_table::sized_finalize_symbol() if a named
symbol is referenced with a version from a dynamic object. In that
case, we try to force a dynamic symbol table entry for the versioned
symbol in the dynamic object. This patch fixes the problem by forcing
the dynamic symbol table entry only after checking that the symbol is
defined in a non-shared object.

Tested on x86_64. OK to commit?

-cary


2012-05-22  Cary Coutant  <ccoutant@google.com>

	* symtab.cc (Symbol::should_add_dynsym_entry): Check for relocatable
	object before exporting symbol.


commit 932930f6aaa2e75093e97d57eb90128d1da635ab
Author: Cary Coutant <ccoutant@google.com>
Date:   Tue May 22 13:58:32 2012 -0700

    Don't export symbols from shared objects.

diff --git a/gold/symtab.cc b/gold/symtab.cc
index a820b0a..1bb9867 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -365,8 +365,10 @@ Symbol::should_add_dynsym_entry(Symbol_table* symtab) const

   // If the symbol was forced dynamic in a --dynamic-list file
   // or an --export-dynamic-symbol option, add it.
-  if (parameters->options().in_dynamic_list(this->name())
-      || parameters->options().is_export_dynamic_symbol(this->name()))
+  if (this->source() == Symbol::FROM_OBJECT
+      && !this->object()->is_dynamic()
+      && (parameters->options().in_dynamic_list(this->name())
+	  || parameters->options().is_export_dynamic_symbol(this->name())))
     {
       if (!this->is_forced_local())
         return true;



More information about the Binutils mailing list