From 7a6da6ed5e3a3e139e8eec2bd7e1d60dee4cd55e 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 1e6fd8cd0..034ca7dee 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -750,15 +750,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 8e6a22ac3d8cb1820a0d6a258a2cdaf47ab9c8c5 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 034ca7dee..c12b33355 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -750,13 +750,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 e459f07b551aef3039c6efc65670a44329884949 Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Mon, 23 Jul 2018 09:44:42 +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( \