From 237277e9a8133c64026b736b1427141e71655330 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Thu, 27 Oct 2005 22:58:52 +0000 Subject: Moved guard_setup to dl-osinfo.h (used commonly by ldso and libc). Renamed to _dl_setup_stack_chk_guard, as in glibc. SSP requires now binutils-2.16.1 and newer. Add NOT_IN_libc/IS_IN_libc. Began using -DSHARED in uClibc_main.c, there are more candidates in there. Move back dl_protect_relro to it's earlier place. --- ldso/ldso/ldso.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'ldso/ldso/ldso.c') diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 3b678588f..3d6884c0c 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -85,6 +85,16 @@ static struct elf_resolve **init_fini_list; static int nlist; /* # items in init_fini_list */ extern void _start(void); +#ifdef __UCLIBC_HAS_SSP__ +#include +#ifndef THREAD_SET_STACK_GUARD +/* Only exported for architectures that don't store the stack guard canary + * in local thread area. */ +uintptr_t __stack_chk_guard attribute_relro; +strong_alias(__stack_chk_guard,__guard) +#endif +#endif + static void __attribute__ ((destructor)) __attribute_used__ _dl_fini(void) { int i; @@ -196,6 +206,17 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr, unlazy = RTLD_NOW; } + /* sjhill: your TLS init should go before this */ +#ifdef __UCLIBC_HAS_SSP__ + /* Set up the stack checker's canary. */ + uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); +# ifdef THREAD_SET_STACK_GUARD + THREAD_SET_STACK_GUARD (stack_chk_guard); +# else + __stack_chk_guard = stack_chk_guard; +# endif +#endif + /* At this point we are now free to examine the user application, * and figure out which libraries are supposed to be called. Until * we have this list, we will not be completely ready for dynamic @@ -705,6 +726,11 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr, if (_dl_symbol_tables) goof += _dl_fixup(_dl_symbol_tables, unlazy); + for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) { + if (tpnt->relro_size) + _dl_protect_relro (tpnt); + } + /* OK, at this point things are pretty much ready to run. Now we need * to touch up a few items that are required, and then we can let the * user application have at it. Note that the dynamic linker itself @@ -756,11 +782,6 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, unsigned long load_addr, } } - for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) { - if (tpnt->relro_size) - _dl_protect_relro (tpnt); - } - /* Find the real malloc function and make ldso functions use that from now on */ _dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash("malloc", _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT); -- cgit v1.2.3