Rethinking GMP's configure
rguenther at suse.de
Tue Dec 6 10:53:59 CET 2011
On Tue, 6 Dec 2011, Torbjorn Granlund wrote:
> nisse at lysator.liu.se (Niels Möller) writes:
> Makes sense to me. Either --with-cpu=ALL or --with-cpu=HOST would be a
> sensible default.
> My thinking is to make --with-cpu=ALL become the default.
> > First, let's admit there will be some overhead. At some level, there
> > will be a need to jump through a table, initiated for the run-time CPU.
> > This indirection costs a few cycles each time. But note that in a
> > shared library, we typically access data through a GOT (global offset
> > table) and call functions indirectly through a PLT (procedure linkage
> > table). I think we could stay within the overhead of shared library
> > calls, if we do things right. (For ELF, that is, where we can control
> > such things.)
> I think I suggested, some time ago, that one could overwrite the table
> entries in the PLT, with no *additional* indirections. But that may not
> work. If I understand things correctly, there's no *the* PLT, there's a
> PLT in each loadable object (executable or shared library file). And
> then I have already forgotten how that is supposed to work with function
> Ian Lance Taylor has written some excellent texts about all this. (They
> should be next to your search engine.)
> This is a messy area, even if one ignores the worls outside of ELF.
> (The PLT is, as you say, part of the process, and not to be manipulated
> by the shared library. Perhaps it is *possible* to manipulate it using
> some dll calls on *some* systems, but I don't think this would be the
> right path.)
For GNU ELF systems you have the possibility to use IFUNC relocations
(basically the relocation depends on the outcome of a selector function
you implement). GLIBC now internally uses this to select between
different implementations of for example memcpy for the CPU a
program is executed on.
That is basically "PLT modification", but at relocation time
(thus not really "modification").
The IFUNC relocations are a GNU ELF extension (and require recent
dynamic loader and binutils support, of course).
Richard Guenther <rguenther at suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
More information about the gmp-devel