Add _finite symbol aliases for better glibc compatibility
The glibc math.h header can redirect math symbols (e.g. with the
-ffinite-math-only cflag) to _finite symbols which have the same
semantics as the original ones except they may omit some error checks.
With these aliases libmathlib can be a drop in replacement for glibc
libm at link time. It's not a full replacement, but it can interpose
glibc libm calls using LD_PRELOAD in case of an already dynamic linked
binary or using -lmathlib before -lm at link time. This hopefully will
make it easy to try libmathlib with a glibc based toolchain.
Unfortunately with static linking the glibc _finite symbol definitions
may conflict with the libmathlib definitions if other glibc internal
symbols are used from the same object file where the _finite symbol is
defined. To work this around add glibc internal symbols as hidden
aliases so the conflicting glibc object files don't get linked.
This is a bit fragile since glibc can change its internal symbols and
how they are used, but it only affects static linking, which always
has this problem when symbols are interposed.
diff --git a/math/pow.c b/math/pow.c
index 3d92784..1164ce1 100644
--- a/math/pow.c
+++ b/math/pow.c
@@ -369,3 +369,7 @@
#endif
return exp_inline (ehi, elo, sign_bias);
}
+#if USE_GLIBC_ABI
+strong_alias (pow, __pow_finite)
+hidden_alias (pow, __ieee754_pow)
+#endif