From 91181954f94917b1e1ae591c60cbadf0321d35af Mon Sep 17 00:00:00 2001 From: Sudakshina Das Date: Tue, 17 Mar 2020 15:44:18 +0000 Subject: aarch64: Add BTI support to assembly files To enable building glibc with branch protection, assembly code needs BTI landing pads and ELF object file markings in the form of a GNU property note. The landing pads are unconditionally added to all functions that may be indirectly called. When the code segment is not mapped with PROT_BTI these instructions are nops. They are kept in the code when BTI is not supported so that the layout of performance critical code is unchanged across configurations. The GNU property notes are only added when there is support for BTI in the toolchain, because old binutils does not handle the notes right. (Does not know how to merge them nor to put them in PT_GNU_PROPERTY segment instead of PT_NOTE, and some versions of binutils emit warnings about the unknown GNU property. In such cases the produced libc binaries would not have valid ELF marking so BTI would not be enabled.) Note: functions using ENTRY or ENTRY_ALIGN now start with an additional BTI c, so alignment of the following code changes, but ENTRY_ALIGN_AND_PAD was fixed so there is no change to the existing code layout. Some string functions may need to be tuned for optimal performance after this commit. Co-authored-by: Szabolcs Nagy Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/multiarch/memset_emag.S | 2 ++ sysdeps/aarch64/multiarch/memset_falkor.S | 1 + sysdeps/aarch64/multiarch/memset_generic.S | 2 ++ sysdeps/aarch64/multiarch/rtld-memset.S | 2 ++ 4 files changed, 7 insertions(+) (limited to 'sysdeps/aarch64/multiarch') diff --git a/sysdeps/aarch64/multiarch/memset_emag.S b/sysdeps/aarch64/multiarch/memset_emag.S index c4d3533c14..3c2e9d2903 100644 --- a/sysdeps/aarch64/multiarch/memset_emag.S +++ b/sysdeps/aarch64/multiarch/memset_emag.S @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#include + #if IS_IN (libc) # define MEMSET __memset_emag diff --git a/sysdeps/aarch64/multiarch/memset_falkor.S b/sysdeps/aarch64/multiarch/memset_falkor.S index 54fd5abffb..154527398f 100644 --- a/sysdeps/aarch64/multiarch/memset_falkor.S +++ b/sysdeps/aarch64/multiarch/memset_falkor.S @@ -17,6 +17,7 @@ License along with the GNU C Library. If not, see . */ +#include #include /* Reading dczid_el0 is expensive on falkor so move it into the ifunc diff --git a/sysdeps/aarch64/multiarch/memset_generic.S b/sysdeps/aarch64/multiarch/memset_generic.S index 46c5329cdf..d746d1d00c 100644 --- a/sysdeps/aarch64/multiarch/memset_generic.S +++ b/sysdeps/aarch64/multiarch/memset_generic.S @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#include + #if IS_IN (libc) # define MEMSET __memset_generic /* Add a hidden definition for use within libc.so. */ diff --git a/sysdeps/aarch64/multiarch/rtld-memset.S b/sysdeps/aarch64/multiarch/rtld-memset.S index 44bc479411..f9845bdd62 100644 --- a/sysdeps/aarch64/multiarch/rtld-memset.S +++ b/sysdeps/aarch64/multiarch/rtld-memset.S @@ -17,6 +17,8 @@ License along with the GNU C Library. If not, see . */ +#include + #if IS_IN (rtld) # define MEMSET memset # include -- cgit 1.4.1