Fix assertion failure on aliases of dynamic weak symbols

H.J. Lu
Mon Jul 16 21:33:00 GMT 2007

On Mon, Jul 16, 2007 at 06:10:10PM +0100, Richard Sandiford wrote:
> The attached testcase fails on GNU/Linux targets with:
>   BFD (GNU Binutils) assertion fail .../bfd/elflink.c:2496
> A shared library has a weak symbol "foo", and bfd determines that the
> strong symbol "data_start" is an alias for "foo" (it has the same section
> and value).  The shared library is then involved in another link, and the
> script for that link defines "data_start" via a PROVIDE statement.

That piece of code was added by Richard on May 3, 1999 with

  /* Now set the weakdefs field correctly for all the weak defined
     symbols we found.  The only way to do this is to search all the
     symbols.  Since we only need the information for non functions in
     dynamic objects, that's the only time we actually put anything on
     the list WEAKS.  We need this information so that if a regular
     object refers to a symbol defined weakly in a dynamic object, the
     real symbol in the dynamic object is also put in the dynamic
     symbols; we also must arrange for both symbols to point to the
     same memory location.  We could handle the general case of symbol
     aliasing, but a general symbol alias can only be generated in
     assembler code, handling it correctly would be very time
     consuming, and other ELF linkers don't handle general aliasing
     either.  */

It no longer applies today since there is no difference between
weak def and strong def in a shared library. Richard, do you
remember if there is a testcase for your change? Can we remove
the whole u.weakdef thing now? It will make linker simpler and



More information about the Binutils mailing list