Debian Codegraph @

lib/stack_protector/stack_protector.c

raw
1 /*
2 * Copyright (c) 2017, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <stdint.h>
8
9 #include <common/debug.h>
10 #include <plat/common/platform.h>
11
12 /*
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 */
18 u_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 */
25 void __dead2 __stack_chk_fail(void)
26 {
27 #if DEBUG
28 ERROR("Stack corruption detected\n");
29 #endif
30 panic();
31 }
32