This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: behavior of weak definitions in archive libraries
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: davidm at hpl dot hp dot com
- Cc: binutils at sources dot redhat dot com, eranian at napali dot hpl dot hp dot com, davidm at napali dot hpl dot hp dot com
- Date: 11 Nov 2003 17:33:36 -0500
- Subject: Re: behavior of weak definitions in archive libraries
- References: <16305.24047.745847.177816@napali.hpl.hp.com>
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