Module Name:    src
Committed By:   joerg
Date:           Mon Feb 21 00:40:08 UTC 2011

Modified Files:
        src/include/ssp: ssp.h
        src/lib/libc/gen: getcwd.c

Log Message:
Redo the SSP wrappers to be transparent on the resulting object files.
This works by having the inline wrapper calling a second function which
uses renaming to output the correct function name.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/include/ssp/ssp.h
cvs rdiff -u -r1.49 -r1.50 src/lib/libc/gen/getcwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/ssp/ssp.h
diff -u src/include/ssp/ssp.h:1.8 src/include/ssp/ssp.h:1.9
--- src/include/ssp/ssp.h:1.8	Wed Jan 26 18:08:00 2011
+++ src/include/ssp/ssp.h	Mon Feb 21 00:40:08 2011
@@ -1,7 +1,7 @@
-/*	$NetBSD: ssp.h,v 1.8 2011/01/26 18:08:00 christos Exp $	*/
+/*	$NetBSD: ssp.h,v 1.9 2011/02/21 00:40:08 joerg Exp $	*/
 
 /*-
- * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -40,16 +40,20 @@
 #  else
 #   define __SSP_FORTIFY_LEVEL 1
 #  endif
+# else
+#  define __SSP_FORTIFY_LEVEL 0
 # endif
+#else
+# define __SSP_FORTIFY_LEVEL 0
 #endif
 
-#ifndef __ssp_weak_name
-#ifdef _NAMESPACE_H_
-#define __ssp_weak_name(fun) _sys ## fun
+/* __ssp_real is used by the implementation in libc */
+#if __SSP_FORTIFY_LEVEL == 0
+#define __ssp_real_(fun)	fun
 #else
-#define __ssp_weak_name(fun) _sys_ ## fun
-#endif
+#define __ssp_real_(fun)	__ssp_real_ ## fun
 #endif
+#define __ssp_real(fun)		__ssp_real_(fun)
 
 #define __ssp_inline static __inline __attribute__((__always_inline__))
 
@@ -59,18 +63,18 @@
 #define __ssp_check(buf, len, bos) \
 	if (bos(buf) != (size_t)-1 && len > bos(buf)) \
 		__chk_fail()
-#define __ssp_redirect_raw(rtype, fun, args, call, bos) \
-rtype __ssp_weak_name(fun) args; \
-__ssp_inline rtype fun args; \
+#define __ssp_redirect_raw(rtype, fun, symbol, args, call, bos) \
+rtype __ssp_real_(fun) args __RENAME(symbol); \
+__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \
 __ssp_inline rtype fun args { \
 	__ssp_check(__buf, __len, bos); \
-	return __ssp_weak_name(fun) call; \
+	return __ssp_real_(fun) call; \
 }
 
 #define __ssp_redirect(rtype, fun, args, call) \
-    __ssp_redirect_raw(rtype, fun, args, call, __ssp_bos)
+    __ssp_redirect_raw(rtype, fun, fun, args, call, __ssp_bos)
 #define __ssp_redirect0(rtype, fun, args, call) \
-    __ssp_redirect_raw(rtype, fun, args, call, __ssp_bos0)
+    __ssp_redirect_raw(rtype, fun, fun, args, call, __ssp_bos0)
 
 __BEGIN_DECLS
 void __stack_chk_fail(void) __dead;

Index: src/lib/libc/gen/getcwd.c
diff -u src/lib/libc/gen/getcwd.c:1.49 src/lib/libc/gen/getcwd.c:1.50
--- src/lib/libc/gen/getcwd.c:1.49	Wed Feb 16 20:20:25 2011
+++ src/lib/libc/gen/getcwd.c	Mon Feb 21 00:40:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: getcwd.c,v 1.49 2011/02/16 20:20:25 tron Exp $	*/
+/*	$NetBSD: getcwd.c,v 1.50 2011/02/21 00:40:07 joerg Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)getcwd.c	8.5 (Berkeley) 2/7/95";
 #else
-__RCSID("$NetBSD: getcwd.c,v 1.49 2011/02/16 20:20:25 tron Exp $");
+__RCSID("$NetBSD: getcwd.c,v 1.50 2011/02/21 00:40:07 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -50,22 +50,14 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <ssp/ssp.h>
 
 #include "extern.h"
 
 #ifdef __weak_alias
-__weak_alias(getcwd,_sys_getcwd)
-__weak_alias(_getcwd,_sys_getcwd)
+__weak_alias(getcwd,_getcwd)
+__weak_alias(_sys_getcwd,_getcwd)
 __weak_alias(realpath,_realpath)
-
-#if !defined(lint)
-#undef getcwd
-#define getcwd _sys_getcwd
-#if !defined(_FORTIFY_SOURCE)
-char *_sys_getcwd(char *, size_t);
-#endif
-
-#endif
 #endif
 
 /*
@@ -216,7 +208,7 @@
 }
 
 char *
-getcwd(char *pt, size_t size)
+__ssp_real(getcwd)(char *pt, size_t size)
 {
 	char *npt;
 

Reply via email to