blob: fba5e1ffa03a2bc826d31c0532c58cecac01592e [file] [log] [blame]
Douglas Raillard306593d2017-02-24 18:14:15 +00001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Douglas Raillard306593d2017-02-24 18:14:15 +00005 */
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 */
16u_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 */
23void __dead2 __stack_chk_fail(void)
24{
25#if DEBUG
26 ERROR("Stack corruption detected\n");
27#endif
28 panic();
29}
30