mirror of
git://sourceware.org/git/glibc.git
synced 2024-12-09 04:11:27 +08:00
965cb60a21
one parameter. If non-NULL use it to initialize return value. (_dl_setup_pointer_guard): New function. * sysdeps/unix/sysv/linux/dl-osinfo.h: Likewise. * sysdeps/generic/ldsodefs.h: Declare _dl_random. * elf/rtld.c (security_init): Pass _dl_random to _dl_setup_stack_chk_guard. Call _dl_setup_pointer_guard to initialize pointer_chk_guard. * elf/dl-sysdep.c (_dl_random): New variable. (_dl_sysdep_start): Handle AT_RANDOM. (_dl_show_auxv): Likewise. * elf/dl-support.c (_dl_random): New variable. (_dl_aux_init): Handle AT_RANDOM. * csu/libc-start.c [!SHARED] (libc_start_main): Pass _dl_random to _dl_setup_stack_chk_guard. * elf/elf.h (AT_RANDOM): Define AT_BASE_PLATFORM and AT_RANDOM.
30 lines
679 B
C
30 lines
679 B
C
#include <stdint.h>
|
|
|
|
static inline uintptr_t __attribute__ ((always_inline))
|
|
_dl_setup_stack_chk_guard (void *dl_random)
|
|
{
|
|
uintptr_t ret;
|
|
if (dl_random == NULL)
|
|
{
|
|
ret = 0;
|
|
unsigned char *p = (unsigned char *) &ret;
|
|
p[sizeof (ret) - 1] = 255;
|
|
p[sizeof (ret) - 2] = '\n';
|
|
p[0] = 0;
|
|
}
|
|
else
|
|
memcmp (&ret, dl_random, sizeof (ret));
|
|
return ret;
|
|
}
|
|
|
|
static inline uintptr_t __attribute__ ((always_inline))
|
|
_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard)
|
|
{
|
|
uintptr_t ret;
|
|
if (dl_random == NULL)
|
|
ret = stack_chk_guard;
|
|
else
|
|
memcmp (&ret, (char *) dl_random + sizeof (ret), sizeof (ret));
|
|
return ret;
|
|
}
|