From 0a96a37f06fda78ce3674b425888b1fc090578aa Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 7 Oct 2012 21:43:46 -0400 Subject: clean up and refactor program initialization the code in __libc_start_main is now responsible for parsing auxv, rather than duplicating the parsing all over the place. this should shave off a few cycles and some code size. __init_libc is left as an external-linkage function despite the fact that it could be static, to prevent it from being inlined and permanently wasting stack space when main is called. a few other minor changes are included, like eliminating per-thread ssp canaries (they were likely broken when combined with certain dlopen usages, and completely unnecessary) and some other unnecessary checks. since this code gets linked into every program, it should be as small and simple as possible. --- src/env/__stack_chk_fail.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/env/__stack_chk_fail.c') diff --git a/src/env/__stack_chk_fail.c b/src/env/__stack_chk_fail.c index eac852b7..3e2e4b6d 100644 --- a/src/env/__stack_chk_fail.c +++ b/src/env/__stack_chk_fail.c @@ -6,13 +6,12 @@ uintptr_t __stack_chk_guard; -void __init_ssp(size_t *auxv) +void __init_ssp(void *entropy) { size_t i; pthread_t self = __pthread_self_init(); uintptr_t canary; - for (i=0; auxv[i] && auxv[i]!=AT_RANDOM; i+=2); - if (auxv[i]) memcpy(&canary, (void *)auxv[i+1], sizeof 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; -- cgit v1.2.1