From f218c0c5cf48c09eb665ff7bfc8144457101ca78 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 5c1ae2d961..3012d4d60b 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -597,15 +597,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 -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 698cb3469dd83d641dd37486e16afd0d3fb9c39f 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 3012d4d60b..70dde281e4 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -597,13 +597,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 e9a437fe59b4e0d3ac38d5e3faec012319011f14 Mon Sep 17 00:00:00 2001 From: Simon Butcher Date: Mon, 23 Jul 2018 09:48:56 +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 8d799ec9b4..bdd7acb399 100644 --- a/include/mbedtls/bn_mul.h +++ b/include/mbedtls/bn_mul.h @@ -55,7 +55,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( \