Module Name: src Committed By: christos Date: Tue Dec 6 02:55:42 UTC 2016
Modified Files: src/sys/kern: kern_ssp.c Log Message: void duplicate definition on statically linking libc+ssp and rumpkern+ssp. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/kern/kern_ssp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_ssp.c diff -u src/sys/kern/kern_ssp.c:1.6 src/sys/kern/kern_ssp.c:1.7 --- src/sys/kern/kern_ssp.c:1.6 Sat Nov 19 17:51:25 2011 +++ src/sys/kern/kern_ssp.c Mon Dec 5 21:55:42 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_ssp.c,v 1.6 2011/11/19 22:51:25 tls Exp $ */ +/* $NetBSD: kern_ssp.c,v 1.7 2016/12/06 02:55:42 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_ssp.c,v 1.6 2011/11/19 22:51:25 tls Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_ssp.c,v 1.7 2016/12/06 02:55:42 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -35,11 +35,21 @@ __KERNEL_RCSID(0, "$NetBSD: kern_ssp.c,v #include <sys/cprng.h> #if defined(__SSP__) || defined(__SSP_ALL__) -long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -void __stack_chk_fail(void); +# ifdef _RUMPKERNEL +__weak_alias(__stack_chk_guard, stack_chk_guard) +__weak_alias(__stack_chk_fail, stack_chk_fail) +# define SSP_STATIC static __used +# else +# define stack_chk_guard __stack_chk_guard +# define stack_chk_fail __stack_chk_fail +# define SSP_STATIC +#endif -void -__stack_chk_fail(void) +SSP_STATIC long stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0,}; +SSP_STATIC void stack_chk_fail(void); + +SSP_STATIC void +stack_chk_fail(void) { panic("stack overflow detected; terminated"); } @@ -56,12 +66,12 @@ ssp_init(void) * 2. without calling a function */ size_t i; - long guard[__arraycount(__stack_chk_guard)]; + long guard[__arraycount(stack_chk_guard)]; cprng_fast(guard, sizeof(guard)); s = splhigh(); for (i = 0; i < __arraycount(guard); i++) - __stack_chk_guard[i] = guard[i]; + stack_chk_guard[i] = guard[i]; splx(s); for (i = 0; i < __arraycount(guard); i++) aprint_debug("%lx ", guard[i]);