This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Binutils is broken by the linker change


On Fri, Mar 19, 2004 at 09:57:20AM +1030, Alan Modra wrote:
> On Thu, Mar 18, 2004 at 02:51:42PM -0800, H. J. Lu wrote:
> > Here is a patch. Basically, a weak definition is treated as strong if
> > the other comes from a shared library.
> 
> Email lag, sorry.  I committed my patch, but I see you have a different
> fix, one that reflects the way ld.so works.  ie. in the testcase you
> sent to the list, the weak foo is the one that actually gets called.
> The strong foo in a later dynamic lib _doesn't_ override.
> 
> Please, please, add this testcase to the ld testsuite!  With weak and
> strong foo returning different values or somesuch so you can check
> which one is called..

I will add it.

> 
> > @@ -887,6 +885,15 @@ _bfd_elf_merge_symbol (bfd *abfd,
> >    oldweak = (h->root.type == bfd_link_hash_defweak
> >  	     || h->root.type == bfd_link_hash_undefweak);
> >  
> > +  /* If a new weak definition comes from a regular file and the old
> > +     symbol comes from a dynamic library, we treat the new one as
> > +     strong.  Further, an old weak definition is treated as strong
> > +     when the new symbol comes from a dynamic library.  */
> > +  if (newdef && !newdyn && olddyn)
> > +    newweak = FALSE;
> > +  if (olddef && newdyn)
> > +    oldweak = FALSE;
> > +
> >    /* It's OK to change the type if either the existing symbol or the
> >       new symbol is weak.  A type change is also OK if the old symbol
> >       is undefined and the new symbol is defined.  */
> 
> Is there a reason why you moved this code above the type/size change
> code?  Also, I don't think there is any need to add newdef and olddef
> to the tests.  That just confuses the meaning of newweak and oldweak.
> 

We don't want to change type/size if a weak definition is treated
as strong. If we don't check newdef and olddef, we may treat a
weak reference as strong.

>   /* If a new weak symbol comes from a regular file and the old symbol
>      comes from a dynamic library, we treat the new one as strong.
>      Similarly, an old weak symbol from a regular file is treated as
>      strong when the new symbol comes from a dynamic library.  Further,
>      an old weak symbol from a dynamic library is treated as strong if
>      the new symbol is from a dynamic library.  This reflects the way
>      glibc's ld.so works.  */
>   if (!newdyn && olddyn)
>     newweak = FALSE;
>   if (newdyn)
>     oldweak = FALSE;
> 



H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]