Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Redo the SSP wrappers to be transparent on the resulting obj...



details:   https://anonhg.NetBSD.org/src/rev/65a9154941c0
branches:  trunk
changeset: 762439:65a9154941c0
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Feb 21 00:40:07 2011 +0000

description:
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.

diffstat:

 include/ssp/ssp.h     |  30 +++++++++++++++++-------------
 lib/libc/gen/getcwd.c |  20 ++++++--------------
 2 files changed, 23 insertions(+), 27 deletions(-)

diffs (117 lines):

diff -r 08b0649bf152 -r 65a9154941c0 include/ssp/ssp.h
--- a/include/ssp/ssp.h Mon Feb 21 00:39:54 2011 +0000
+++ b/include/ssp/ssp.h Mon Feb 21 00:40:07 2011 +0000
@@ -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
+#define __ssp_real_(fun)       __ssp_real_ ## fun
 #endif
-#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;
diff -r 08b0649bf152 -r 65a9154941c0 lib/libc/gen/getcwd.c
--- a/lib/libc/gen/getcwd.c     Mon Feb 21 00:39:54 2011 +0000
+++ b/lib/libc/gen/getcwd.c     Mon Feb 21 00:40:07 2011 +0000
@@ -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;
 



Home | Main Index | Thread Index | Old Index