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 | */ |
| 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 | */ |
| 23 | void __dead2 __stack_chk_fail(void) |
| 24 | { |
| 25 | #if DEBUG |
| 26 | ERROR("Stack corruption detected\n"); |
| 27 | #endif |
| 28 | panic(); |
| 29 | } |
| 30 | |