summaryrefslogtreecommitdiff
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
commit844b67aa7c83d60d43903508cf62305c508443ac (patch)
tree12a77cd4a19a1de3ef251ffbaad2605623caf092 /gold/symtab.h
parenta35f20962b7d736da82eae2c5f20d12e72cb744f (diff)
downloadbinutils-redhat-844b67aa7c83d60d43903508cf62305c508443ac.tar.gz
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 43a228d7cc..d3e076bc9c 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