behavior of weak definitions in archive libraries

Ian Lance Taylor ian@wasabisystems.com
Tue Nov 11 22:33:00 GMT 2003


David Mosberger <davidm@napali.hpl.hp.com> writes:

> We're seeing a problem which appears to come from an unexpected (to
> me) behavior of the linker: it appears that if a program has a weak
> reference to a symbol in an archive object and there is no other
> reason for the archive object to be linked in, then the weak reference
> will end up being resolved to NULL.

This behaviour is intentional for ELF.  That is how ELF linkers work.

>From http://www.caldera.com/developers/gabi/1998-04-29/ch4.symtab.html

  When the link editor searches archive libraries [see ``Archive
  File'' in Chapter 7], it extracts archive members that contain
  definitions of undefined global symbols.  The member's definition
  may be either a global or a weak symbol.  The link editor does not
  extract archive members to resolve undefined weak symbols.
  Unresolved weak symbols have a zero value.

Ian



More information about the Binutils mailing list