This is the mail archive of the binutils@sourceware.org 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: Weak symbols not overriden


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


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