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: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- To: Dave Korn <dave dot korn at artimi dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 08 Apr 2005 14:30:45 +0200
- Subject: RE: Referenced symbol not present in final image?
- References: <SERRANO5y4FypKsEgJX000000bb@SERRANO.CAM.ARTIMI.COM>
> Umm, look, if you really want to know what kind of symbol it is, don't you
> just want to be using "nm" or "objdump --syms" on eh_alloc.o (or libsupc++),
> and it'll probably tell you something interesting like it's weak, or common,
> or somesuch ?
>
> If it's referenced, but doesn't get pulled into the link unless you -U it
> on the linker command line, that suggests that the object that contains it
> is too early in the link order and the objects that reference it are too
> late in the link order, so by the time the linker knows it's needed, it's
> already gone by and be discarded.
The symbol in question is weak, which explains the "strange" behaviour.
Thanks for the tip(s)!
--- a reply I got in mail directly -----
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>
--- a reply I got in mail directly -----
--
Øyvind Harboe
http://www.zylin.com