aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2010-08-24 12:58:54 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2010-08-24 12:58:54 +0000
commitda2a0df59c215bf19150821eec15440f2db3f932 (patch)
tree93ba3d280e5bad7826eeb6ed6dc6443564e85d59 /lib
parentf5a5c5653a99ce0bc36c42fa5ce0244536560023 (diff)
downloadsrc-da2a0df59c215bf19150821eec15440f2db3f932.tar.gz
src-da2a0df59c215bf19150821eec15440f2db3f932.zip
Move the __stack_chk_fail_local@FBSD_1.0 compat symbol definition into
the separate .o for libc_pic.a. This prevents rtld from making the symbol global. Putting the stack_protector_compat.c into the public domain acknowledged by kan. Reviewed by: kan MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=211748
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/sys/Makefile.inc2
-rw-r--r--lib/libc/sys/stack_protector.c4
-rw-r--r--lib/libc/sys/stack_protector_compat.c20
3 files changed, 22 insertions, 4 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 05c3e173d109..dc56429a267d 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -18,7 +18,7 @@
.endif
# Sources common to both syscall interfaces:
-SRCS+= stack_protector.c __error.c
+SRCS+= stack_protector.c stack_protector_compat.c __error.c
.if !defined(WITHOUT_SYSCALL_COMPAT)
SRCS+= fcntl.c ftruncate.c lseek.c mmap.c pread.c pwrite.c truncate.c
PSEUDO+= _fcntl.o
diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c
index b0108f9ff7a5..114972f97b4e 100644
--- a/lib/libc/sys/stack_protector.c
+++ b/lib/libc/sys/stack_protector.c
@@ -116,8 +116,6 @@ __chk_fail(void)
__fail("buffer overflow detected; terminated");
}
-#ifdef PIC
-__sym_compat(__stack_chk_fail_local, __stack_chk_fail, FBSD_1.0);
-#else
+#ifndef PIC
__weak_reference(__stack_chk_fail, __stack_chk_fail_local);
#endif
diff --git a/lib/libc/sys/stack_protector_compat.c b/lib/libc/sys/stack_protector_compat.c
new file mode 100644
index 000000000000..cacb863e75e6
--- /dev/null
+++ b/lib/libc/sys/stack_protector_compat.c
@@ -0,0 +1,20 @@
+/*
+ * Written by Alexander Kabaev <kan@FreeBSD.org>
+ * The file is in public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+void __stack_chk_fail(void);
+
+#ifdef PIC
+void
+__stack_chk_fail_local_hidden(void)
+{
+
+ __stack_chk_fail();
+}
+
+__sym_compat(__stack_chk_fail_local, __stack_chk_fail_local_hidden, FBSD_1.0);
+#endif