diff options
| -rw-r--r-- | ldso/ldso/ldso.c | 14 | ||||
| -rw-r--r-- | libc/misc/internals/__uClibc_main.c | 25 | ||||
| -rw-r--r-- | libc/sysdeps/linux/common/ssp.c | 3 | 
3 files changed, 15 insertions, 27 deletions
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index 89af5a505..4d79d4665 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -102,15 +102,13 @@ extern void _start(void);  #ifdef __UCLIBC_HAS_SSP__  # include <dl-osinfo.h> -uintptr_t stack_chk_guard; +static uintptr_t stack_chk_guard;  # 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; -#  ifdef __UCLIBC_HAS_SSP_COMPAT__ -strong_alias(__stack_chk_guard,__guard) -#  endif -# elif defined __UCLIBC_HAS_SSP_COMPAT__ +# endif +# ifdef __UCLIBC_HAS_SSP_COMPAT__  uintptr_t __guard attribute_relro;  # endif  #endif @@ -944,12 +942,12 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,  	stack_chk_guard = _dl_setup_stack_chk_guard ();  # ifdef THREAD_SET_STACK_GUARD  	THREAD_SET_STACK_GUARD (stack_chk_guard); -#  ifdef __UCLIBC_HAS_SSP_COMPAT__ -	__guard = stack_chk_guard; -#  endif  # else  	__stack_chk_guard = stack_chk_guard;  # endif +# ifdef __UCLIBC_HAS_SSP_COMPAT__ +	__guard = stack_chk_guard; +# endif  #endif diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index da29ef69e..315365a25 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -45,22 +45,15 @@ void *__libc_stack_end = NULL;  # ifdef __UCLIBC_HAS_SSP__  #  include <dl-osinfo.h> +static uintptr_t stack_chk_guard;  #  ifndef THREAD_SET_STACK_GUARD  /* Only exported for architectures that don't store the stack guard canary   * in thread local area. */ -#   include <stdint.h> -uintptr_t stack_chk_guard;  /* for gcc-4.1 non-TLS */  uintptr_t __stack_chk_guard attribute_relro; +#  endif  /* for gcc-3.x + Etoh ssp */ -#   ifdef __UCLIBC_HAS_SSP_COMPAT__ -#    ifdef __HAVE_SHARED__ -strong_alias(__stack_chk_guard,__guard) -#    else -uintptr_t __guard attribute_relro; -#    endif -#   endif -#  elif defined __UCLIBC_HAS_SSP_COMPAT__ +#  ifdef __UCLIBC_HAS_SSP_COMPAT__  uintptr_t __guard attribute_relro;  #  endif  # endif @@ -251,18 +244,14 @@ void __uClibc_init(void)  #ifndef SHARED  # ifdef __UCLIBC_HAS_SSP__      /* Set up the stack checker's canary.  */ +    stack_chk_guard = _dl_setup_stack_chk_guard();  #  ifdef THREAD_SET_STACK_GUARD -    uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard();      THREAD_SET_STACK_GUARD (stack_chk_guard); -#   ifdef __UCLIBC_HAS_SSP_COMPAT__ -    stack_chk_guard = _dl_setup_stack_chk_guard(); -    __guard = stack_chk_guard; -#   endif  #  else      __stack_chk_guard = stack_chk_guard; -#   if !defined __HAVE_SHARED__ && defined __UCLIBC_HAS_SSP_COMPAT__ -     __guard = stack_chk_guard; -#   endif +#  endif +#  ifdef __UCLIBC_HAS_SSP_COMPAT__ +    __guard = stack_chk_guard;  #  endif  # endif  #endif diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index a2d7ff2ca..d81c706f4 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -71,6 +71,7 @@ static attribute_noreturn void terminate(void)  	_exit(127);  } +#ifdef __UCLIBC_HAS_SSP_COMPAT__  void __stack_smash_handler(char func[], int damaged __attribute__ ((unused))) attribute_noreturn __cold;  void __stack_smash_handler(char func[], int damaged)  { @@ -84,6 +85,7 @@ void __stack_smash_handler(char func[], int damaged)  	while(1)  		terminate();  } +#endif  void __stack_chk_fail(void) attribute_noreturn __cold;  void __stack_chk_fail(void) @@ -114,4 +116,3 @@ void __chk_fail(void)  	while(1)  		terminate();  } -  | 
