GMP-5.0.0 problems with gcd_1.asm on Apple with fixes

Philip McLaughlin pbmcl at dakotacom.net
Tue Jan 12 06:54:16 CET 2010


Apple Mac Pro (8-core Xeon) has easily fixed problems with the file

	mpn/x86-64/gcd_1.asm

1) As released, "make" fails with the following error during the construction of the library:

gcc -std=gnu99 -dynamiclib ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/libgmp.3.6.0.dylib  .libs/assert.o .libs/compat.o .libs/errno.o .libs/extract-dbl.o .libs/invalid.o .libs/memory.o .libs/mp_bpl.o ...
 ... scanf/.libs/vscanf.o scanf/.libs/vsscanf.o   -m64 -mtune=core2 -march=core2 -install_name  /usr/local/lib/libgmp.3.dylib -compatibility_version 10 -current_version 10.0

ld: in mpn/.libs/gcd_1.o, in section __TEXT,__text reloc 0: not extern and X86_64_RELOC_GOT_LOAD not supported
collect2: ld returned 1 exit status
make[2]: *** [libgmp.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

>> Fix #1: this error vanishes if the trailing zero table label "L(table)" is changed to "tz_table" (2 places).


2) After fix #1, "make check" fails in "t-fat" with a segmentation fault at the call to test "mpn_gcd_1".

>> Fix #2: the fix for this error was suggested in the file "redc_1.asm", where the stack pointer
                  needs to be aligned for a secondary call. Adding the instruction

		sub	$8, %rsp                   C maintain ABI required rsp alignment
 
just before the instruction

		CALL(	mpn_modexact_1_odd)

which is then followed by

		add	$8, %rsp

fixes the fault and "make check" runs without errors.

3) (Bonus code improvement!) Near the start of the routine, the instructions

		mov	%r8, %r10
		...
and

		shr	R8(%rcx), %r10
 
can be removed. r10 is not used before it is overwritten elsewhere.


The revised "gcd_1.asm" file is attached.

Regards,
Phil McLaughlin


-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcd_1.asm
Type: application/octet-stream
Size: 2786 bytes
Desc: not available
URL: <http://gmplib.org/list-archives/gmp-bugs/attachments/20100111/944a5dfa/attachment.obj>
-------------- next part --------------




More information about the gmp-bugs mailing list