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?


>   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


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