Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 6 | |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <common/debug.h> |
| 10 | #include <plat/common/platform.h> |
| 11 | |
Douglas Raillard | 306593d | 2017-02-24 18:14:15 +0000 | [diff] [blame] | 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 | |