summaryrefslogtreecommitdiff
path: root/gold/symtab.h
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2008-04-04 17:24:47 +0000
committerCary Coutant <ccoutant@google.com>2008-04-04 17:24:47 +0000
commit86925eef33811b6ca76006e539314a7de652b5c8 (patch)
tree860e974f6df678882727d8b0a9fd35c227e86fa7 /gold/symtab.h
parent594ab6a333bf85639e6839a924534fa264616c39 (diff)
downloadbinutils-gdb-86925eef33811b6ca76006e539314a7de652b5c8.tar.gz
2008-04-04 Cary Coutant <ccoutant@google.com>
* symtab.h (Symbol::is_weak_undefined): New function. (Symbol::is_strong_undefined): New function. (Symbol::is_absolute): New function. (Symbol::needs_plt_entry): Exclude weak undefined symbols. (Symbol::needs_dynamic_reloc): Exclude weak undefined and absolute symbols. * testsuite/Makefile.am (check_PROGRAMS): Add weak_undef_test. (weak_undef_test): New target. * testsuite/Makefile.in: Rebuild. * testsuite/weak_undef_file1.cc: New file. * testsuite/weak_undef_file2.cc: New file. * testsuite/weak_undef_test.cc: New file.
Diffstat (limited to 'gold/symtab.h')
-rw-r--r--gold/symtab.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/gold/symtab.h b/gold/symtab.h
index bd417948cd3..e262cd4cc59 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -405,6 +405,31 @@ class Symbol
return this->source_ == FROM_OBJECT && this->shndx() == elfcpp::SHN_UNDEF;
}
+ // Return whether this is a weak undefined symbol.
+ bool
+ is_weak_undefined() const
+ {
+ return (this->source_ == FROM_OBJECT
+ && this->binding() == elfcpp::STB_WEAK
+ && this->shndx() == elfcpp::SHN_UNDEF);
+ }
+
+ // Return whether this is a strong (i.e., not weak) undefined symbol.
+ bool
+ is_strong_undefined() const
+ {
+ return (this->source_ == FROM_OBJECT
+ && this->binding() != elfcpp::STB_WEAK
+ && this->shndx() == elfcpp::SHN_UNDEF);
+ }
+
+ // Return whether this is an absolute symbol.
+ bool
+ is_absolute() const
+ {
+ return this->source_ == FROM_OBJECT && this->shndx() == elfcpp::SHN_ABS;
+ }
+
// Return whether this is a common symbol.
bool
is_common() const
@@ -453,7 +478,7 @@ class Symbol
return (!parameters->doing_static_link()
&& this->type() == elfcpp::STT_FUNC
&& (this->is_from_dynobj()
- || this->is_undefined()
+ || this->is_strong_undefined()
|| this->is_preemptible()));
}
@@ -481,6 +506,11 @@ class Symbol
if (parameters->doing_static_link())
return false;
+ // A reference to a weak undefined symbol or to an absolute symbol
+ // does not need a dynamic relocation.
+ if (this->is_weak_undefined() || this->is_absolute())
+ return false;
+
// An absolute reference within a position-independent output file
// will need a dynamic relocation.
if ((flags & ABSOLUTE_REF)