This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Referenced symbol not present in final image?
- From: Ravi Ramaseshan <ramaseshan dot ravi at gmail dot com>
- To: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 8 Apr 2005 17:53:17 +0530
- Subject: Re: Referenced symbol not present in final image?
- References: <1112956254.23080.30.camel@localhost.localdomain>
- Reply-to: Ravi Ramaseshan <ramaseshan dot ravi at gmail dot com>
On Apr 8, 2005 4:00 PM, Øyvind Harboe <oyvind.harboe@zylin.com> wrote:
> Using binutils 2.15:
>
> Under what circumstances would the linker allow a symbol to be
> referenced but not defined?
If you define a symbol as weak and do not provide a definition for the
same (as in the example below) then the linker would allow the symbol
to be undefined but still referenced in the binary.
<snip>
#include<stdio.h>
void foo() __attribute__ ((weak));
int main()
{
int c;
if(!c)
foo();
return 0;
}
</snip>
Regards,
Ravi Ramaseshan.
PS: Please correct me if I am wrong. Sorry for the incomplete reply I
sent earlier.
--
" All man's miseries derive from not being able to sit in a room alone. "
- Blaise Pascal