2 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
12 #ifdef __UCLIBC_HAS_SSP__
13 # if defined IS_IN_libc || defined IS_IN_rtld
15 # if defined __SSP__ || defined __SSP_ALL__
16 # error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
24 # include <sys/time.h>
28 # define GETTIMEOFDAY gettimeofday
30 # define OPEN _dl_open
31 # define READ _dl_read
32 # define CLOSE _dl_close
33 # define GETTIMEOFDAY _dl_gettimeofday
36 static __always_inline uintptr_t _dl_setup_stack_chk_guard(void)
39 # ifndef __SSP_QUICK_CANARY__
41 int fd = OPEN("/dev/urandom", O_RDONLY, 0);
43 size_t size = READ(fd, &ret, sizeof(ret));
45 if (size == (size_t) sizeof(ret))
49 # endif /* !__SSP_QUICK_CANARY__ */
51 /* Start with the "terminator canary". */
54 /* Everything failed? Or we are using a weakened model of the
55 * terminator canary */
58 if (GETTIMEOFDAY(&tv, NULL) != (-1))
59 ret ^= tv.tv_usec ^ tv.tv_sec;
63 # endif /* libc || rtld */
64 #endif /* __UCLIBC_HAS_SSP__ */
66 #endif /* _DL_OSINFO_H */