X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fenv%2F__stack_chk_fail.c;h=47784c62383d66df4ca9a3f337b4b953c6193c3f;hb=3d7e32d28dc9962e9efc1c317c5b44b5b2df3008;hp=031a1ed7058e4aefd498cc4a379858eacc2ac9c2;hpb=3a5aa8e49ce9a98725ceb311bb64f6168fc72d3e;p=musl diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c index 031a1ed7..47784c62 100644 --- a/src/env/__stack_chk_fail.c +++ b/src/env/__stack_chk_fail.c @@ -1,22 +1,28 @@ #include -#include -#include +#include #include "pthread_impl.h" -#include "atomic.h" uintptr_t __stack_chk_guard; void __init_ssp(void *entropy) { - pthread_t self = __pthread_self_init(); - uintptr_t canary; - if (entropy) memcpy(&canary, entropy, sizeof canary); - else canary = (uintptr_t)&canary * 1103515245; - a_cas_l(&__stack_chk_guard, 0, canary); - self->canary = __stack_chk_guard; + if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t)); + else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245; + + __pthread_self()->CANARY = __stack_chk_guard; } void __stack_chk_fail(void) { a_crash(); } + +#ifdef SHARED + +__attribute__((__visibility__("hidden"))) +void __stack_chk_fail_local(void) +{ + a_crash(); +} + +#endif