9 Dec 2010 13:19
[PATCH] Fix -D_FORTIFY_SOURCE memmove and bcopy
Jakub Jelinek <jakub <at> redhat.com>
2010-12-09 12:19:35 GMT
2010-12-09 12:19:35 GMT
Hi! http://gcc.gnu.org/PR46863 shows that with recent GCCs memmove (or bcopy) might be "optimized" into memcpy with -D_FORTIFY_SOURCE, even when the arguments overlap, because of the wrong restrict qualifiers. Fixed thusly. 2010-12-09 Jakub Jelinek <jakub <at> redhat.com> * string/bits/string3.h (memmove, bcopy): Remove __restrict. --- libc/string/bits/string3.h +++ libc/string/bits/string3.h <at> <at> -1,4 +1,4 <at> <at> -/* Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005, 2007, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or <at> <at> -53,8 +53,7 <at> <at> __NTH (memcpy (void *__restrict __dest, __const void *__restrict __src, } __extern_always_inline void * -__NTH (memmove (void *__restrict __dest, __const void *__restrict __src, - size_t __len)) +__NTH (memmove (void *__dest, __const void *__src, size_t __len)) { return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); } <at> <at> -88,8 +87,7 <at> <at> __NTH (memset (void *__dest, int __ch, size_t __len)) #ifdef __USE_BSD __extern_always_inline void -__NTH (bcopy (__const void *__restrict __src, void *__restrict __dest, - size_t __len)) +__NTH (bcopy (__const void *__src, void *__dest, size_t __len)) { (void) __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); } Jakub
RSS Feed