Subject: toolchain/24153: sparc64 -> i386 cross compile fails assembling negative bignums
To: None <>
From: None <>
List: netbsd-bugs
Date: 01/19/2004 10:40:54
>Number:         24153
>Category:       toolchain
>Synopsis:       sparc64 -> i386 cross compile fails assembling negative bignums
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 19 18:42:00 UTC 2004
>Release:        NetBSD-current (ca. 17 Jan 2004)
System: NetBSD ultra2.ouranos 1.6.1 NetBSD 1.6.1 (GENERIC) #0: Mon Apr 7 10:27:16 UTC 2003 sparc64
Architecture: sparc64
Machine: sparc64
Cross-building a i386 kernel fails on a sparc64 in sys/crypto/sha2/sha2.c. The exact complait is about an invalid bignum. When I compiled with the -S flag, to see the assembly, the problem was a negative .quad bignum.
Do a "./ -m i386" a kernel on an ultrasparc. 
This sounds like a gas bug. I found
when doing a Google search.

As a workaround, I compiled sha2.c using the powerpc gcc:
/home/source/src/../tool/bin/powerpc--netbsd-gcc -S -msoft-float -ffreestanding -O2 -Wreturn-type -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wno-sign-compare -Dmacppc=macppc -I. -I/home/source/src/sys/arch -I/home/source/src/sys -nostdinc -DLKM -DDIAGNOSTIC -DZS_CONSOLE_ABORT -DMAXUSERS=32 -D_KERNEL -D_KERNEL_OPT -c /home/source/src/sys/crypto/sha2/sha2.c

Note that it generates the same constants, but uses .long rather than .quad.  I replaced the .quad sections in the i386 sha2.s with the .long sections generated by the powerpc compiler. (Note that this may result in different constants due to endian issues--I am not sure how this stuff works out) I then assembled sha2.o and resumed compilation with -u.