aboutsummaryrefslogtreecommitdiff
path: root/gold/symtab.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-01-23 07:15:59 +0000
committerIan Lance Taylor <iant@google.com>2008-01-23 07:15:59 +0000
commit0700cf329e7579515fb775fa0ccb8b4f623e7ea9 (patch)
treee85a5c586a303a545d637ba42592aec531d02dc8 /gold/symtab.h
parent7bf81d63025ff1b953e40c7610889ae3680af0a0 (diff)
downloadfsf-binutils-gdb-0700cf329e7579515fb775fa0ccb8b4f623e7ea9.zip
fsf-binutils-gdb-0700cf329e7579515fb775fa0ccb8b4f623e7ea9.tar.gz
fsf-binutils-gdb-0700cf329e7579515fb775fa0ccb8b4f623e7ea9.tar.bz2
From Cary Coutant: Fix mixing PIC and non-PIC relocs in the same
shared library.
Diffstat (limited to 'gold/symtab.h')
-rw-r--r--gold/symtab.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/gold/symtab.h b/gold/symtab.h
index 43a228d..d3e076b 100644
--- a/gold/symtab.h
+++ b/gold/symtab.h
@@ -480,21 +480,45 @@ class Symbol
&& (this->is_from_dynobj() || this->is_preemptible()));
}
+ // When determining whether a reference to a symbol needs a dynamic
+ // relocation, we need to know several things about the reference.
+ // These flags may be or'ed together.
+ enum Reference_flags
+ {
+ // Reference to the symbol's absolute address.
+ ABSOLUTE_REF = 1,
+ // A non-PIC reference.
+ NON_PIC_REF = 2,
+ // A function call.
+ FUNCTION_CALL = 4
+ };
+
// Given a direct absolute or pc-relative static relocation against
// the global symbol, this function returns whether a dynamic relocation
// is needed.
bool
- needs_dynamic_reloc(bool is_absolute_ref, bool is_function_call) const
+ needs_dynamic_reloc(int flags) const
{
// An absolute reference within a position-independent output file
- // will need a dynamic relocaion.
- if (is_absolute_ref && parameters->output_is_position_independent())
+ // will need a dynamic relocation.
+ if ((flags & ABSOLUTE_REF)
+ && parameters->output_is_position_independent())
return true;
// A function call that can branch to a local PLT entry does not need
// a dynamic relocation.
- if (is_function_call && this->has_plt_offset())
+ if ((flags & FUNCTION_CALL) && this->has_plt_offset())
+ return false;
+
+ // A non-pic pc-relative function call in a shared library whose target
+ // is defined in the same load module does not need a dynamic relocation.
+ // Even if the target is preemptible, we will bind directly, since we
+ // cannot use a PLT entry in this case.
+ if ((flags & FUNCTION_CALL)
+ && (flags & NON_PIC_REF)
+ && this->is_defined()
+ && parameters->output_is_shared())
return false;
// A reference to any PLT entry in a non-position-independent executable