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: Referenced symbol not present in final image?


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


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