mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-28 18:07:34 +08:00
Merge f1d54598a3ba03ae40166eb10bab8e8d08296531 into 4fdb917aae2fb5876e04f88621630712a906a067
This commit is contained in:
commit
0724d6a3d7
7
ChangeLog.d/sha256-armv8-crypto-pragma.txt
Normal file
7
ChangeLog.d/sha256-armv8-crypto-pragma.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Bugfix
|
||||
* Fix a build failure with GCC on AArch64 when
|
||||
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT or
|
||||
MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_ONLY is enabled and the target CPU has
|
||||
extensions beyond Armv8.0-A, such as -mcpu=cortex-a53 with CRC. The
|
||||
sha256 module then failed to inline always_inline functions such as a
|
||||
fortified memset().
|
||||
7
ChangeLog.d/sha512-a64-crypto-pragma.txt
Normal file
7
ChangeLog.d/sha512-a64-crypto-pragma.txt
Normal file
@ -0,0 +1,7 @@
|
||||
Bugfix
|
||||
* Fix a build failure with GCC 13 or later on AArch64 when
|
||||
MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT or
|
||||
MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY is enabled and the target CPU has
|
||||
extensions that Armv8.2-A does not include, such as -mcpu=cortex-a76.
|
||||
The sha512 module then failed to inline always_inline functions such as
|
||||
a fortified memset().
|
||||
@ -102,7 +102,11 @@
|
||||
# error "A more recent GCC is required for MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_*"
|
||||
# else
|
||||
# pragma GCC push_options
|
||||
# pragma GCC target ("arch=armv8-a+crypto")
|
||||
# if defined(MBEDTLS_ARCH_IS_ARM64)
|
||||
# pragma GCC target ("+crypto")
|
||||
# else
|
||||
# pragma GCC target ("arch=armv8-a+crypto")
|
||||
# endif
|
||||
# define MBEDTLS_POP_TARGET_PRAGMA
|
||||
# endif
|
||||
# else
|
||||
|
||||
@ -91,7 +91,12 @@
|
||||
# error "A more recent GCC is required for MBEDTLS_SHA512_USE_A64_CRYPTO_*"
|
||||
# else
|
||||
# pragma GCC push_options
|
||||
# pragma GCC target ("arch=armv8.2-a+sha3")
|
||||
/* Before GCC 13, the SHA-512 intrinsics require Armv8.2-A. */
|
||||
# if __GNUC__ < 13
|
||||
# pragma GCC target ("arch=armv8.2-a+sha3")
|
||||
# else
|
||||
# pragma GCC target ("+sha3")
|
||||
# endif
|
||||
# define MBEDTLS_POP_TARGET_PRAGMA
|
||||
# endif
|
||||
# else
|
||||
|
||||
@ -276,6 +276,40 @@ component_test_m32_no_asm () {
|
||||
make test
|
||||
}
|
||||
|
||||
component_build_sha_armce_gcc () {
|
||||
# The SHA-256 crypto extensions must be added to the target of the build,
|
||||
# not replace it: with -mcpu=cortex-a53 (which has CRC) GCC otherwise
|
||||
# refuses to inline always_inline functions such as a fortified memset().
|
||||
scripts/config.py unset MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_IF_PRESENT
|
||||
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 ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc, -mcpu=cortex-a53 -D_FORTIFY_SOURCE=2"
|
||||
make -B library/sha256.o library/sha256.s CC="${AARCH64_LINUX_GNU_GCC_PREFIX}gcc" CFLAGS="-std=c99 -Werror -O2 -mcpu=cortex-a53 -D_FORTIFY_SOURCE=2"
|
||||
msg "$opt ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc, test aarch64 crypto instructions built"
|
||||
grep -E 'sha256[a-z0-9]+\s+[qv]' library/sha256.s
|
||||
scripts/config.py unset $opt
|
||||
done
|
||||
|
||||
# The same for the SHA-512 extensions with -mcpu=cortex-a76, which has
|
||||
# extensions beyond Armv8.2-A. Before GCC 13, the SHA-512 intrinsics
|
||||
# require Armv8.2-A, so this only builds with GCC 13 or later.
|
||||
if [ "$(gcc_version "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc")" -ge 13 ]; then
|
||||
for opt in MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT; do
|
||||
scripts/config.py set $opt
|
||||
msg "$opt ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc, -mcpu=cortex-a76 -D_FORTIFY_SOURCE=2"
|
||||
make -B library/sha512.o library/sha512.s CC="${AARCH64_LINUX_GNU_GCC_PREFIX}gcc" CFLAGS="-std=c99 -Werror -O2 -mcpu=cortex-a76 -D_FORTIFY_SOURCE=2"
|
||||
msg "$opt ${AARCH64_LINUX_GNU_GCC_PREFIX}gcc, test aarch64 crypto instructions built"
|
||||
grep -E 'sha512[a-z0-9]+\s+[qv]' library/sha512.s
|
||||
scripts/config.py unset $opt
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
support_build_sha_armce_gcc () {
|
||||
# Minimum version of GCC for MBEDTLS_SHA256_USE_ARMV8_A_CRYPTO_* is 6.0
|
||||
[ "$(gcc_version "${AARCH64_LINUX_GNU_GCC_PREFIX}gcc")" -ge 6 ]
|
||||
}
|
||||
|
||||
support_test_m32_no_asm () {
|
||||
case $(uname -m) in
|
||||
amd64|x86_64) true;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user