This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PATCH: Fix weak definition in regular object
- To: Ian Lance Taylor <ian at zembu dot com>, binutils at sourceware dot cygnus dot com
- Subject: PATCH: Fix weak definition in regular object
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Wed, 3 Oct 2001 11:29:47 -0700
Hi Ian,
We should allow an old definition, weak or non-weak, in a shared object
to override a new weak definition in a regular object. Here is a patch.
H.J.
----
2001-10-03 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_merge_symbol): Allow a definition in a shared
object to override a weak definition in a regular object.
--- bfd/elflink.h.weak Wed Oct 3 09:49:15 2001
+++ bfd/elflink.h Wed Oct 3 11:25:52 2001
@@ -908,8 +908,8 @@ elf_merge_symbol (abfd, info, name, sym,
override a definition in a shared object if the shared object
symbol is a function or is weak.
- As above, we permit a non-weak definition in a shared object to
- override a weak definition in a regular object. */
+ As above, we permit a definition in a shared object to override a
+ weak definition in a regular object. */
if (! newdyn
&& (newdef
@@ -930,8 +930,13 @@ elf_merge_symbol (abfd, info, name, sym,
h->root.u.undef.abfd = h->root.u.def.section->owner;
*size_change_ok = true;
- olddef = false;
- olddyncommon = false;
+ /* A definition in a shared object can override a weak definition
+ in a regular object. */
+ if (bind != STB_WEAK)
+ {
+ olddef = false;
+ olddyncommon = false;
+ }
/* We again permit a type change when a common symbol may be
overriding a function. */
@@ -1023,14 +1028,13 @@ elf_merge_symbol (abfd, info, name, sym,
*sym_hash = h;
}
- /* Handle the special case of a non-weak definition in a shared
- object followed by a weak definition in a regular object. In
- this case we prefer to definition in the shared object. To make
- this work we have to tell the caller to not treat the new symbol
- as a definition. */
+ /* Handle the special case of a definition in a shared object
+ followed by a weak definition in a regular object. In this case
+ we prefer to definition in the shared object. To make this work
+ we have to tell the caller to not treat the new symbol as a
+ definition. */
if (olddef
&& olddyn
- && h->root.type != bfd_link_hash_defweak
&& newdef
&& ! newdyn
&& bind == STB_WEAK)