__stack_chk_fail.c 466 字节
Newer Older
1 2 3
#include <string.h>
#include <inttypes.h>
#include <elf.h>
4 5 6
#include "pthread_impl.h"
#include "atomic.h"

7 8
uintptr_t __stack_chk_guard;

9
void __init_ssp(void *entropy)
10
{
11 12 13
	size_t i;
	pthread_t self = __pthread_self_init();
	uintptr_t canary;
14
	if (entropy) memcpy(&canary, entropy, sizeof canary);
15
	else canary = (uintptr_t)&canary * 1103515245;
16 17
	a_cas_l(&__stack_chk_guard, 0, canary);
	self->canary = __stack_chk_guard;
18 19 20 21 22 23
}

void __stack_chk_fail(void)
{
	a_crash();
}