diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2020-05-06 20:22:16 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2020-07-08 15:02:37 +0100 |
commit | 1b0a4f58f5b10cf6d5ad10ee8d81772c5bd29248 (patch) | |
tree | 1b4e0dcc25815f45d90cc1c2b9def4d42ab9aecc /sysdeps/aarch64/configure.ac | |
parent | dbfefbdc3aeec88868cb9d46267f91dc62461226 (diff) | |
download | glibc-1b0a4f58f5b10cf6d5ad10ee8d81772c5bd29248.zip glibc-1b0a4f58f5b10cf6d5ad10ee8d81772c5bd29248.tar.gz glibc-1b0a4f58f5b10cf6d5ad10ee8d81772c5bd29248.tar.bz2 |
aarch64: configure test for BTI support
Check BTI support in the compiler and linker. The check also
requires READELF that understands the BTI GNU property note.
It is expected to succeed with gcc >=gcc-9 configured with
--enable-standard-branch-protection and binutils >=binutils-2.33.
Note: passing -mbranch-protection=bti in CFLAGS when building glibc
may not be enough to get a glibc that supports BTI because crtbegin*
and crtend* provided by the compiler needs to be BTI compatible too.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/aarch64/configure.ac')
-rw-r--r-- | sysdeps/aarch64/configure.ac | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sysdeps/aarch64/configure.ac b/sysdeps/aarch64/configure.ac index 7851dd4..798f494 100644 --- a/sysdeps/aarch64/configure.ac +++ b/sysdeps/aarch64/configure.ac @@ -20,3 +20,22 @@ if test $libc_cv_aarch64_be = yes; then else LIBC_CONFIG_VAR([default-abi], [lp64]) fi + +# Only consider BTI supported if -mbranch-protection=bti is +# on by default in the compiler and the linker produces +# binaries with GNU property notes in PT_GNU_PROPERTY segment. +AC_CACHE_CHECK([for BTI support], [libc_cv_aarch64_bti], [dnl + cat > conftest.c <<EOF +void foo (void) { } +EOF + libc_cv_aarch64_bti=no + if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostdlib -nostartfiles $no_ssp -shared -fPIC -o conftest.so conftest.c]) \ + && AC_TRY_COMMAND([$READELF -lW conftest.so | grep -q GNU_PROPERTY]) \ + && AC_TRY_COMMAND([$READELF -nW conftest.so | grep -q "NT_GNU_PROPERTY_TYPE_0.*AArch64 feature:.* BTI"]) + then + libc_cv_aarch64_bti=yes + fi + rm -rf conftest.*]) +if test $libc_cv_aarch64_bti = yes; then + AC_DEFINE(HAVE_AARCH64_BTI) +fi |