From 7c6b84102d6328fc3a9e96f30d5a6931b17b56e3 Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Wed, 27 Jun 2018 21:52:54 +0100 Subject: [PATCH 1/3] Expand i386 all.sh tests to full config ASan builds The i386 test builds were only building the default configuration and had no address sanitisation. This commit expands the test configuration to the full configuration in all.sh and builds with ASan for when the test suites are executed. --- tests/scripts/all.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 09c8b1666..43c8773d5 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -658,15 +658,19 @@ if uname -a | grep -F Linux >/dev/null; then fi if uname -a | grep -F x86_64 >/dev/null; then - msg "build: i386, make, gcc" # ~ 30s + msg "build: i386, make, gcc (ASan build)" # ~ 30s cleanup - make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32' + cp "$CONFIG_H" "$CONFIG_BAK" + scripts/config.pl full + make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32 -fsanitize=address' - msg "test: i386, make, gcc" + msg "test: i386, make, gcc (ASan build)" make test msg "build: 64-bit ILP32, make, gcc" # ~ 30s cleanup + cp "$CONFIG_H" "$CONFIG_BAK" + scripts/config.pl full make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' msg "test: 64-bit ILP32, make, gcc" From 948f2643022c367101092d90150eb85f0ae33308 Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Fri, 20 Jul 2018 21:27:33 +0100 Subject: [PATCH 2/3] Add additional i386 tests to all.sh Added an additional i386 test to all.sh, to allow one test with -O0 which compiles out inline assembly, and one to test with -01 which includes the inline assembly. --- tests/scripts/all.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 43c8773d5..8fcb70b80 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -658,13 +658,24 @@ if uname -a | grep -F Linux >/dev/null; then fi if uname -a | grep -F x86_64 >/dev/null; then - msg "build: i386, make, gcc (ASan build)" # ~ 30s + # Build once with -O0, to compile out the i386 specific inline assembly + msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s cleanup cp "$CONFIG_H" "$CONFIG_BAK" scripts/config.pl full - make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32 -fsanitize=address' + make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' - msg "test: i386, make, gcc (ASan build)" + msg "test: i386, make, gcc -O0 (ASan build)" + make test + + # Build again with -O1, to compile in the i386 specific inline assembly + msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s + cleanup + cp "$CONFIG_H" "$CONFIG_BAK" + scripts/config.pl full + make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' + + msg "test: i386, make, gcc -O1 (ASan build)" make test msg "build: 64-bit ILP32, make, gcc" # ~ 30s From e08754762d96665eb3dcc3ecacfaef865b4d1f3e Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Mon, 23 Jul 2018 09:46:50 +0100 Subject: [PATCH 3/3] Correct logic to exclude i386 inline assenbly when -O0 The i386 MPI inline assembly code was being incorrectly included when all compiler optimisation was disabled. --- include/mbedtls/bn_mul.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h index 438aa8cea..b587317d9 100644 --- a/include/mbedtls/bn_mul.h +++ b/include/mbedtls/bn_mul.h @@ -56,7 +56,7 @@ * This is done as the number of registers used in the assembly code doesn't * work with the -O0 option. */ -#if defined(__i386__) && !defined(__OPTIMIZE__) +#if defined(__i386__) && defined(__OPTIMIZE__) #define MULADDC_INIT \ asm( \