This is the mail archive of the
mailing list for the binutils project.
Re: Weak symbol in an executable, overridable by shared libraries at runtime
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Lorenzo Pistone <blaffablaffa at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sun, 3 Nov 2013 04:05:27 -0800
- Subject: Re: Weak symbol in an executable, overridable by shared libraries at runtime
- Authentication-results: sourceware.org; auth=none
- References: <52757240 dot 4020107 at gmail dot com>
On Sat, Nov 2, 2013 at 2:44 PM, Lorenzo Pistone <firstname.lastname@example.org> wrote:
> Is there a way to define a weak symbol in an executable (not a .so!), that
> can be overridden by the runtime linking process by a symbol found in
> another library?
> The aim is to provide a fallback implementation, within my executable, for
> systems where a specific function in a standard library cannot be found.
> More exactly, if I compile my program with -ffast-math, some calls to
> __pow_finite are generated: on recent systems this function is in libm.so,
> but on older systems this function simply does not exist. The idea is then
> to have a weak symbol "__pow_infinite" in my executable, whose
> implementation just calls the normal "pow": this way, on a recent system,
> the weak symbol is overridden and the libm.so version is used, whereas on an
> old system there's no other symbol than the weak one, that would be then
> picked up.
The secondary symbol is what you are looking for. But it isn't supported