GMP symbol naming (and the history thereof)?

Niels Möller nisse at lysator.liu.se
Thu Feb 28 10:20:23 CET 2013


Torbjorn Granlund <tg at gmplib.org> writes:

> There are some specific GNU/Linux loader features which were
> discusssed here not long ago.  I prefer to start portable, then do
> unportable tweaks.  (Yes, the GNU system is the most important goal
> for the GNU project, but I want GMP to be great on every reasonable
> platform.)

I think it's possible to keep the current fat mechanism mor or less as
is, and additionally use IFUNC-relocations where available. The IFUNC
hooks should call in to GMP's fat machinery and then return an
appropriate function pointer back to the linker.

> Another reason is to stay away from the user name space with our
> internal routines.  Today we can do that more cleanly, at least on ELF
> systems, but GMP was born in 1991 before these "teenage features"
> existed.  :-)

I think it make sense with some level of name mangling from API symbols
to linker names. First, it's good practice to use a single prefix for
all linker symbols, while it's nice to use multiple prefixes for API
symbols (mpz_*, mpn_*, gmp_*, ...).

Second, and maybe you don't agree, I think it's quite reasonable for
users to use the name spaces mpz_* and mpn_* for application functions
working with the corresponding types. With some name mangling for gmp
symbol names, at least that user doesn't risk collision with the
internal gmp functions.

Third, I think it's desirable if gmp and mini-gmp keep using different
symbol names as seen by the linker.

But I don't think using a __ prefix on symbols is appropriate, it would
be better to use the namespace gmp_* or maybe libgmp_*.

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list