summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/cmake/config-ix.cmake2
-rw-r--r--compiler-rt/lib/safestack/safestack.cc7
2 files changed, 7 insertions, 2 deletions
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 106ad58b819..d003f03a7d2 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -281,7 +281,7 @@ set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC64}
set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64})
set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
${MIPS32} ${MIPS64} ${PPC64})
-set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64})
+set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64})
if(APPLE)
include(CompilerRTDarwinUtils)
diff --git a/compiler-rt/lib/safestack/safestack.cc b/compiler-rt/lib/safestack/safestack.cc
index 5254462d92c..92c24b35d6d 100644
--- a/compiler-rt/lib/safestack/safestack.cc
+++ b/compiler-rt/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);
OpenPOWER on IntegriCloud