• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 #include <debug.h>
7 #include <platform.h>
8 #include <stdint.h>
9 
10 /*
11  * Canary value used by the compiler runtime checks to detect stack corruption.
12  *
13  * Force the canary to be in .data to allow predictable memory layout relatively
14  * to the stacks.
15  */
16 u_register_t  __attribute__((section(".data.stack_protector_canary")))
17 	__stack_chk_guard = (u_register_t) 3288484550995823360ULL;
18 
19 /*
20  * Function called when the stack's canary check fails, which means the stack
21  * was corrupted. It must not return.
22  */
__stack_chk_fail(void)23 void __dead2 __stack_chk_fail(void)
24 {
25 #if DEBUG
26 	ERROR("Stack corruption detected\n");
27 #endif
28 	panic();
29 }
30 
31