]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
aarch64: ensure objects are BTI compatible
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 30 Jun 2020 10:12:40 +0000 (11:12 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 8 Jul 2020 14:02:38 +0000 (15:02 +0100)
When glibc is built with branch protection (i.e. with a gcc configured
with --enable-standard-branch-protection), all glibc binaries should
be BTI compatible and marked as such.

It is easy to link BTI incompatible objects by accident and this is
silent currently which is usually not the expectation, so this is
changed into a link error. (There is no linker flag for failing on
BTI incompatible inputs so all warnings are turned into fatal errors
outside the test system when building glibc with branch protection.)

Unfortunately, outlined atomic functions are not BTI compatible in
libgcc (PR libgcc/96001), so to build glibc with current gcc use
'CC=gcc -mno-outline-atomics', this should be fixed in libgcc soon
and then glibc can be built and tested without such workarounds.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/aarch64/Makefile
sysdeps/aarch64/configure
sysdeps/aarch64/configure.ac

index 5ae8b082b0ba0270feccd329b27829baba1d539e..7f82fc055e3516a558f2f18d4ac7282c8711f89b 100644 (file)
@@ -1,5 +1,13 @@
 long-double-fcts = yes
 
+ifeq (yes,$(aarch64-bti))
+# Mark linker output BTI compatible, it warns on non-BTI inputs.
+sysdep-LDFLAGS += -Wl,-z,force-bti
+# Make warnings fatal outside the test system.
+LDFLAGS-lib.so += -Wl,--fatal-warnings
+LDFLAGS-rtld += -Wl,-z,force-bti,--fatal-warnings
+endif
+
 ifeq ($(subdir),elf)
 sysdep-dl-routines += dl-bti
 endif
index 70477a7fa56efc16df10dfca08b4ecf10dbb7f6d..c6375404364e3c44b64653cfd07f37c2cc74d9a4 100644 (file)
@@ -210,6 +210,8 @@ EOF
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_aarch64_bti" >&5
 $as_echo "$libc_cv_aarch64_bti" >&6; }
+config_vars="$config_vars
+aarch64-bti = $libc_cv_aarch64_bti"
 if test $libc_cv_aarch64_bti = yes; then
   $as_echo "#define HAVE_AARCH64_BTI 1" >>confdefs.h
 
index 798f4947400fb0c46077522a8a58fa37220e1e70..2c2817514d790b173afcb8450e5c66c570c5b70a 100644 (file)
@@ -36,6 +36,7 @@ EOF
     libc_cv_aarch64_bti=yes
   fi
   rm -rf conftest.*])
+LIBC_CONFIG_VAR([aarch64-bti], [$libc_cv_aarch64_bti])
 if test $libc_cv_aarch64_bti = yes; then
   AC_DEFINE(HAVE_AARCH64_BTI)
 fi