summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common/dl-osinfo.h
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2005-10-30 00:02:40 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2005-10-30 00:02:40 +0000
commit8bd5f12892294006afa2c3538323dfbbf1194f49 (patch)
treeee5de81e9dc045f29932e9e7b15db21322417fae /libc/sysdeps/linux/common/dl-osinfo.h
parent33b16c7f88e78ff318c6f62aae0785abbc363859 (diff)
downloaduClibc-alpine-8bd5f12892294006afa2c3538323dfbbf1194f49.tar.bz2
uClibc-alpine-8bd5f12892294006afa2c3538323dfbbf1194f49.tar.xz
Add from trunk.
Diffstat (limited to 'libc/sysdeps/linux/common/dl-osinfo.h')
-rw-r--r--libc/sysdeps/linux/common/dl-osinfo.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/common/dl-osinfo.h b/libc/sysdeps/linux/common/dl-osinfo.h
new file mode 100644
index 000000000..ee3e2ce99
--- /dev/null
+++ b/libc/sysdeps/linux/common/dl-osinfo.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#ifndef _DL_OSINFO_H
+#define _DL_OSINFO_H 1
+
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_SSP__
+#include <stdint.h>
+#include <sys/time.h>
+
+#ifdef IS_IN_libc
+#include <ssp-internal.h>
+#if 0
+#ifndef __SSP_QUICK_CANARY__
+#define OPEN __libc_open
+#define READ __libc_read
+#define CLOSE __libc_close
+#endif
+#define GETTIMEOFDAY gettimeofday
+#endif
+#else
+#ifndef __SSP_QUICK_CANARY__
+#define OPEN _dl_open
+#define READ _dl_read
+#define CLOSE _dl_close
+#endif
+#define GETTIMEOFDAY _dl_gettimeofday
+#endif
+
+static __always_inline uintptr_t _dl_setup_stack_chk_guard(void)
+{
+ uintptr_t ret;
+#ifndef __SSP_QUICK_CANARY__
+ {
+ int fd = OPEN("/dev/urandom", O_RDONLY, 0);
+ if (fd >= 0) {
+ size_t size = READ(fd, &ret, sizeof(ret));
+ CLOSE(fd);
+ if (size == (size_t) sizeof(ret))
+ return ret;
+ }
+ }
+#endif /* !__SSP_QUICK_CANARY__ */
+
+ /* Start with the "terminator canary". */
+ ret = 0xFF0A0D00UL;
+
+ /* Everything failed? Or we are using a weakened model of the
+ * terminator canary */
+ {
+ struct timeval tv;
+ if (GETTIMEOFDAY(&tv, NULL) != (-1))
+ ret ^= tv.tv_usec ^ tv.tv_sec;
+ }
+ return ret;
+}
+#endif /* __UCLIBC_HAS_SSP__ */
+
+#endif /* _DL_OSINFO_H */