fb11e647
vrobic
reseau statique a...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Copyright (C) 2015 Eistec AB
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/
#include "cpu.h"
/**
* @ingroup cpu_k60
* @{
*
* @file
* @brief Implementation of stack smashing protection helper functions used by GCC's -fstack-protector
*
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
*/
void *__stack_chk_guard = 0;
void __stack_chk_guard_setup(void)
{
unsigned char *p;
p = (unsigned char *) &__stack_chk_guard;
/* TODO: This should be replaced by a random number to use as a canary value */
p[0] = 0;
p[1] = 0;
p[2] = '\n';
p[3] = 255;
}
/*
* Arrange so that the __stack_chk_guard_setup function is called during
* early init.
*/
void __attribute__((section(".preinit_array")))(*preinit__stack_chk_guard_setup[])(void) = {__stack_chk_guard_setup};
/**
* @brief Handler for stack smashing protection failure.
*
* This is called if the SSP checks fail, which means that the stack has been
* corrupted.
*/
void __attribute__((noreturn)) __stack_chk_fail(void)
{
__asm__ volatile ("bkpt #1");
while (1);
}
/** @} */
|