aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2008-08-04 22:22:13 +0000
committerIan Lance Taylor <ian@airs.com>2008-08-04 22:22:13 +0000
commitde4c45bd54870058d0ee91a652df9f1652b12cdb (patch)
tree84e4795da42d1cc11212fdea401c73944d38bac3 /gold/symtab.h
parente5e6a5ff6ea89e1f8627d16d492288e0b8e834b1 (diff)
downloadgdb-de4c45bd54870058d0ee91a652df9f1652b12cdb.zip
gdb-de4c45bd54870058d0ee91a652df9f1652b12cdb.tar.gz
gdb-de4c45bd54870058d0ee91a652df9f1652b12cdb.tar.bz2
* symtab.h (Symbol::use_plt_offset): New function.
* i386.cc (Relocate::relocate): Call Symbol::use_plt_offset. * powerpc.cc (Relocate::relocate): Likewise. * sparc.cc (Relocate::relocate): Likewise. * x86_64.cc (Relocate::relocate): Likewise. * testsuite/weak_plt.sh: New test. * testsuite/weak_plt_main.cc: New test. * testsuite/weak_plt_shared.cc: New test. * testsuite/Makefile.am (check_SCRIPTS): Add weak_plt.sh. (check_PROGRAMS): Add weak_plt. (check_DATA): Add weak_plt_shared.so. (weak_plt_main_pic.o, weak_plt): New targets. (weak_plt_shared_pic.o, weak_plt_shared.so): New targets. * testsuite/Makefile.in: Rebuild. * testsuite/Makefile.am (weak_alias_test_1.so): Depend upon gcctestdir/ld. (weak_alias_test_2.so, weak_alias_test_4.so): Likewise. * testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/symtab.h')
-rw-r--r--gold/symtab.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/gold/symtab.h b/gold/symtab.h
index 3c998f8..043fb50f 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -577,6 +577,48 @@ class Symbol
return false;
}
+ // Whether we should use the PLT offset associated with a symbol for
+ // a relocation. IS_NON_PIC_REFERENCE is true if this is a non-PIC
+ // reloc--the same set of relocs for which we would pass NON_PIC_REF
+ // to the needs_dynamic_reloc function.
+
+ bool
+ use_plt_offset(bool is_non_pic_reference) const
+ {
+ // If the symbol doesn't have a PLT offset, then naturally we
+ // don't want to use it.
+ if (!this->has_plt_offset())
+ return false;
+
+ // If we are going to generate a dynamic relocation, then we will
+ // wind up using that, so no need to use the PLT entry.
+ if (this->needs_dynamic_reloc(FUNCTION_CALL
+ | (is_non_pic_reference
+ ? NON_PIC_REF
+ : 0)))
+ return false;
+
+ // If the symbol is from a dynamic object, we need to use the PLT
+ // entry.
+ if (this->is_from_dynobj())
+ return true;
+
+ // If we are generating a shared object, and this symbol is
+ // undefined or preemptible, we need to use the PLT entry.
+ if (parameters->options().shared()
+ && (this->is_undefined() || this->is_preemptible()))
+ return true;
+
+ // If this is a weak undefined symbol, we need to use the PLT
+ // entry; the symbol may be defined by a library loaded at
+ // runtime.
+ if (this->is_weak_undefined())
+ return true;
+
+ // Otherwise we can use the regular definition.
+ return false;
+ }
+
// Given a direct absolute static relocation against
// the global symbol, where a dynamic relocation is needed, this
// function returns whether a relative dynamic relocation can be used.