summaryrefslogtreecommitdiff
path: root/libc/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps')
-rw-r--r--libc/sysdeps/linux/common/Makefile1
-rw-r--r--libc/sysdeps/linux/common/Makefile.in5
-rw-r--r--libc/sysdeps/linux/common/dl-osinfo.h64
-rw-r--r--libc/sysdeps/linux/common/ssp.c2
4 files changed, 69 insertions, 3 deletions
diff --git a/libc/sysdeps/linux/common/Makefile b/libc/sysdeps/linux/common/Makefile
index e45c58961..704f0350b 100644
--- a/libc/sysdeps/linux/common/Makefile
+++ b/libc/sysdeps/linux/common/Makefile
@@ -56,6 +56,7 @@ $(OBJS) $(NONSHARED_OBJS): %.o : %.c
headers:
$(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h $(TOPDIR)/include/
+ $(LN) -fs ../libc/sysdeps/linux/common/dl-osinfo.h $(TOPDIR)/include/
clean:
$(RM) *.o *~ core
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index 85826913e..ce7d8f90d 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -31,9 +31,7 @@ COMMON_SRC:=$(patsubst %.c,$(COMMON_DIR)/%.c,$(CSRC))
COMMON_OBJ:=$(patsubst %.c,$(COMMON_OUT)/%.o,$(CSRC))
libc-a-y+=$(COMMON_OBJ)
-libc-a-$(UCLIBC_HAS_SSP)+=$(COMMON_OUT)/ssp-local.o
-libc-a-pic-y+=$(COMMON_OBJ:.o=.os)
-libc-a-pic-$(UCLIBC_HAS_SSP)+=$(COMMON_OUT)/ssp-local.os
+libc-a-static-$(UCLIBC_HAS_SSP)+=$(COMMON_OUT)/ssp-local.o
libc-so-y+=$(COMMON_OBJ:.o=.os)
libc-nonshared-$(UCLIBC_HAS_SSP)+=$(COMMON_OUT)/ssp-local.os
@@ -50,3 +48,4 @@ headers-y+=common_headers
common_headers:
$(LN) -fs ../libc/sysdeps/linux/common/fpu_control.h $(top_builddir)include/
+ $(LN) -fs ../libc/sysdeps/linux/common/dl-osinfo.h $(top_builddir)include/
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 */
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c
index 7791a0104..2f3a28ba4 100644
--- a/libc/sysdeps/linux/common/ssp.c
+++ b/libc/sysdeps/linux/common/ssp.c
@@ -87,6 +87,7 @@ void __attribute__ ((noreturn)) __stack_chk_fail(void)
terminate();
}
+#if 0
void __attribute__ ((noreturn)) __chk_fail(void)
{
extern char *__progname;
@@ -101,3 +102,4 @@ void __attribute__ ((noreturn)) __chk_fail(void)
while(1)
terminate();
}
+#endif