This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Fix -D_FORTIFY_SOURCE memmove and bcopy
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ulrich Drepper <drepper at gmail dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Thu, 9 Dec 2010 13:19:35 +0100
- Subject: [PATCH] Fix -D_FORTIFY_SOURCE memmove and bcopy
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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@redhat.com>
* string/bits/string3.h (memmove, bcopy): Remove __restrict.
--- libc/string/bits/string3.h
+++ libc/string/bits/string3.h
@@ -1,4 +1,4 @@
-/* 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
@@ -53,8 +53,7 @@ __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));
}
@@ -88,8 +87,7 @@ __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