Symbol hiding and unit tests
Torbjörn Granlund
tg at gmplib.org
Sun Jun 21 20:12:55 UTC 2015
I am finally doing something about hiding internal GMP symbols for the
shared gmplib.{so,lib,dll}. The machanism is essentially to use GCC's
__attribute__((visibility("hidden"))), which in turn make use of
features of the object file formats.
The good effects of this are:
1. The symbols cannot be reached from outside of the shared lib.
2. The internal references are resolved at library creation time instead
of at application startup time
3. The internal references do not need an indirection (via a PLT in the
case of functions, or a GOT in the case of data).
Say that we hide __gmpn_toom22_mul.
An undesirable effect is that our unit tests can no longer reach
__gmpn_toom22_mul of the shared library. It can still reach it in the
static library (as symbol hiding has no meaning there).
What to do?
We could decide that unit testing is not mainly to catch miscompilation
errors but to catch logical errors, and thus be happy with just static
testing. Fundamental testing against miscompilation will take place
indirectly. PROBLEM: Our current "make check" target do not test both
the static and the shared build (a problem in itself!), or of course
only tests either static or shared build of either was disabled.
If we don't want to do that, we need to provide a "backdoor" to the
internal functions. We could then provide an alias (using
__attribute__((alias(...)))). This, of course, re-enables user code's
access to the same internals. The other benefit (points 2 and 3)
remain.
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-devel
mailing list