blob: d0f240092f004e246c63f5acfc7c5bb1e357e107 [file] [log] [blame]
Douglas Raillard306593d2017-02-24 18:14:15 +00001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2017, Arm Limited and Contributors. All rights reserved.
Douglas Raillard306593d2017-02-24 18:14:15 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Douglas Raillard306593d2017-02-24 18:14:15 +00005 */
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00006
Douglas Raillard306593d2017-02-24 18:14:15 +00007#include <stdint.h>
8
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/debug.h>
10#include <plat/common/platform.h>
11
Douglas Raillard306593d2017-02-24 18:14:15 +000012/*
13 * Canary value used by the compiler runtime checks to detect stack corruption.
14 *
15 * Force the canary to be in .data to allow predictable memory layout relatively
16 * to the stacks.
17 */
18u_register_t __attribute__((section(".data.stack_protector_canary")))
19 __stack_chk_guard = (u_register_t) 3288484550995823360ULL;
20
21/*
22 * Function called when the stack's canary check fails, which means the stack
23 * was corrupted. It must not return.
24 */
25void __dead2 __stack_chk_fail(void)
26{
27#if DEBUG
28 ERROR("Stack corruption detected\n");
29#endif
30 panic();
31}
32