From 3551901cd149359bb3bff4b3bb8a30f87120e9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 7 Jan 2016 13:06:51 +0100 Subject: [PATCH 1/4] Make ar invocation more portable armar doesn't understand the syntax without dash. OTOH, the syntax with dash is the only one specified by POSIX, and it's accepted by GNU ar, BSD ar (as bundled with OS X) and armar, so it looks like the most portable syntax. fixes #386 --- ChangeLog | 3 ++- library/Makefile | 12 ++++++------ tests/scripts/all.sh | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6cf066f3..ef62ddb0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,7 +5,8 @@ mbed TLS ChangeLog (Sorted per branch, date) Bugfix * Fix bug in mbedtls_mpi_add_mpi() that caused wrong results when the three arguments where the same (in-place doubling). Found and fixed by Janos - Follath. + Follath. #309 + * Fix issue in Makefile that prevented building using armar. #386 = mbed TLS 2.2.1 released 2016-01-05 diff --git a/library/Makefile b/library/Makefile index 7d253434c..00528b3c8 100644 --- a/library/Makefile +++ b/library/Makefile @@ -90,9 +90,9 @@ shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) # tls libmbedtls.a: $(OBJS_TLS) echo " AR $@" - $(AR) rc $@ $(OBJS_TLS) + $(AR) -rc $@ $(OBJS_TLS) echo " RL $@" - $(AR) s $@ + $(AR) -s $@ libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" @@ -113,9 +113,9 @@ libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll # x509 libmbedx509.a: $(OBJS_X509) echo " AR $@" - $(AR) rc $@ $(OBJS_X509) + $(AR) -rc $@ $(OBJS_X509) echo " RL $@" - $(AR) s $@ + $(AR) -s $@ libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so echo " LD $@" @@ -136,9 +136,9 @@ libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll # crypto libmbedcrypto.a: $(OBJS_CRYPTO) echo " AR $@" - $(AR) rc $@ $(OBJS_CRYPTO) + $(AR) -rc $@ $(OBJS_CRYPTO) echo " RL $@" - $(AR) s $@ + $(AR) -s $@ libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) echo " LD $@" diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index d96615b48..4829c8fa0 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -233,7 +233,7 @@ scripts/config.pl unset MBEDTLS_THREADING_PTHREAD scripts/config.pl unset MBEDTLS_THREADING_C scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit -CC=armcc WARNING_CFLAGS= make lib 2> armcc.stderr +CC=armcc AR=armar WARNING_CFLAGS= make lib 2> armcc.stderr if [ -s armcc.stderr ]; then cat armcc.stderr exit 1; From 25caaf36a618f687d45c1f724049717a15521082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 8 Jan 2016 14:29:11 +0100 Subject: [PATCH 2/4] Avoid build errors with -O0 due to assembly --- ChangeLog | 5 +++++ include/mbedtls/bn_mul.h | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ef62ddb0a..f68333e7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,11 @@ Bugfix Follath. #309 * Fix issue in Makefile that prevented building using armar. #386 +Changes + * On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5, + don't use the optimized assembly for bignum multiplication. This removes + the need to pass -fomit-frame-pointer to avoid a build error with -O0. + = mbed TLS 2.2.1 released 2016-01-05 Security diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h index 5408d4146..c59cbc77a 100644 --- a/include/mbedtls/bn_mul.h +++ b/include/mbedtls/bn_mul.h @@ -563,7 +563,23 @@ #endif /* TriCore */ -#if defined(__arm__) +/* + * gcc -O0 by default uses r7 for the frame pointer, so it complains about our + * use of r7 below, unless -fomit-frame-pointer is passed. Unfortunately, + * passing that option is not easy when building with yotta. + * + * On the other hand, -fomit-frame-pointer is implied by any -Ox options with + * x !=0, which we can detect using __OPTIMIZE__ (which is also defined by + * clang and armcc5 under the same conditions). + * + * So, only use the optimized assembly below for optimized build, which avoids + * the build error and is pretty reasonable anyway. + */ +#if defined(__GNUC__) && !defined(__OPTIMIZE__) +#define CANNOT_USE_R7 +#endif + +#if defined(__arm__) && !defined(CANNOT_USE_R7) #if defined(__thumb__) && !defined(__thumb2__) From 365f325e03e9ab38ae70ae53548f43a1316d7303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 8 Jan 2016 14:58:45 +0100 Subject: [PATCH 3/4] Make check-names.sh happy --- include/mbedtls/bn_mul.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h index c59cbc77a..1fc7aa68d 100644 --- a/include/mbedtls/bn_mul.h +++ b/include/mbedtls/bn_mul.h @@ -576,10 +576,10 @@ * the build error and is pretty reasonable anyway. */ #if defined(__GNUC__) && !defined(__OPTIMIZE__) -#define CANNOT_USE_R7 +#define MULADDC_CANNOT_USE_R7 #endif -#if defined(__arm__) && !defined(CANNOT_USE_R7) +#if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7) #if defined(__thumb__) && !defined(__thumb2__) From d2655ac2dc450dd5169db09f52396180879fba1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 8 Jan 2016 15:02:05 +0100 Subject: [PATCH 4/4] Add test for yotta debug build --- tests/scripts/yotta-build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/scripts/yotta-build.sh b/tests/scripts/yotta-build.sh index 0651baee6..19cc57664 100755 --- a/tests/scripts/yotta-build.sh +++ b/tests/scripts/yotta-build.sh @@ -11,8 +11,12 @@ yt update || true # needs network yotta_build() { TARGET=$1 - echo; echo "*** $TARGET ***" + + echo; echo "*** $TARGET (release) ***" yt -t $TARGET build + + echo; echo "*** $TARGET (debug) ***" + yt -t $TARGET build -d } if uname -a | grep 'Linux.*x86' >/dev/null; then