Weak symbol in an executable, overridable by shared libraries at runtime
Lorenzo Pistone
blaffablaffa@gmail.com
Sat Nov 2 21:44:00 GMT 2013
Hello,
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.
Cheers.
More information about the Binutils
mailing list