I’m trying to build mbed TLS 2.16.2 for an ARM926EJ-S Linux target
(Atmel AT91SAM9G20). The build fails because the bignum code tries to
use the ‘umaal’ instruction:
$ /home/nextgen/toolchain/bin/arm-linux-gcc --version
arm-linux-gcc (crosstool-NG 1.16.0) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ make clean
$ make CC=/home/nextgen/toolchain/bin/arm-linux-gcc
CC aes.c
CC aesni.c
CC arc4.c
CC aria.c
CC asn1parse.c
CC asn1write.c
CC base64.c
CC bignum.c
/tmp/ccbTqlwk.s: Assembler messages:
/tmp/ccbTqlwk.s:111: Error: selected processor does not support 'umaal r1,r5,r3,r0'
/tmp/ccbTqlwk.s:115: Error: selected processor does not support 'umaal r1,r5,r3,r0'
/tmp/ccbTqlwk.s:119: Error: selected processor does not support 'umaal r1,r5,r3,r0'
[... 20 more ...]
/tmp/ccbTqlwk.s:209: Error: selected processor does not support 'umaal r1,r5,r3,r0'
/tmp/ccbTqlwk.s:213: Error: selected processor does not support 'umaal r1,r5,r3,r0'
/tmp/ccbTqlwk.s:226: Error: selected processor does not support 'umaal r1,r5,r3,r0'
make[1]: *** [Makefile:196: bignum.o] Error 1
make: *** [Makefile:18: lib] Error 2
The code in question from bn_mul.h appears to be enabled by the
__ARM_FEATURES_DSP macro:
#elif defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)
#define MULADDC_INIT \
asm(
#define MULADDC_CORE \
"ldr r0, [%0], #4 \n\t" \
"ldr r1, [%1] \n\t" \
"umaal r1, %2, %3, r0 \n\t" \
"str r1, [%1], #4 \n\t"
#define MULADDC_STOP \
: "=r" (s), "=r" (d), "=r" (c) \
: "r" (b), "0" (s), "1" (d), "2" (c) \
: "r0", "r1", "memory" \
);
#else
That macro is defined by my toolchain:
$ /home/nextgen/toolchain/bin/arm-linux-gcc -dM -E - </dev/null | grep ARM
#define __ARMEL__ 1
#define __ARM_ARCH_5TE__ 1
#define __ARM_PCS 1
#define __ARM_EABI__ 1
#define __ARM_FEATURE_DSP 1
I’ve reviewed the ARM9E-S Core Technical Reference Manual, and though
it lists several multiply/accumulate instructions (UMLAL, SMLALx,
SMLAL) there is indeed no UMAAL.
Is this a bug in bn_mult.h?
Shold the code also be checking for !defined(ARM_ARCH_5TE) or
something?