all.sh: Update paths to builtin driver modules and objects

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index 6b439aa..9273b8a 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -444,6 +444,7 @@
 
     msg "size: ARM Compiler 6 ($FLAGS)"
     "$ARMC6_FROMELF" -z library/*.o
+    "$ARMC6_FROMELF" -z ${BUILTIN_SRC_PATH}/*.o
 }
 
 err_msg()
@@ -1094,6 +1095,8 @@
 #### Basic checks
 ################################################################
 
+export BUILTIN_SRC_PATH="tf-psa-crypto/drivers/builtin/src"
+
 #
 # Test Suites to be executed
 #
@@ -1108,6 +1111,7 @@
 component_check_recursion () {
     msg "Check: recursion.pl" # < 1s
     tests/scripts/recursion.pl library/*.c
+    tests/scripts/recursion.pl ${BUILTIN_SRC_PATH}/*.c
 }
 
 component_check_generated_files () {
@@ -1670,8 +1674,8 @@
     make CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
 
     # Ensure that PK_[PARSE|WRITE]_C were not re-enabled accidentally (additive config).
-    not grep mbedtls_pk_parse_key library/pkparse.o
-    not grep mbedtls_pk_write_key_der library/pkwrite.o
+    not grep mbedtls_pk_parse_key ${BUILTIN_SRC_PATH}/pkparse.o
+    not grep mbedtls_pk_write_key_der ${BUILTIN_SRC_PATH}/pkwrite.o
 
     msg "test: full without pkparse and pkwrite"
     make test
@@ -1698,8 +1702,8 @@
     make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS"
 
     # Make sure we don't have the HMAC functions, but the hashing functions
-    not grep mbedtls_md_hmac library/md.o
-    grep mbedtls_md library/md.o
+    not grep mbedtls_md_hmac ${BUILTIN_SRC_PATH}/md.o
+    grep mbedtls_md ${BUILTIN_SRC_PATH}/md.o
 
     msg "test: crypto_full with only the light subset of MD"
     make test
@@ -1734,7 +1738,7 @@
     make
 
     # Ensure that CIPHER_C was not re-enabled
-    not grep mbedtls_cipher_init library/cipher.o
+    not grep mbedtls_cipher_init ${BUILTIN_SRC_PATH}/cipher.o
 
     msg "test: full no CIPHER"
     make test
@@ -2524,7 +2528,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_ecdsa_ library/ecdsa.o
+    not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
 
     # Run the tests
     # -------------
@@ -2565,7 +2569,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_ecdh_ library/ecdh.o
+    not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
 
     # Run the tests
     # -------------
@@ -2603,7 +2607,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_dhm_ library/dhm.o
+    not grep mbedtls_dhm_ ${BUILTIN_SRC_PATH}/dhm.o
 
     # Run the tests
     # -------------
@@ -2657,7 +2661,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_ecjpake_init library/ecjpake.o
+    not grep mbedtls_ecjpake_init ${BUILTIN_SRC_PATH}/ecjpake.o
 
     # Run the tests
     # -------------
@@ -2714,10 +2718,10 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # ECP should be re-enabled but not the others
-    not grep mbedtls_ecdh_ library/ecdh.o
-    not grep mbedtls_ecdsa library/ecdsa.o
-    not grep mbedtls_ecjpake  library/ecjpake.o
-    grep mbedtls_ecp library/ecp.o
+    not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
+    not grep mbedtls_ecdsa ${BUILTIN_SRC_PATH}/ecdsa.o
+    not grep mbedtls_ecjpake  ${BUILTIN_SRC_PATH}/ecjpake.o
+    grep mbedtls_ecp ${BUILTIN_SRC_PATH}/ecp.o
 
     # Run the tests
     # -------------
@@ -2808,27 +2812,27 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # We expect ECDH to be re-enabled for the missing curves
-    grep mbedtls_ecdh_ library/ecdh.o
+    grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
     # We expect ECP to be re-enabled, however the parts specific to the
     # families of curves that are accelerated should be ommited.
     # - functions with mxz in the name are specific to Montgomery curves
     # - ecp_muladd is specific to Weierstrass curves
-    ##nm library/ecp.o | tee ecp.syms
+    ##nm ${BUILTIN_SRC_PATH}/ecp.o | tee ecp.syms
     if [ $weierstrass -eq 1 ]; then
-        not grep mbedtls_ecp_muladd library/ecp.o
-        grep mxz library/ecp.o
+        not grep mbedtls_ecp_muladd ${BUILTIN_SRC_PATH}/ecp.o
+        grep mxz ${BUILTIN_SRC_PATH}/ecp.o
     else
-        grep mbedtls_ecp_muladd library/ecp.o
-        not grep mxz library/ecp.o
+        grep mbedtls_ecp_muladd ${BUILTIN_SRC_PATH}/ecp.o
+        not grep mxz ${BUILTIN_SRC_PATH}/ecp.o
     fi
     # We expect ECDSA and ECJPAKE to be re-enabled only when
     # Weierstrass curves are not accelerated
     if [ $weierstrass -eq 1 ]; then
-        not grep mbedtls_ecdsa library/ecdsa.o
-        not grep mbedtls_ecjpake  library/ecjpake.o
+        not grep mbedtls_ecdsa ${BUILTIN_SRC_PATH}/ecdsa.o
+        not grep mbedtls_ecjpake  ${BUILTIN_SRC_PATH}/ecjpake.o
     else
-        grep mbedtls_ecdsa library/ecdsa.o
-        grep mbedtls_ecjpake  library/ecjpake.o
+        grep mbedtls_ecdsa ${BUILTIN_SRC_PATH}/ecdsa.o
+        grep mbedtls_ecjpake  ${BUILTIN_SRC_PATH}/ecjpake.o
     fi
 
     # Run the tests
@@ -2907,10 +2911,10 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure any built-in EC alg was not re-enabled by accident (additive config)
-    not grep mbedtls_ecdsa_ library/ecdsa.o
-    not grep mbedtls_ecdh_ library/ecdh.o
-    not grep mbedtls_ecjpake_ library/ecjpake.o
-    not grep mbedtls_ecp_mul library/ecp.o
+    not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
+    not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
+    not grep mbedtls_ecjpake_ ${BUILTIN_SRC_PATH}/ecjpake.o
+    not grep mbedtls_ecp_mul ${BUILTIN_SRC_PATH}/ecp.o
 
     # Run the tests
     # -------------
@@ -3011,11 +3015,11 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure any built-in EC alg was not re-enabled by accident (additive config)
-    not grep mbedtls_ecdsa_ library/ecdsa.o
-    not grep mbedtls_ecdh_ library/ecdh.o
-    not grep mbedtls_ecjpake_ library/ecjpake.o
+    not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
+    not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
+    not grep mbedtls_ecjpake_ ${BUILTIN_SRC_PATH}/ecjpake.o
     # Also ensure that ECP module was not re-enabled
-    not grep mbedtls_ecp_ library/ecp.o
+    not grep mbedtls_ecp_ ${BUILTIN_SRC_PATH}/ecp.o
 
     # Run the tests
     # -------------
@@ -3186,14 +3190,14 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure any built-in EC alg was not re-enabled by accident (additive config)
-    not grep mbedtls_ecdsa_ library/ecdsa.o
-    not grep mbedtls_ecdh_ library/ecdh.o
-    not grep mbedtls_ecjpake_ library/ecjpake.o
+    not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
+    not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
+    not grep mbedtls_ecjpake_ ${BUILTIN_SRC_PATH}/ecjpake.o
     # Also ensure that ECP, RSA, [DHM] or BIGNUM modules were not re-enabled
-    not grep mbedtls_ecp_ library/ecp.o
-    not grep mbedtls_rsa_ library/rsa.o
-    not grep mbedtls_mpi_ library/bignum.o
-    not grep mbedtls_dhm_ library/dhm.o
+    not grep mbedtls_ecp_ ${BUILTIN_SRC_PATH}/ecp.o
+    not grep mbedtls_rsa_ ${BUILTIN_SRC_PATH}/rsa.o
+    not grep mbedtls_mpi_ ${BUILTIN_SRC_PATH}/bignum.o
+    not grep mbedtls_dhm_ ${BUILTIN_SRC_PATH}/dhm.o
 
     # Run the tests
     # -------------
@@ -3289,20 +3293,20 @@
     make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -I../tests/include/spe" LDFLAGS="$ASAN_CFLAGS"
 
     # Make sure any built-in EC alg was not re-enabled by accident (additive config)
-    not grep mbedtls_ecdsa_ library/ecdsa.o
-    not grep mbedtls_ecdh_ library/ecdh.o
-    not grep mbedtls_ecjpake_ library/ecjpake.o
+    not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
+    not grep mbedtls_ecdh_ ${BUILTIN_SRC_PATH}/ecdh.o
+    not grep mbedtls_ecjpake_ ${BUILTIN_SRC_PATH}/ecjpake.o
     # Also ensure that ECP, RSA, DHM or BIGNUM modules were not re-enabled
-    not grep mbedtls_ecp_ library/ecp.o
-    not grep mbedtls_rsa_ library/rsa.o
-    not grep mbedtls_dhm_ library/dhm.o
-    not grep mbedtls_mpi_ library/bignum.o
+    not grep mbedtls_ecp_ ${BUILTIN_SRC_PATH}/ecp.o
+    not grep mbedtls_rsa_ ${BUILTIN_SRC_PATH}/rsa.o
+    not grep mbedtls_dhm_ ${BUILTIN_SRC_PATH}/dhm.o
+    not grep mbedtls_mpi_ ${BUILTIN_SRC_PATH}/bignum.o
     # Check that p256m was built
     grep -q p256_ecdsa_ library/libmbedcrypto.a
 
     # In "config-tfm.h" we disabled CIPHER_C tweaking TF-M's configuration
     # files, so we want to ensure that it has not be re-enabled accidentally.
-    not grep mbedtls_cipher library/cipher.o
+    not grep mbedtls_cipher ${BUILTIN_SRC_PATH}/cipher.o
 
     # Run the tests
     msg "test: TF-M config + p256m driver + accel ECDH(E)/ECDSA"
@@ -3327,7 +3331,7 @@
 
     # In "config-tfm.h" we disabled CIPHER_C tweaking TF-M's configuration
     # files, so we want to ensure that it has not be re-enabled accidentally.
-    not grep mbedtls_cipher library/cipher.o
+    not grep mbedtls_cipher ${BUILTIN_SRC_PATH}/cipher.o
 
     msg "test: TF-M config"
     make test
@@ -3449,7 +3453,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_rsa library/rsa.o
+    not grep mbedtls_rsa ${BUILTIN_SRC_PATH}/rsa.o
 
     # Run the tests
     # -------------
@@ -3559,11 +3563,11 @@
 
     # There's a risk of something getting re-enabled via config_psa.h;
     # make sure it did not happen. Note: it's OK for MD_C to be enabled.
-    not grep mbedtls_md5 library/md5.o
-    not grep mbedtls_sha1 library/sha1.o
-    not grep mbedtls_sha256 library/sha256.o
-    not grep mbedtls_sha512 library/sha512.o
-    not grep mbedtls_ripemd160 library/ripemd160.o
+    not grep mbedtls_md5 ${BUILTIN_SRC_PATH}/md5.o
+    not grep mbedtls_sha1 ${BUILTIN_SRC_PATH}/sha1.o
+    not grep mbedtls_sha256 ${BUILTIN_SRC_PATH}/sha256.o
+    not grep mbedtls_sha512 ${BUILTIN_SRC_PATH}/sha512.o
+    not grep mbedtls_ripemd160 ${BUILTIN_SRC_PATH}/ripemd160.o
 
     # Run the tests
     # -------------
@@ -3616,11 +3620,11 @@
 
     # There's a risk of something getting re-enabled via config_psa.h;
     # make sure it did not happen. Note: it's OK for MD_C to be enabled.
-    not grep mbedtls_md5 library/md5.o
-    not grep mbedtls_sha1 library/sha1.o
-    not grep mbedtls_sha256 library/sha256.o
-    not grep mbedtls_sha512 library/sha512.o
-    not grep mbedtls_ripemd160 library/ripemd160.o
+    not grep mbedtls_md5 ${BUILTIN_SRC_PATH}/md5.o
+    not grep mbedtls_sha1 ${BUILTIN_SRC_PATH}/sha1.o
+    not grep mbedtls_sha256 ${BUILTIN_SRC_PATH}/sha256.o
+    not grep mbedtls_sha512 ${BUILTIN_SRC_PATH}/sha512.o
+    not grep mbedtls_ripemd160 ${BUILTIN_SRC_PATH}/ripemd160.o
 
     # Run the tests
     # -------------
@@ -3707,7 +3711,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Ensure that built-in support for HMAC is disabled.
-    not grep mbedtls_md_hmac library/md.o
+    not grep mbedtls_md_hmac ${BUILTIN_SRC_PATH}/md.o
 
     # Run the tests
     # -------------
@@ -3765,7 +3769,7 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_des* library/des.o
+    not grep mbedtls_des* ${BUILTIN_SRC_PATH}/des.o
 
     # Run the tests
     # -------------
@@ -3802,9 +3806,9 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_ccm library/ccm.o
-    not grep mbedtls_gcm library/gcm.o
-    not grep mbedtls_chachapoly library/chachapoly.o
+    not grep mbedtls_ccm ${BUILTIN_SRC_PATH}/ccm.o
+    not grep mbedtls_gcm ${BUILTIN_SRC_PATH}/gcm.o
+    not grep mbedtls_chachapoly ${BUILTIN_SRC_PATH}/chachapoly.o
 
     # Run the tests
     # -------------
@@ -3870,15 +3874,15 @@
     helper_libtestdriver1_make_main "$loc_accel_list"
 
     # Make sure this was not re-enabled by accident (additive config)
-    not grep mbedtls_cipher library/cipher.o
-    not grep mbedtls_des library/des.o
-    not grep mbedtls_aes library/aes.o
-    not grep mbedtls_aria library/aria.o
-    not grep mbedtls_camellia library/camellia.o
-    not grep mbedtls_ccm library/ccm.o
-    not grep mbedtls_gcm library/gcm.o
-    not grep mbedtls_chachapoly library/chachapoly.o
-    not grep mbedtls_cmac library/cmac.o
+    not grep mbedtls_cipher ${BUILTIN_SRC_PATH}/cipher.o
+    not grep mbedtls_des ${BUILTIN_SRC_PATH}/des.o
+    not grep mbedtls_aes ${BUILTIN_SRC_PATH}/aes.o
+    not grep mbedtls_aria ${BUILTIN_SRC_PATH}/aria.o
+    not grep mbedtls_camellia ${BUILTIN_SRC_PATH}/camellia.o
+    not grep mbedtls_ccm ${BUILTIN_SRC_PATH}/ccm.o
+    not grep mbedtls_gcm ${BUILTIN_SRC_PATH}/gcm.o
+    not grep mbedtls_chachapoly ${BUILTIN_SRC_PATH}/chachapoly.o
+    not grep mbedtls_cmac ${BUILTIN_SRC_PATH}/cmac.o
 
     # Run the tests
     # -------------
@@ -3967,9 +3971,9 @@
 
     # Make sure disabled components were not re-enabled by accident (additive
     # config)
-    not grep mbedtls_aes_ library/aes.o
-    not grep mbedtls_aria_ library/aria.o
-    not grep mbedtls_camellia_ library/camellia.o
+    not grep mbedtls_aes_ ${BUILTIN_SRC_PATH}/aes.o
+    not grep mbedtls_aria_ ${BUILTIN_SRC_PATH}/aria.o
+    not grep mbedtls_camellia_ ${BUILTIN_SRC_PATH}/camellia.o
 
     # Run the tests
     # -------------
@@ -4074,9 +4078,8 @@
         ./scripts/config.py unset ${opt}
     done
 
-    # enter the directory containing the target file & strip the dir from the filename
-    cd $(dirname ${file})
-    file=$(basename ${file})
+    # enter the library directory
+    cd library
 
     # The most common issue is unused variables/functions, so ensure -Wunused is set.
     warning_flags="-Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused"
@@ -4091,7 +4094,7 @@
     deps=""
 
     len=${#options[@]}
-    source_file=${file%.o}.c
+    source_file=../${file%.o}.c
 
     targets=0
     echo 'include Makefile' >${makefile}
@@ -4148,7 +4151,7 @@
     MBEDTLS_ROOT_DIR="$PWD"
     msg "build: aes.o for all combinations of relevant config options"
 
-    build_test_config_combos library/aes.o validate_aes_config_variations \
+    build_test_config_combos ${BUILTIN_SRC_PATH}/aes.o validate_aes_config_variations \
         "MBEDTLS_AES_SETKEY_ENC_ALT" "MBEDTLS_AES_DECRYPT_ALT" \
         "MBEDTLS_AES_ROM_TABLES" "MBEDTLS_AES_ENCRYPT_ALT" "MBEDTLS_AES_SETKEY_DEC_ALT" \
         "MBEDTLS_AES_FEWER_TABLES" "MBEDTLS_AES_USE_HARDWARE_ONLY" \
@@ -4165,7 +4168,7 @@
     scripts/config.py unset MBEDTLS_CIPHER_MODE_XTS
     scripts/config.py unset MBEDTLS_DES_C
     scripts/config.py unset MBEDTLS_NIST_KW_C
-    build_test_config_combos library/aes.o validate_aes_config_variations \
+    build_test_config_combos ${BUILTIN_SRC_PATH}/aes.o validate_aes_config_variations \
         "MBEDTLS_AES_SETKEY_ENC_ALT" "MBEDTLS_AES_DECRYPT_ALT" \
         "MBEDTLS_AES_ROM_TABLES" "MBEDTLS_AES_ENCRYPT_ALT" "MBEDTLS_AES_SETKEY_DEC_ALT" \
         "MBEDTLS_AES_FEWER_TABLES" "MBEDTLS_AES_USE_HARDWARE_ONLY" \
@@ -4597,49 +4600,49 @@
     scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
 
     msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64"
-    make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto"
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto"
 
     msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
 
     msg "MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
 
     scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
 
     msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, aarch64"
-    make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto"
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a+crypto"
 
     msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, arm"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
 
     msg "no MBEDTLS_AES_USE_HARDWARE_ONLY, clang, thumb"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
 
     # test for presence of AES instructions
     scripts/config.py set MBEDTLS_AES_USE_HARDWARE_ONLY
     msg "clang, test A32 crypto instructions built"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
-    grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
+    grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
     msg "clang, test T32 crypto instructions built"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
-    grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
+    grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
     msg "clang, test aarch64 crypto instructions built"
-    make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
-    grep -E 'aes[a-z]+\s*[qv]' library/aesce.o
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
+    grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
 
     # test for absence of AES instructions
     scripts/config.py unset MBEDTLS_AES_USE_HARDWARE_ONLY
     scripts/config.py unset MBEDTLS_AESCE_C
     msg "clang, test A32 crypto instructions not built"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
-    not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
+    not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
     msg "clang, test T32 crypto instructions not built"
-    make -B library/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
-    not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' library/aesce.o
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
+    not grep -E 'aes[0-9a-z]+.[0-9]\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
     msg "clang, test aarch64 crypto instructions not built"
-    make -B library/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
-    not grep -E 'aes[a-z]+\s*[qv]' library/aesce.o
+    make -B library/../${BUILTIN_SRC_PATH}/aesce.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
+    not grep -E 'aes[a-z]+\s*[qv]' ${BUILTIN_SRC_PATH}/aesce.o
 }
 
 support_build_sha_armce() {
@@ -4654,30 +4657,30 @@
     # Test variations of SHA256 Armv8 crypto extensions
     scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
         msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, aarch64"
-        make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a"
+        make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a"
         msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY clang, arm"
-        make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
+        make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm"
     scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY
 
 
     # test the deprecated form of the config option
     scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY
         msg "MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY clang, thumb"
-        make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
+        make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
     scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY
 
     scripts/config.py set MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
         msg "MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT clang, aarch64"
-        make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a"
+        make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a"
     scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
 
 
     # test the deprecated form of the config option
     scripts/config.py set MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
         msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, arm"
-        make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -std=c99"
+        make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -std=c99"
         msg "MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT clang, thumb"
-        make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
+        make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb"
     scripts/config.py unset MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT
 
 
@@ -4685,32 +4688,32 @@
     for opt in MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT; do
         scripts/config.py set ${opt}
             msg "${opt} clang, test A32 crypto instructions built"
-            make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
-            grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o
+            make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
+            grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
 
             msg "${opt} clang, test T32 crypto instructions built"
-            make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
-            grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o
+            make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
+            grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
 
             msg "${opt} clang, test aarch64 crypto instructions built"
-            make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
-            grep -E 'sha256[a-z0-9]+\s+[qv]' library/sha256.o
+            make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
+            grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
         scripts/config.py unset ${opt}
     done
 
 
     # examine the disassembly for absence of SHA instructions
     msg "clang, test A32 crypto instructions not built"
-    make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
-    not grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o
+    make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a72+crypto -marm -S"
+    not grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
 
     msg "clang, test T32 crypto instructions not built"
-    make -B library/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
-    not grep -E 'sha256[a-z0-9]+.32\s+[qv]' library/sha256.o
+    make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=arm-linux-gnueabihf -mcpu=cortex-a32+crypto -mthumb -S"
+    not grep -E 'sha256[a-z0-9]+.32\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
 
     msg "clang, test aarch64 crypto instructions not built"
-    make -B library/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
-    not grep -E 'sha256[a-z0-9]+\s+[qv]' library/sha256.o
+    make -B library/../${BUILTIN_SRC_PATH}/sha256.o CC=clang CFLAGS="--target=aarch64-linux-gnu -march=armv8-a -S"
+    not grep -E 'sha256[a-z0-9]+\s+[qv]' ${BUILTIN_SRC_PATH}/sha256.o
 }
 
 support_build_aes_aesce_armcc () {
@@ -4832,13 +4835,13 @@
     make CFLAGS="-O2 $cflags" LDFLAGS="$ldflags"
 
     # Make sure we don't have mbedtls_xxx_setkey_dec in AES/ARIA/CAMELLIA
-    not grep mbedtls_aes_setkey_dec library/aes.o
-    not grep mbedtls_aria_setkey_dec library/aria.o
-    not grep mbedtls_camellia_setkey_dec library/camellia.o
+    not grep mbedtls_aes_setkey_dec ${BUILTIN_SRC_PATH}/aes.o
+    not grep mbedtls_aria_setkey_dec ${BUILTIN_SRC_PATH}/aria.o
+    not grep mbedtls_camellia_setkey_dec ${BUILTIN_SRC_PATH}/camellia.o
     # Make sure we don't have mbedtls_internal_aes_decrypt in AES
-    not grep mbedtls_internal_aes_decrypt library/aes.o
+    not grep mbedtls_internal_aes_decrypt ${BUILTIN_SRC_PATH}/aes.o
     # Make sure we don't have mbedtls_aesni_inverse_key in AESNI
-    not grep mbedtls_aesni_inverse_key library/aesni.o
+    not grep mbedtls_aesni_inverse_key ${BUILTIN_SRC_PATH}/aesni.o
 
     msg "test: default config + BLOCK_CIPHER_NO_DECRYPT${set_opts:+ + $set_opts}${unset_opts:+ - $unset_opts} with $cflags${ldflags:+, $ldflags}"
     make test
@@ -4939,14 +4942,14 @@
     armc6_build_test "-O1 --target=aarch64-arm-none-eabi -march=armv8-a+crypto -Werror -Wall -Wextra"
 
     # Make sure we don't have mbedtls_xxx_setkey_dec in AES/ARIA/CAMELLIA
-    not grep mbedtls_aes_setkey_dec library/aes.o
-    not grep mbedtls_aria_setkey_dec library/aria.o
-    not grep mbedtls_camellia_setkey_dec library/camellia.o
+    not grep mbedtls_aes_setkey_dec ${BUILTIN_SRC_PATH}/aes.o
+    not grep mbedtls_aria_setkey_dec ${BUILTIN_SRC_PATH}/aria.o
+    not grep mbedtls_camellia_setkey_dec ${BUILTIN_SRC_PATH}/camellia.o
     # Make sure we don't have mbedtls_internal_aes_decrypt in AES
-    not grep mbedtls_internal_aes_decrypt library/aes.o
+    not grep mbedtls_internal_aes_decrypt ${BUILTIN_SRC_PATH}/aes.o
     # Make sure we don't have mbedtls_aesce_inverse_key and aesce_decrypt_block in AESCE
-    not grep mbedtls_aesce_inverse_key library/aesce.o
-    not grep aesce_decrypt_block library/aesce.o
+    not grep mbedtls_aesce_inverse_key ${BUILTIN_SRC_PATH}/aesce.o
+    not grep aesce_decrypt_block ${BUILTIN_SRC_PATH}/aesce.o
 }
 
 component_test_ctr_drbg_aes_256_sha_256 () {
@@ -5319,6 +5322,7 @@
 
     msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -O1, baremetal+debug"
     ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
+    ${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
 }
 
 component_build_arm_linux_gnueabi_gcc_arm5vte () {
@@ -5333,6 +5337,7 @@
 
     msg "size: ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
     ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t library/*.o
+    ${ARM_LINUX_GNUEABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
 }
 support_build_arm_linux_gnueabi_gcc_arm5vte () {
     type ${ARM_LINUX_GNUEABI_GCC_PREFIX}gcc >/dev/null 2>&1
@@ -5348,6 +5353,7 @@
 
     msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -march=armv5te -O1, baremetal+debug"
     ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
+    ${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
 }
 
 component_build_arm_none_eabi_gcc_m0plus () {
@@ -5357,6 +5363,7 @@
 
     msg "size: ${ARM_NONE_EABI_GCC_PREFIX}gcc -mthumb -mcpu=cortex-m0plus -Os, baremetal_size"
     ${ARM_NONE_EABI_GCC_PREFIX}size -t library/*.o
+    ${ARM_NONE_EABI_GCC_PREFIX}size -t ${BUILTIN_SRC_PATH}/*.o
     for lib in library/*.a; do
         echo "$lib:"
         ${ARM_NONE_EABI_GCC_PREFIX}size -t $lib | grep TOTALS
@@ -5370,6 +5377,7 @@
     make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -Wall -Wextra' lib
     echo "Checking that software 64-bit division is not required"
     not grep __aeabi_uldiv library/*.o
+    not grep __aeabi_uldiv ${BUILTIN_SRC_PATH}/*.o
 }
 
 component_build_arm_none_eabi_gcc_no_64bit_multiplication () {
@@ -5379,6 +5387,7 @@
     make CC="${ARM_NONE_EABI_GCC_PREFIX}gcc" AR="${ARM_NONE_EABI_GCC_PREFIX}ar" LD="${ARM_NONE_EABI_GCC_PREFIX}ld" CFLAGS='-std=c99 -Werror -O1 -march=armv6-m -mthumb' lib
     echo "Checking that software 64-bit multiplication is not required"
     not grep __aeabi_lmul library/*.o
+    not grep __aeabi_lmul ${BUILTIN_SRC_PATH}/*.o
 }
 
 component_build_arm_clang_thumb () {
@@ -5423,6 +5432,7 @@
 
     msg "size: ARM Compiler 5"
     "$ARMC5_FROMELF" -z library/*.o
+    "$ARMC5_FROMELF" -z ${BUILTIN_SRC_PATH}/*.o
 
     # Compile mostly with -O1 since some Arm inline assembly is disabled for -O0.