This is the mail archive of the binutils@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]

PATCH COMMITTED: Add -Bsymbolic-functions


"Andreas Hartmetz" <ahartmetz@gmail.com> writes:

> + else if (!strcmp(argv[i], "-Bsymbolic-functions")

I committed this patch to add support for -Bsymbolic-functions.

Ian


2008-05-06  Ian Lance Taylor  <iant@google.com>

	* options.h (class General_options): Add -Bsymbolic-functions.
	* symtab.h (Symbol::is_preemptible): Check for
	-Bsymbolic-functions.


Index: options.h
===================================================================
RCS file: /cvs/src/src/gold/options.h,v
retrieving revision 1.73
diff -p -u -r1.73 options.h
--- options.h	6 May 2008 05:03:15 -0000	1.73
+++ options.h	6 May 2008 17:42:35 -0000
@@ -510,6 +510,9 @@ class General_options
   DEFINE_bool(Bsymbolic, options::ONE_DASH, '\0', false,
               N_("Bind defined symbols locally"), NULL);
 
+  DEFINE_bool(Bsymbolic_functions, options::ONE_DASH, '\0', false,
+	      N_("Bind defined function symbols locally"), NULL);
+
   DEFINE_optional_string(build_id, options::TWO_DASHES, '\0', "sha1",
 			 N_("Generate build ID note"),
 			 N_("[=STYLE]"));
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gold/symtab.h,v
retrieving revision 1.75
diff -p -u -r1.75 symtab.h
--- symtab.h	19 Apr 2008 18:30:58 -0000	1.75
+++ symtab.h	6 May 2008 17:42:35 -0000
@@ -467,12 +467,36 @@ class Symbol
     // is preemptible.
     gold_assert(!this->is_undefined());
 
-    return (this->visibility_ != elfcpp::STV_INTERNAL
-            && this->visibility_ != elfcpp::STV_HIDDEN
-            && this->visibility_ != elfcpp::STV_PROTECTED
-            && !this->is_forced_local_
-            && parameters->options().shared()
-	    && !parameters->options().Bsymbolic());
+    // If a symbol does not have default visibility, it can not be
+    // seen outside this link unit and therefore is not preemptible.
+    if (this->visibility_ != elfcpp::STV_DEFAULT)
+      return false;
+
+    // If this symbol has been forced to be a local symbol by a
+    // version script, then it is not visible outside this link unit
+    // and is not preemptible.
+    if (this->is_forced_local_)
+      return false;
+
+    // If we are not producing a shared library, then nothing is
+    // preemptible.
+    if (!parameters->options().shared())
+      return false;
+
+    // If the user used -Bsymbolic, then nothing is preemptible.
+    if (parameters->options().Bsymbolic())
+      return false;
+
+    // If the user used -Bsymbolic-functions, then functions are not
+    // preemptible.  We explicitly check for not being STT_OBJECT,
+    // rather than for being STT_FUNC, because that is what the GNU
+    // linker does.
+    if (this->type() != elfcpp::STT_OBJECT
+	&& parameters->options().Bsymbolic_functions())
+      return false;
+
+    // Otherwise the symbol is preemptible.
+    return true;
   }
 
   // Return true if this symbol is a function that needs a PLT entry.

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