This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Fix weak definition in regular object
On Wed, Oct 03, 2001 at 12:11:13PM -0700, Ian Lance Taylor wrote:
> "H . J . Lu" <hjl@lucon.org> writes:
>
> > 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.
>
> This is fine with me.
>
I clean it up a little bit since overriding weak definition in a
regular object is handled at the end of elf_merge_symbol.
Thanks.
H.J.
----
--- bfd/elflink.h.weak Wed Oct 3 09:49:15 2001
+++ bfd/elflink.h Wed Oct 3 13:53:08 2001
@@ -906,10 +906,7 @@ elf_merge_symbol (abfd, info, name, sym,
As above, we again permit a common symbol in a regular object to
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. */
+ symbol is a function or is weak. */
if (! newdyn
&& (newdef
@@ -919,8 +916,7 @@ elf_merge_symbol (abfd, info, name, sym,
&& olddyn
&& olddef
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (bind != STB_WEAK
- || h->root.type == bfd_link_hash_defweak))
+ && bind != STB_WEAK)
{
/* Change the hash table entry to undefined, and let
_bfd_generic_link_add_one_symbol do the right thing with the
@@ -1023,14 +1019,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)