Module Name: src Committed By: mrg Date: Sun Feb 4 20:22:18 UTC 2018
Modified Files: src/common/lib/libc/string: bcopy.c memchr.c memcmp.c strcat.c strchr.c strcmp.c strcpy.c strncmp.c strrchr.c src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common: sanitizer_linux.cc src/external/gpl3/gcc/dist/libsanitizer/ubsan: ubsan_platform.h Log Message: updates for GCC 6.4: - remove many _DIAGASSERT() checks against not NULL for functions with arguments with nonnull attributes. (probably more to come, the set between x86 and sparc us disjoint.) - port libsanitizer's GetPcSpBp() to sparc, sparc64 and amd64. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/common/lib/libc/string/bcopy.c cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/string/memchr.c \ src/common/lib/libc/string/strcmp.c src/common/lib/libc/string/strcpy.c cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/string/memcmp.c cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/string/strcat.c \ src/common/lib/libc/string/strncmp.c cvs rdiff -u -r1.5 -r1.6 src/common/lib/libc/string/strchr.c \ src/common/lib/libc/string/strrchr.c cvs rdiff -u -r1.11 -r1.12 \ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc cvs rdiff -u -r1.2 -r1.3 \ src/external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_platform.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/common/lib/libc/string/bcopy.c diff -u src/common/lib/libc/string/bcopy.c:1.11 src/common/lib/libc/string/bcopy.c:1.12 --- src/common/lib/libc/string/bcopy.c:1.11 Wed Apr 16 20:39:55 2014 +++ src/common/lib/libc/string/bcopy.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: bcopy.c,v 1.11 2014/04/16 20:39:55 joerg Exp $ */ +/* $NetBSD: bcopy.c,v 1.12 2018/02/04 20:22:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: bcopy.c,v 1.11 2014/04/16 20:39:55 joerg Exp $"); +__RCSID("$NetBSD: bcopy.c,v 1.12 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -89,7 +89,7 @@ bcopy(const void *src0, void *dst0, size unsigned long u; #if !defined(_KERNEL) - _DIAGASSERT((dst0 && src0) || length == 0); + _DIAGASSERT(length == 0); #endif if (length == 0 || dst == src) /* nothing to do */ Index: src/common/lib/libc/string/memchr.c diff -u src/common/lib/libc/string/memchr.c:1.3 src/common/lib/libc/string/memchr.c:1.4 --- src/common/lib/libc/string/memchr.c:1.3 Tue Jan 8 21:57:06 2008 +++ src/common/lib/libc/string/memchr.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memchr.c,v 1.3 2008/01/08 21:57:06 martin Exp $ */ +/* $NetBSD: memchr.c,v 1.4 2018/02/04 20:22:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: memchr.c,v 1.3 2008/01/08 21:57:06 martin Exp $"); +__RCSID("$NetBSD: memchr.c,v 1.4 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -51,7 +51,6 @@ __RCSID("$NetBSD: memchr.c,v 1.3 2008/01 void * memchr(const void *s, int c, size_t n) { - _DIAGASSERT(s != NULL); if (n != 0) { const unsigned char *p = s; Index: src/common/lib/libc/string/strcmp.c diff -u src/common/lib/libc/string/strcmp.c:1.3 src/common/lib/libc/string/strcmp.c:1.4 --- src/common/lib/libc/string/strcmp.c:1.3 Mon Jul 1 20:51:59 2013 +++ src/common/lib/libc/string/strcmp.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strcmp.c,v 1.3 2013/07/01 20:51:59 joerg Exp $ */ +/* $NetBSD: strcmp.c,v 1.4 2018/02/04 20:22:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strcmp.c,v 1.3 2013/07/01 20:51:59 joerg Exp $"); +__RCSID("$NetBSD: strcmp.c,v 1.4 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -57,9 +57,6 @@ int strcmp(const char *s1, const char *s2) { - _DIAGASSERT(s1 != NULL); - _DIAGASSERT(s2 != NULL); - while (*s1 == *s2++) if (*s1++ == 0) return (0); Index: src/common/lib/libc/string/strcpy.c diff -u src/common/lib/libc/string/strcpy.c:1.3 src/common/lib/libc/string/strcpy.c:1.4 --- src/common/lib/libc/string/strcpy.c:1.3 Tue Nov 8 16:52:11 2011 +++ src/common/lib/libc/string/strcpy.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strcpy.c,v 1.3 2011/11/08 16:52:11 joerg Exp $ */ +/* $NetBSD: strcpy.c,v 1.4 2018/02/04 20:22:17 mrg Exp $ */ /* * Copyright (c) 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strcpy.c,v 1.3 2011/11/08 16:52:11 joerg Exp $"); +__RCSID("$NetBSD: strcpy.c,v 1.4 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -52,9 +52,6 @@ strcpy(char *to, const char *from) { char *save = to; - _DIAGASSERT(to != NULL); - _DIAGASSERT(from != NULL); - for (; (*to = *from) != '\0'; ++from, ++to); return(save); } Index: src/common/lib/libc/string/memcmp.c diff -u src/common/lib/libc/string/memcmp.c:1.4 src/common/lib/libc/string/memcmp.c:1.5 --- src/common/lib/libc/string/memcmp.c:1.4 Mon Dec 2 21:21:33 2013 +++ src/common/lib/libc/string/memcmp.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: memcmp.c,v 1.4 2013/12/02 21:21:33 joerg Exp $ */ +/* $NetBSD: memcmp.c,v 1.5 2018/02/04 20:22:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: memcmp.c,v 1.4 2013/12/02 21:21:33 joerg Exp $"); +__RCSID("$NetBSD: memcmp.c,v 1.5 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -55,8 +55,6 @@ __RCSID("$NetBSD: memcmp.c,v 1.4 2013/12 int memcmp(const void *s1, const void *s2, size_t n) { - _DIAGASSERT(s1 != 0); - _DIAGASSERT(s2 != 0); if (n != 0) { const unsigned char *p1 = s1, *p2 = s2; Index: src/common/lib/libc/string/strcat.c diff -u src/common/lib/libc/string/strcat.c:1.2 src/common/lib/libc/string/strcat.c:1.3 --- src/common/lib/libc/string/strcat.c:1.2 Mon Jun 4 18:19:27 2007 +++ src/common/lib/libc/string/strcat.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strcat.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ +/* $NetBSD: strcat.c,v 1.3 2018/02/04 20:22:17 mrg Exp $ */ /* * Copyright (c) 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)strcat.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strcat.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); +__RCSID("$NetBSD: strcat.c,v 1.3 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -55,7 +55,6 @@ strcat(char *s, const char *append) char *t = s; _DIAGASSERT(t != NULL); - _DIAGASSERT(append != NULL); for (; *t; ++t) ; Index: src/common/lib/libc/string/strncmp.c diff -u src/common/lib/libc/string/strncmp.c:1.2 src/common/lib/libc/string/strncmp.c:1.3 --- src/common/lib/libc/string/strncmp.c:1.2 Mon Jun 4 18:19:27 2007 +++ src/common/lib/libc/string/strncmp.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strncmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */ +/* $NetBSD: strncmp.c,v 1.3 2018/02/04 20:22:17 mrg Exp $ */ /* * Copyright (c) 1989, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strncmp.c,v 1.2 2007/06/04 18:19:27 christos Exp $"); +__RCSID("$NetBSD: strncmp.c,v 1.3 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -49,9 +49,6 @@ int strncmp(const char *s1, const char *s2, size_t n) { - _DIAGASSERT(s1 != NULL); - _DIAGASSERT(s2 != NULL); - if (n == 0) return (0); do { Index: src/common/lib/libc/string/strchr.c diff -u src/common/lib/libc/string/strchr.c:1.5 src/common/lib/libc/string/strchr.c:1.6 --- src/common/lib/libc/string/strchr.c:1.5 Wed Aug 31 15:48:32 2011 +++ src/common/lib/libc/string/strchr.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strchr.c,v 1.5 2011/08/31 15:48:32 plunky Exp $ */ +/* $NetBSD: strchr.c,v 1.6 2018/02/04 20:22:17 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)index.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strchr.c,v 1.5 2011/08/31 15:48:32 plunky Exp $"); +__RCSID("$NetBSD: strchr.c,v 1.6 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -51,7 +51,6 @@ char * strchr(const char *p, int ch) { const char cmp = ch; - _DIAGASSERT(p != NULL); for (;; ++p) { if (*p == cmp) { Index: src/common/lib/libc/string/strrchr.c diff -u src/common/lib/libc/string/strrchr.c:1.5 src/common/lib/libc/string/strrchr.c:1.6 --- src/common/lib/libc/string/strrchr.c:1.5 Fri Jul 17 19:37:57 2009 +++ src/common/lib/libc/string/strrchr.c Sun Feb 4 20:22:17 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: strrchr.c,v 1.5 2009/07/17 19:37:57 dsl Exp $ */ +/* $NetBSD: strrchr.c,v 1.6 2018/02/04 20:22:17 mrg Exp $ */ /* * Copyright (c) 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: strrchr.c,v 1.5 2009/07/17 19:37:57 dsl Exp $"); +__RCSID("$NetBSD: strrchr.c,v 1.6 2018/02/04 20:22:17 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -52,8 +52,6 @@ strrchr(const char *p, int ch) char *save; const char c = ch; - _DIAGASSERT(p != NULL); - for (save = NULL;; ++p) { if (*p == c) { /* LINTED const cast-away */ Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.11 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.12 --- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.11 Sun Feb 4 01:14:42 2018 +++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc Sun Feb 4 20:22:17 2018 @@ -1161,6 +1161,11 @@ void GetPcSpBp(void *context, uptr *pc, *pc = ucontext->uc_mcontext.mc_rip; *bp = ucontext->uc_mcontext.mc_rbp; *sp = ucontext->uc_mcontext.mc_rsp; +# elif SANITIZER_NETBSD + ucontext_t *ucontext = (ucontext_t*)context; + *pc = ucontext->uc_mcontext.__gregs[_REG_RIP]; + *bp = ucontext->uc_mcontext.__gregs[_REG_RBP]; + *sp = ucontext->uc_mcontext.__gregs[_REG_RSP]; # else ucontext_t *ucontext = (ucontext_t*)context; *pc = ucontext->uc_mcontext.gregs[REG_RIP]; @@ -1194,7 +1199,16 @@ void GetPcSpBp(void *context, uptr *pc, #elif defined(__sparc__) ucontext_t *ucontext = (ucontext_t*)context; uptr *stk_ptr; -# if defined (__arch64__) +# if SANITIZER_NETBSD + *pc = _UC_MACHINE_PC(ucontext); + *sp = _UC_MACHINE_SP(ucontext); +# if defined (__arch64__) + stk_ptr = (uptr *) (*sp + 2047); +# else + stk_ptr = (uptr *) *sp; +# endif + *bp = stk_ptr[15]; +# elif defined (__arch64__) *pc = ucontext->uc_mcontext.mc_gregs[MC_PC]; *sp = ucontext->uc_mcontext.mc_gregs[MC_O6]; stk_ptr = (uptr *) (*sp + 2047); Index: src/external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_platform.h diff -u src/external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_platform.h:1.2 src/external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_platform.h:1.3 --- src/external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_platform.h:1.2 Sun Feb 4 01:14:42 2018 +++ src/external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_platform.h Sun Feb 4 20:22:18 2018 @@ -16,7 +16,8 @@ #if (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ defined(__APPLE__)) && \ (defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \ - defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__)) + defined(__aarch64__) || defined(__mips__) || defined(__powerpc64__) || \ + defined(__sparc__)) # define CAN_SANITIZE_UB 1 #elif defined(_WIN32) # define CAN_SANITIZE_UB 1