3 #include "pthread_impl.h"
6 uintptr_t __stack_chk_guard;
8 void __init_ssp(void *entropy)
10 /* Here the thread pointer is used without checking whether
11 * it is available; this will crash if it's not. However,
12 * this function is only meant to be called if the program
13 * being run uses stack protector, and in that case, it would
14 * crash without a thread pointer anyway, so it's better to
15 * crash early before there is state to be lost on crash. */
16 pthread_t self = __pthread_self();
18 if (entropy) memcpy(&canary, entropy, sizeof canary);
19 else canary = (uintptr_t)&canary * 1103515245;
20 a_cas_l(&__stack_chk_guard, 0, canary);
21 self->canary = __stack_chk_guard;
24 void __stack_chk_fail(void)