1 // A shadow call stack runtime is not yet included with compiler-rt, provide a
2 // minimal runtime to allocate a shadow call stack and assign an
3 // architecture-specific register to point at it.
11 #include "libc_support.h"
13 __attribute__((no_sanitize("shadow-call-stack")))
14 static void __shadowcallstack_init() {
15 void *stack
= mmap(NULL
, 8192, PROT_READ
| PROT_WRITE
,
16 MAP_PRIVATE
| MAP_ANONYMOUS
, -1, 0);
17 if (stack
== MAP_FAILED
)
20 #if defined(__aarch64__)
21 __asm__
__volatile__("mov x18, %0" ::"r"(stack
));
23 #error Unsupported platform
29 __attribute__((no_sanitize("shadow-call-stack"))) int main(void) {
30 __shadowcallstack_init();
32 // We can't simply return scs_main() because scs_main might have corrupted our
33 // return address for testing purposes (see overflow.c), so we need to exit