Weak symbols not overriden

Ian Lance Taylor iant@google.com
Fri Mar 18 06:02:00 GMT 2011


Pan ruochen <panruochen@gmail.com> writes:

> I find there are some symbols with the same names existing both in libc
> and in libpthread. All these symbols are weak. I guess the libpthread
> provides multi-threading safe functions rather than libc provides
> single-threading versions. But since all these symbols are weak, how the
> dynamic loader choose the symbol in libpthread if libpthread is linked
> against the application?
>
> $nm -D libpthread.so.0 | grep '\<sendto\>'
> 00010d54 W sendto
> $nm -D libc-2.8.so | grep '\<sendto\>'
> 000e0704 W sendto

I have to encourage you to send glibc questions to the glibc mailing
list, rather than to the gcc and binutils mailing lists.

As far as I know, it works because programs link against libpthread
before they link against libc, so the dynamic linker searches libpthread
first.

Ian



More information about the Gcc-help mailing list