summaryrefslogtreecommitdiff
path: root/lib/safestack
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2015-12-11 17:38:38 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2015-12-11 17:38:38 +0000
commitdd5dc1527ec0569fe6f8cb892d6dda0a39802c34 (patch)
tree36390953707730d8fd5c0b3a7dee8580dd28e14f /lib/safestack
parent1bc6638b6a11742dfff8fbafba7dc7fca92115b3 (diff)
[compiler-rt] [safestack] Enable for aarch64
This patch enables the safestack for aarch64. The frontend already have it enabled on all supported architectures and no adjustment is required in llvm. The compiler-rt adjustments are basically add on the cmake configuration to enable the tests and fix the pagesize debug check by getting its value at runtime (since aarch64 has multiple pagesize depending of kernel configuration). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@255345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/safestack')
-rw-r--r--lib/safestack/safestack.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/safestack/safestack.cc b/lib/safestack/safestack.cc
index 5254462d9..92c24b35d 100644
--- a/lib/safestack/safestack.cc
+++ b/lib/safestack/safestack.cc
@@ -18,6 +18,7 @@
#include <pthread.h>
#include <stddef.h>
#include <stdint.h>
+#include <unistd.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/user.h>
@@ -68,6 +69,9 @@ const unsigned kStackAlign = 16;
/// size rlimit is set to infinity.
const unsigned kDefaultUnsafeStackSize = 0x2800000;
+/// Runtime page size obtained through sysconf
+static unsigned pageSize;
+
// TODO: To make accessing the unsafe stack pointer faster, we plan to
// eventually store it directly in the thread control block data structure on
// platforms where this structure is pointed to by %fs or %gs. This is exactly
@@ -185,7 +189,7 @@ INTERCEPTOR(int, pthread_create, pthread_t *thread,
CHECK_NE(size, 0);
CHECK_EQ((size & (kStackAlign - 1)), 0);
- CHECK_EQ((guard & (PAGE_SIZE - 1)), 0);
+ CHECK_EQ((guard & (pageSize - 1)), 0);
void *addr = unsafe_stack_alloc(size, guard);
struct tinfo *tinfo =
@@ -217,6 +221,7 @@ void __safestack_init() {
void *addr = unsafe_stack_alloc(size, guard);
unsafe_stack_setup(addr, size, guard);
+ pageSize = sysconf(_SC_PAGESIZE);
// Initialize pthread interceptors for thread allocation
INTERCEPT_FUNCTION(pthread_create);