From 61a6c3b0e9a8dab5c5f845af4becde817539133c Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 18 Nov 2021 14:12:47 +0800 Subject: [PATCH] build: add `-mbranch-protection=bti` to aarch64 hardening flags This is a simpler (less hardening) version of #24123. Scoped to aarch64 to avoid unused command line option warnings when building on x86_64. Related to #19075. --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 9b4b9bd42bb..20358205caf 100644 --- a/configure.ac +++ b/configure.ac @@ -964,6 +964,11 @@ if test "$use_hardening" != "no"; then ;; esac + case $host in + *aarch64*) + AX_CHECK_COMPILE_FLAG([-mbranch-protection=bti], [HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -mbranch-protection=bti"]) + ;; + esac dnl When enable_debug is yes, all optimizations are disabled. dnl However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning.