aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-09-28 06:36:25 +0000
committerIan Lance Taylor <iant@google.com>2007-09-28 06:36:25 +0000
commitb3b74ddc6e208b58108b0900b4896034f84bb6be (patch)
treece562c3e12599c8d8f40e9ec75f6e729b272b62e /gold/symtab.cc
parentfe6fbf8b6eff80d3df998ab8b0e14ac984e3e265 (diff)
downloadgdb-b3b74ddc6e208b58108b0900b4896034f84bb6be.zip
gdb-b3b74ddc6e208b58108b0900b4896034f84bb6be.tar.gz
gdb-b3b74ddc6e208b58108b0900b4896034f84bb6be.tar.bz2
Use parameters to track whether we are doing a static link. Fix up
final_value_is_known for weak undefined symbols. Pointed out by Cary Coutant.
Diffstat (limited to 'gold/symtab.cc')
-rw-r--r--gold/symtab.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 332c59f..c9ac1c9 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -187,6 +187,39 @@ Sized_symbol<size>::init(const char* name, Value_type value, Size_type symsize,
this->symsize_ = symsize;
}
+// Return true if the final value of this symbol is known at link
+// time.
+
+bool
+Symbol::final_value_is_known() const
+{
+ // If we are not generating an executable, then no final values are
+ // known, since they will change at runtime.
+ if (!parameters->output_is_executable())
+ return false;
+
+ // If the symbol is not from an object file, then it is defined, and
+ // known.
+ if (this->source_ != FROM_OBJECT)
+ return true;
+
+ // If the symbol is from a dynamic object, then the final value is
+ // not known.
+ if (this->object()->is_dynamic())
+ return false;
+
+ // If the symbol is not undefined (it is defined or common), then
+ // the final value is known.
+ if (!this->is_undefined())
+ return true;
+
+ // If the symbol is undefined, then whether the final value is known
+ // depends on whether we are doing a static link. If we are doing a
+ // dynamic link, then the final value could be filled in at runtime.
+ // This could reasonably be the case for a weak undefined symbol.
+ return parameters->doing_static_link();
+}
+
// Class Symbol_table.
Symbol_table::Symbol_table()