This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[gold][patch] Fix problem where unsatisfied reference to vtable causes a misleading error message
- From: Cary Coutant <ccoutant at google dot com>
- To: Binutils <binutils at sourceware dot org>
- Date: Tue, 24 Mar 2009 13:37:05 -0700
- Subject: [gold][patch] Fix problem where unsatisfied reference to vtable causes a misleading error message
This patch fixes a problem where an unsatisfied reference to a vtable
causes the linker to print an error message "requires unsupported
dynamic reloc; recompile with -fPIC" (in addition to the undefined
symbol error). This happened because we were still creating a dynamic
relocation for the unsatisfied reference.
The Target_*::Scan::check_non_pic() routines in several of the targets
(all except i386, I think) still have a problem where they print that
error message even when we're not building a shared library. This
patch bypasses the most likely case where we would hit that problem,
but I'll follow up with a separate patch to catch any remaining cases
where that might happen.
OK to commit?
-cary
* symtab.h (needs_plt_entry): Check for unsatisfied reference from
an executable.
(needs_dynamic_reloc): Likewise.
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gold/symtab.h,v
retrieving revision 1.87
diff -u -p -r1.87 symtab.h
--- symtab.h 17 Mar 2009 07:07:21 -0000 1.87
+++ symtab.h 24 Mar 2009 20:25:35 -0000
@@ -530,6 +530,10 @@ class Symbol
bool
needs_plt_entry() const
{
+ // An undefined symbol from an executable does not need a PLT entry.
+ if (this->is_undefined() && !parameters->options().shared())
+ return false;
+
return (!parameters->doing_static_link()
&& this->type() == elfcpp::STT_FUNC
&& (this->is_from_dynobj()
@@ -561,10 +565,10 @@ class Symbol
if (parameters->doing_static_link())
return false;
- // A reference to a weak undefined symbol from an executable should be
+ // A reference to an undefined symbol from an executable should be
// statically resolved to 0, and does not need a dynamic relocation.
// This matches gnu ld behavior.
- if (this->is_weak_undefined() && !parameters->options().shared())
+ if (this->is_undefined() && !parameters->options().shared())
return false;
// A reference to an absolute symbol does not need a dynamic relocation.