summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-05-06 17:46:31 +0000
committerIan Lance Taylor <ian@airs.com>2008-05-06 17:46:31 +0000
commit3c0f13d4622f5aec575da6d9da33cc7cc41dcd30 (patch)
tree9871a55b46b0d85e867c7a4483d61349f46192b4
parentf564b46aadd48563b2afba24822a75af628ed291 (diff)
downloadbinutils-redhat-3c0f13d4622f5aec575da6d9da33cc7cc41dcd30.tar.gz
* options.h (class General_options): Add -Bsymbolic-functions.
* symtab.h (Symbol::is_preemptible): Check for -Bsymbolic-functions.
-rw-r--r--gold/ChangeLog6
-rw-r--r--gold/options.h3
-rw-r--r--gold/symtab.h36
3 files changed, 39 insertions, 6 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 3ae464f53b..358ec64bfb 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2008-05-05 Ian Lance Taylor <iant@google.com>
* options.h (DEFINE_bool): For DASH_Z, create the negative option
diff --git a/gold/options.h b/gold/options.h
index 0dd822104d..9eb51ce032 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -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]"));
diff --git a/gold/symtab.h b/gold/symtab.h
index 1ee3131d8f..020f242c50 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -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.