This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Weak symbols not overriden
- From: Ian Lance Taylor <iant at google dot com>
- To: Pan ruochen <panruochen at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>, binutils <binutils at sourceware dot org>
- Date: Thu, 17 Mar 2011 18:36:16 -0700
- Subject: Re: Weak symbols not overriden
- References: <AANLkTim2MiESdj6tCS1uk1tSR9DS01+pSvDW8D3L0iKK@mail.gmail.com>
Pan ruochen <panruochen@gmail.com> writes:
> I found weak symbols wouldn't be overriden by the strong symbols with
> same names.
This case, involving shared libraries, actually has nothing to do with
either gcc or the binutils. It's the dynamic linker that matters here,
and that is part of the C library. You didn't say, but I'm guessing
that you are using GNU/Linux and glibc. By default, the glibc dynamic
linker uses the first definition it finds even if it is weak. That is
because overriding a weak symbol is rare, and would require the dynamic
linker to search all the remaining shared libraries.
You can get the behaviour you want by defining the environment variable
LD_DYNAMIC_WEAK.
Ian