Some secondary asm T3,T4,T5 functions

David Miller davem at davemloft.net
Tue Apr 2 07:54:04 CEST 2013


From: Torbjorn Granlund <tg at gmplib.org>
Date: Tue, 02 Apr 2013 04:30:32 +0200

> More work is needed for loading table symbols.

Reading this code over reminded me of an issue we should address on
sparc.

We need to add some configury and macros for PIC sequences, because we
should use gotdata relocations because in many if not all cases inside
of GMP it will optimize away the relocation and GOT slot completely
since the linker can fully resolve the PC relative address at link time.

GOTDATA relocs are used like the following, assuming the PIC register
is %l7:

	sethi   %gdop_hix22(foo), %g1
	xor     %g1, %gdop_lox10(foo), %g1
	ld      [%l7 + %g1], %g1, %gdop(foo)

and if the linker can determine that 'foo' can resolve only to the
symbol 'foo' in the final link of the shared library it will rewrite
that code sequence into:

	sethi   %gdop_hix22(foo), %g1
	xor     %g1, %gdop_lox10(foo), %g1
	add	%l7, %g1, %g1

And when this optimization takes place the address computed in %g1 is
actually something like "_GLOBAL_OFFSET_TABLE - foo", hence the 'xor'
to get proper 64-bit sign extension when this %g1 value needs to be
negative.


More information about the gmp-devel mailing list